xamarin.forms

介绍 (Introduction)

Before you actually start developing a mobile app, you have to make various decisions. This includes, for example, the choice of the framework. At the time of creating the app which will be transformed, there was a requirement to create an app for Android, iOS and Windows Phone. That is why the decision to use Xamarin Native was made at the time. It was possible to share the business logic between the three apps and only the UI for the different platforms had to be developed separately. Over time, the choice of Xamarin Native was questioned, so that a platform change was recently carried out. The app has now been implemented with the help of Xamarin.Forms. This article documents this procedure.

在实际开始开发移动应用程序之前,您必须做出各种决定。 例如,这包括框架的选择。 在创建将要转换的应用程序时,需要为Android,iOS和Windows Phone创建一个应用程序。 这就是当时决定使用Xamarin Native的原因。 可以在这三个应用程序之间共享业务逻辑,并且只需要分别开发用于不同平台的UI。 随着时间的流逝,Xamarin Native的选择受到质疑,因此最近进行了平台更改。 该应用程序现已在Xamarin.Forms的帮助下实施。 本文介绍了此过程。

Xamarin Native与Xamarin.Forms (Xamarin Native vs. Xamarin.Forms)

At this point I would like to roughly explain the difference between Xamarin Native and Xamarin.Forms in order to make the actual implementation easier to understand. Xamarin Native is suitable for the development of apps that want to share the business logic between different platforms. However, the UI must be written individually for each platform. For example, storyboards can be used for the iOS version or XAML under UWP. The following picture shows the structure of a Xamarin native app:

在这一点上,我想粗略地解释Xamarin Native和Xamarin.Forms之间的区别,以使实际实现更容易理解。 Xamarin Native适用于希望在不同平台之间共享业务逻辑的应用程序的开发。 但是,必须为每个平台分别编写UI。 例如,情节提要可用于iOS版本或UWP下的XAML。 下图显示了Xamarin本机应用程序的结构:

In comparison, Xamarin.Forms offers the possibility to share the UI between the individual platforms in addition to the business logic, so that, ideally, everything only has to be written once.

相比之下,除了业务逻辑之外,Xamarin.Forms还提供了在各个平台之间共享UI的可能性,因此,理想情况下,所有内容仅需编写一次。

With this approach, depending on the app, you can share up to 95% of the code and only have to develop a very small part for each platform individually. In both cases 100% of the native APIs are available if required. By using Xamarin Native or Xamarin.Forms, there are no performance losses, since everything is compiled natively.

通过这种方法,根据应用程序,您可以共享多达95%的代码,而只需要为每个平台单独开发非常小的一部分。 在这两种情况下,如果需要,都可以使用100%的本机API。 使用Xamarin Native或Xamarin.Forms,不会造成性能损失,因为所有内容都是本地编译的。

起始位置 (Starting position)

The starting point is an app developed with Xamarin Native for Android, iOS and Windows Phone. It enables the customer to add a number of images to various projects that are accessed via an API. In a second step you can add a comment to each of the images. Then everything is sent to the backend via the API, where the images and comments are stored in a database. Here are a few screenshots of the Android version, implemented with Xamarin Native:

起点是使用Xamarin Native开发的适用于Android,iOS和Windows Phone的应用程序。 它使客户可以向通过API访问的各种项目添加大量图像。 在第二步中,您可以为每个图像添加注释。 然后,所有内容都通过API发送到后端,其中图像和注释存储在数据库中。 这是使用Xamarin Native实现的Android版本的一些屏幕截图:

改造 (Replatforming)

Fortunately, I already used the MVVM pattern in the original development of the app, which can now be implemented even more easily with the help of Xamarin.Forms and XAML and thus simplifies the switch from Xamarin Native to Xamarin.Forms.

幸运的是,我已经在应用程序的原始开发中使用了MVVM模式,现在可以借助Xamarin.Forms和XAML更加轻松地实现该模式,从而简化了从Xamarin Native到Xamarin.Forms的转换。

MVVM (Model View View Model) is a design pattern, which provides for a strict separation between business logic and the UI.

MVVM(模型视图视图模型)是一种设计模式,它在业务逻辑和UI之间提供了严格的分隔。

I started in Visual Studio with an empty Xamarin.Forms project, which now only supports Android and iOS, since UWP was not important for the customer anymore. In the next step, the NuGet packages used were analyzed in the old app and added according to the different projects in the new project.

我从Visual Studio开始使用一个空的Xamarin.Forms项目,该项目现在仅支持Android和iOS,因为UWP对客户而言不再重要。 下一步,将在旧应用程序中分析使用的NuGet软件包,并根据新项目中的不同项目将其添加。

The business logic was then transferred step by step and adjustments were made directly. For example, I had implemented the determination of device information on each platform individually, but with the help of Xamarin.Essentials, this logic could be implemented platform-independently in the .NET Standard project. In this context, I also looked more closely at the implementation of the MVVM pattern and made minor adjustments to ViewModels and services. Thanks to the good preparatory work, this process did not take much time.

然后逐步转移业务逻辑,并直接进行调整。 例如,我已经在每个平台上单独实现了设备信息的确定,但是借助Xamarin.Essentials ,可以在.NET Standard项目中独立于平台实现此逻辑。 在这种情况下,我还更加仔细地研究了MVVM模式的实现,并对ViewModels和服务进行了较小的调整。 由于进行了良好的准备工作,因此此过程无需花费很多时间。

The next step focused on the UI. As you can see from the screenshots above, the app did not have an overly complex UI because the functionality was always in the foreground. Due to the fact that the XAML dialect differs between UWP with Windows Phone and Xamarin.Forms, almost nothing could be used from the old app. I took advantage of this opportunity and made adjustments to the UI, which makes the app look more contemporary.

下一步集中在UI上。 从上面的屏幕截图中可以看到,该应用程序没有过于复杂的UI,因为该功能始终处于前台。 由于XAML的方言在带有Windows Phone的UWP和Xamarin.Forms之间有所不同,因此旧应用程序几乎无法使用任何东西。 我抓住了这个机会,对UI进行了调整,从而使该应用看起来更加现代。

While a lot of logic was still implemented in the activities under Android and under iOS in the ViewControllers, I have now implemented the complete UI with the help of DataBinding. Here it helped me that the Xamarin Native implementation was also implemented for Windows Phone, since the DataBinding model was already used and the ViewModels were prepared Ibaccordingly.

尽管在Android和iOS的ViewControllers中的活动中仍然实现了很多逻辑,但是现在我已经在DataBinding的帮助下实现了完整的UI。 在这里,对Xamarin Native的实现也为Windows Phone实现了帮助,因为已经使用了DataBinding模型,并且ViewModels都是经过精心准备的。

Overall, the development of the UI took a little more time because almost nothing could be used. Of course, I was able to orientate myself on the existing structures, so that I didn’t have to start from scratch.

总体而言,UI的开发花费了更多时间,因为几乎无法使用任何东西。 当然,我能够使自己适应现有的结构,因此不必从头开始。

At this point I would like to show you some pictures of the new Xamarin.Forms version of the app on Android:

现在,我想向您展示一些新的Xamarin.Forms版本的Android应用程序图片:

摘要 (Summary)

For this project, I can summarize that the replatforming was worth it. Legacy implementation have been replaced by new implementations. At the same time, future adjustments to the app can now be implemented more quickly, since there is only one UI for both platforms. By implementing the Xamarin Native App with the MVVM pattern, much of the business logic could also be used nearly one to one. On the other hand, a little more time had to be invested in building the new UI, since almost nothing could be used here. However, this significantly improved the user experience.

对于这个项目,我可以总结出重新进行是值得的。 旧版实现已被新实现取代。 同时,由于两个平台只有一个用户界面,因此现在可以更快地对应用程序进行将来的调整。 通过使用MVVM模式实现Xamarin Native App,许多业务逻辑也可以一对一地使用。 另一方面,由于新的用户界面几乎无法使用,因此需要花费更多的时间来构建新的用户界面。 但是,这大大改善了用户体验。

To replatform a Xamarin Native to a Xamarin.Forms app, time must be invested until the platform change is completed, but there are numerous advantages through this change, which will definitely pay off in retrospect. We’ve used Xamarin.Forms 4.7 while replatforming the app.

要将Xamarin本机重新平台化为Xamarin.Forms应用程序,必须花费时间直到平台更改完成,但是通过此更改有很多优势,这无疑会得到回报。 我们在重新平台化应用程序时使用了Xamarin.Forms 4.7。

翻译自: https://medium.com/medialesson/replatforming-from-xamarin-native-to-xamarin-forms-f4b92499d9b

xamarin.forms


http://www.taodudu.cc/news/show-7229627.html

相关文章:

  • python可视化_python商业智能可视化
  • 为Navigation 2创建自定义behavior tree plugin
  • laravel 使用 Intervention/image 进行图片处理
  • 【C语言-数据结构与算法】-哈夫曼压缩解压缩-终局-如何做一个自己独有的压缩软件
  • pgsql-jsonb和mongodb性能比较
  • 【C语言->数据结构与算法】->哈夫曼压缩解压缩->第一阶段->哈夫曼编码解码的实现
  • The maighty power and flavor of plants
  • [intervention/image]操作图片从未如此简单
  • laravel 的 intervention-image 图像处理笔记
  • 我看了下GAAS里ROS里发布的pose 的 topic包含position和orientation,我觉得position是实际位置,orientation是期望位置。错了,是标准的里程计消息。
  • 面向对象(Oriented Object Programing)的本质
  • qpython 3h怎么使用_彭州混凝土表面气孔处理怎么施工
  • python爬取链家房价消息_Python的scrapy之爬取链家网房价信息并保存到本地
  • g0
  • SpringBoot 中使用 JWT 案例分享详解
  • 只为让你听见更好的声音 吉利缤瑞音响升级牧童套餐喇叭
  • 喝水也要喝出高逼格!这款智能保温杯,用它再也没烫过嘴~
  • 【JavaSE系列】Java中的字符串之字符串常量池
  • 毕业设计 stm32智能恒温水杯 - 单片机 物联网 嵌入式
  • 简单易用的随身泡茶杯,保温效果也不错,北鼎BUYDEEM泡茶保温杯上手
  • springboot整合shiro + jwt + redis实现权限认证(上手即用)
  • 每天五个面试题,保温杯里泡枸杞!!!
  • 基于单片机智能水杯 保温杯 定时提醒喝水 温度控制的设计与实现
  • 人到中年不得已,保温杯里泡枸杞--送程序员
  • Kubernetes入门教程 --- 使用二进制安装
  • 19k字图文讲解Vision科研常用的系统环境配置和工具(附详细命令行)
  • CSGO连接到任意服务器失败问题的解决方案(超详细)
  • 《鹅鸭杀》卡死,服务器屡遭攻击,“线上Party”还办不办了?
  • 宝藏世界中什么叫服务器中断了,宝藏世界版本检查错误解决方法 Trove登陆不了怎么办...
  • 元宇宙特点

xamarin.forms_重构:从Xamarin Native到Xamarin.Forms相关推荐

  1. Xamarin Anroid开发教程之下载安装Xamarin

    Xamarin Anroid开发教程之下载安装Xamarin Xamarin在过去安装时都会检查系统中是否安装了前面所提供的内容.而后来,Xamarin安装时只提供安装步骤,其它内容都需要读者自己下载 ...

  2. xamarin.android蓝牙,在Android上连接Xamarin的配对蓝牙设备

    请记住,Xamarin绑定到本机api所以不要担心某些"与本机方式有关";)基于你引用的anwser我编写并测试了下面的代码 . 我希望它会对你有所帮助 . class btLis ...

  3. xamarin android 微信,转换微信SDK为Xamarin绑定库 Android5.5.8 iOS1.8.6.2

    原标题:转换微信SDK为Xamarin绑定库 Android5.5.8 iOS1.8.6.2 文章第二次更新, iOS库 更新为1.8.6.2 已经可以使用的库: Android nuget: htt ...

  4. 快速开发跨平台应用之Xamarin技术

    Xamarin 介绍 Xamarin 是一个允许开发人员有效创建可跨 iOS.Android.Windows 应用程序的开发工具集.Xamarin是免费且开源的,遵循 MIT (麻省理工学院许可证)协 ...

  5. Xamarin环境搭建

    Xamarin的环境搭建 Xamarin在osx下面的环境搭建包括开发者帐号申请,下载安装Xamarin以及Xcode,以及Xamarin Studio上编写第一个应用程序.Xamarin是一个跨平台 ...

  6. Xamarin的环境搭建Xamarin.iOS

    Xamarin的环境搭建 Xamarin在osx下面的环境搭建包括开发者帐号申请,下载安装Xamarin以及Xcode,以及Xamarin Studio上编写第一个应用程序.Xamarin是一个跨平台 ...

  7. 【Xamarin挖墙脚系列:使用Xamarin进行Hybrid应用开发】

    官方地址:https://developer.xamarin.com/guides/cross-platform/advanced/razor_html_templates/ 使用Xamarin进行网 ...

  8. 为什么你没有选择xamarin?

    点击上方"dotNET全栈开发","设为星标" 加"星标★",每天11.50,好文必达 全文约900字,预计阅读时间11分钟 注:本篇文章只 ...

  9. 大叔也说Xamarin~Android篇~环境部署与破解

    原文:大叔也说Xamarin~Android篇~环境部署与破解 现在移动开发很HOT,以至于很多人都转向了它,大叔也不例外,这次有机制接触一下xamarin这个东西,其实之前也用于xamarin,只是 ...

最新文章

  1. 使用C# 3.0编译器编译 Asp.Net 项目代码
  2. 涉密计算机格式化维修,涉密计算机中的涉密信息被删除或格式化后,不可复原,可以连接互联网 - 作业在线问答...
  3. 十一:外观模式详解(Service,action与dao)
  4. 介绍下 Emacs 的包管理功能,感觉还是比较方便的
  5. ubuntu20.04LTS系统的终端terminal透明化设置
  6. 剑指offer刷题(java)|二维数组中的查找|替换空格|leetcode刷题
  7. 计算机系统结构树形流程图,计算机系统结构 第七章自考练习题答案
  8. 在基于Spring MVC的应用程序中配置favicon.ico
  9. javascript知识点总结----Function定义
  10. cloc统计想项目行数
  11. 【kafka】如何修改分区的指定副本为Leader|设计方案
  12. jmeter安装和使用-个人总结
  13. 互联网晚报 | 7月15日 星期五 | 苹果开始试产iPhone 14;银保监会回应“停贷”事件;抖音否认屏蔽词语致谐音梗大流行...
  14. 史上最详细的测试用例的设计方法及案例
  15. IT学生技术入门值得关注的网站(页)链接
  16. 大数据与云计算学习:Python网络数据采集
  17. kvm静态迁移error: Cannot access storage file
  18. 【算法】【树】已知先序中序序列求后序序列(详细解释)
  19. STEM 教育课程如何设计?
  20. 列举一些 MacBook Pro 必需的外设和应用程序推荐

热门文章

  1. matlab问题记录:索引超出矩阵维度与下标索引必须为正整数类型或逻辑类型。
  2. Antimalware Service Executable 高内存的处理办法,亲测有效
  3. Pandas —— rank( )函数进行排名
  4. Fritzing软件绘制Arduino面包板接线图传感器模块库文件231
  5. sock5系列之简单测试sock5 连通性!(二)
  6. call和apply用法
  7. 04.Linux-CentOS系统SSH连接问题
  8. 7.0android版本点三下,StarStar
  9. java flowlayout 左对齐_防止FlowLayout的垂直居中
  10. 故事的结局应该如此吧!