neo-6m uno_Uno-统治所有人的平台

neo-6m uno

First, we should start off with what Uno is and why you should care.

首先,我们应该从Uno是什么以及为什么要关心开始。

As stated on their website, Uno is "The only platform for building native mobile, desktop and WebAssembly apps with C#, XAML from a single codebase. Open source and professionally supported."

如其网站上所述 ,Uno是“唯一的平台,可通过单一代码库使用C#,XAML构建本机移动,桌面和WebAssembly应用程序。开源且受到专业支持。”

这是什么意思? (What does this mean?)

Well if you have any experience (or not) building a mobile app and a subsequent web app, you have essentially had to build both separately, outside of potentially sharing data through an API.

好吧,如果您有(或没有)构建移动应用程序和后续Web应用程序的经验,那么除了通过API可能共享数据之外,您实际上必须分别构建两者。

Before Xamarin, you would even have had to build the iOS and Android apps separately using different languages (Swift/Objective-C and Java/Kotlin respectively). Uno introduces a way to build for iOS, Android, Web, and UWP using shared logic and UI.

在使用Xamarin之前,您甚至不得不使用不同的语言(分别为Swift / Objective-C和Java / Kotlin)分别构建iOS和Android应用程序。 Uno引入了一种使用共享逻辑和UI为iOS,Android,Web和UWP进行构建的方法。

This is huge.

这是巨大的。

Sharing logic between platforms has been the "easy" part for developers. Sharing UI, however, is not. There is a huge difference in UI between Android and iOS and even larger differences between web and mobile. Xamarin.Forms allows us to share UI for Android and iOS but we were still on our own for the web.

平台之间共享逻辑一直是开发人员的“轻松”部分。 但是,不是共享UI。 Android和iOS之间的UI差异巨大,网络和移动设备之间的差异甚至更大。 Xamarin.Forms允许我们共享Android和iOS的UI,但在网络上我们仍然靠自己。

Uno enables you to write the UI once, then, using native controls, deploys native UI look and feel to each of your platforms. This means, you write the same code for a button regardless of the platform the button is for, and the user will see the native button for their platform.

Uno使您可以编写一次UI,然后使用本机控件将本机UI外观部署到每个平台。 这意味着,无论按钮用于哪个平台,都为该按钮编写相同的代码,并且用户将看到其平台的本机按钮。

它是如何工作的? (How does it work?)

The Uno Platform works differently depending on what you're building.

Uno平台的工作方式取决于您所构建的内容。

The platform specific UI is created by taking the visual tree and rendering into what the platform supports:

通过将可视化树并渲染为平台支持的内容来创建特定于平台的UI:

iOS - UI Kit

iOS - UI套件

Android - ViewGroups and Views

Android的 - ViewGroups和视图

Web - Native controls

网络 -本地控制

The logic is also deployed differently for each platform.

每个平台的逻辑部署也不同。

When building a UWP app, Uno runs on top of, well, UWP and WinUI. When building Android and iOS apps, Uno runs on top of the Xamarin Native Stack. Finally, when you're building a Web App, Uno runs on top of WebAssembly. The mobile apps and web apps all run with Mono runtime. When it all comes together, it looks a little like this:

在构建UWP应用时,Uno可以运行在UWP和WinUI之上。 在构建Android和iOS应用程序时,Uno在Xamarin本机堆栈的顶部运行。 最后,当您构建Web应用程序时,Uno在WebAssembly之上运行。 移动应用程序和Web应用程序均与Mono运行时一起运行。 当所有这些放在一起时,看起来有点像这样:

Well this looks nice, but what's really happening under the hood?

好吧,这看起来不错,但是引擎盖下到底发生了什么呢?

让我们分解一下: (Let's break it down:)

Android and iOS

Android和iOS

  1. You write your C# and XAML code in Visual Studio

    您在Visual Studio中编写C#和XAML代码
  2. Uno takes the code and lets you add any Xamarin specific libraries or tools

    Uno获取代码,并允许您添加任何Xamarin特定的库或工具
  3. Mono runtime executes the C# code

    Mono运行时执行C#代码

This process is essentially the same as regular Xamarin. The big difference between Xamarin and Uno comes with the ability to run the same UI on the Web.

此过程与常规Xamarin基本相同。 Xamarin和Uno之间的最大区别在于可以在Web上运行相同的UI。

Web Apps -

网络应用 -

  1. You reuse both your logic and UI  that you wrote for your mobile apps.

    您可以重用为移动应用程序编写的逻辑UI

  2. Uno uses the Web Assembly Bootstrapper to take any .NET standard library and execute these files in the JavaScript console.

    Uno使用Web Assembly Bootstrapper来获取任何.NET标准库并在JavaScript控制台中执行这些文件。

  3. Mono runtime then executes the code

    然后,Mono运行时执行代码

The ability for Uno to utilize Web Assembly (which is what allows you to write your code in C# and not JavaScript) is what makes Uno so unique.

Uno能够利用Web Assembly(这是使您可以用C#而不是JavaScript编写代码的能力)的能力使Uno如此独特。

UWP -

UWP-

  1. You reuse both your logic and UI  that you wrote for your mobile apps and Web Assembly Apps.

    您可以重用为移动应用程序和Web Assembly Apps编写的逻辑UI

  2. Your code is run through the Windows UI which does not need the Mono runtime to execute.

    您的代码是通过Windows UI运行的,不需要执行Mono运行时。

The big difference here is that UWP apps already have the Windows namespaces and do not need to reference the Uno.UI. The benefit Uno provides here is the ability to reuse the code you've already written for mobile and web.

这里的最大区别是UWP应用程序已经具有Windows名称空间,并且不需要引用Uno.UI。 Uno在此提供的好处是可以重用您已经为移动设备和Web编写的代码。

Now that we have an idea of how this beauty works, let's write some code!

现在我们已经了解了这种美的原理,让我们编写一些代码!

To get started with Uno, follow their instructions here.

要开始使用Uno,请按照此处的说明进行操作。

When you create your Uno solution in Visual Studio, there is a similar feel to when you create a Xamarin.Forms solution because of the different projects created for you. Here is a look at the projects that are auto-created:

在Visual Studio中创建Uno解决方案时,由于为您创建了不同的项目,因此与创建Xamarin.Forms解决方案时的感觉相似。 看一下自动创建的项目:

As you would see in a Xamarin.Forms project, there are separate projects for each platform and a single shared project. The Droid, iOS, UWP, and Wasm projects are all the same as if you had created a blank app for each, the only difference being references to the Uno UI. The magic happens in the Shared project.

正如您在Xamarin.Forms项目中看到的那样,每个平台都有单独的项目,而单个共享项目也有。 Droid,iOS,UWP和Wasm项目与您为每个项目创建一个空白应用程序一样,唯一的不同是对Uno UI的引用。 魔术发生在共享项目中。

Similar to the Shared project in Xamarin.Forms, this is where you will write all your shared logic and UI. Uno provides support for the MVVM, a design pattern many developers are familiar and comfortable with.

与Xamarin.Forms中的Shared项目相似,在这里您将编写所有共享的逻辑和UI。 Uno提供了对MVVM的支持, MVVM是许多开发人员熟悉并熟悉的设计模式。

那么,成品看起来像什么? (So, what does a finished product look like?)

Using the example "Todo" app provided by Uno here, here are examples from each of the four platforms.

使用Uno 这里提供的示例“ Todo”应用程序,这里是来自四个平台的示例。

iOS

的iOS

Android

安卓系统

Web

网页

UWP

超人

These projects all use logic and UI from the shared project. Code once, four apps.

这些项目都使用共享项目中的逻辑和UI。 编写一次,四个应用程序。

让我们谈谈调试。 (Let's talk debugging. )

Debugging in Uno can be a bit different depending which platform you are trying to debug.

Uno中的调试可能会有所不同,具体取决于您要调试的平台。

Android and iOS - For mobile, you will use the same Mono debugger you are used to using in Visual Studio, with access to all your favorite breakpoints, value changes, etc.

Android和iOS-对于移动设备,您将使用与Visual Studio中相同的Mono调试器,并可以访问所有喜欢的断点,值更改等。

Web - Currently there is only support for chromium debugging, which means Chrome and Edge.

网络 -目前仅支持Chrome调试,即Chrome和Edge。

UWP - Here, the tooling comes from .NET studios which is not as efficient with the mono runtime.

UWP-在这里,该工具来自.NET Studio,这在Mono运行时中效率不高。

Want to try out Uno but don't want to go through the steps to get set up through Visual Studio?

是否想尝试Uno,但不想执行通过Visual Studio进行设置的步骤?

Then checkout their playground!

然后结帐他们的游乐场

The Uno Playground is a fun and easy way to look at how different items render on different platforms. They make it quick and easy to try out new styles and is great for beginners and tutorials.

Uno Playground是一种有趣而简单的方法,可以查看不同项目在不同平台上的呈现方式。 它们使您可以轻松快捷地尝试新样式,非常适合初学者和教程。

我们可以期待哪些未来功能? (What are future features we can look forward to?)

  1. Support for MacOS or Linux.

    支持MacOS或Linux。
  2. More features from UWP API

    UWP API的更多功能
  3. Support for smart watches

    支持智能手表

The true beauty of Uno is that it encompasses what we as developers should all be striving to accomplish - building on top of each others' accomplishments. We don't need to re-create the wheel, real innovation happens when you stand on the shoulders of giants and we all move upwards.

Uno的真正优点在于它涵盖了我们所有人作为开发人员都应努力实现的目标-建立在彼此的成就之上。 我们不需要重新制造轮子,当您站在巨人的肩膀上并且我们都向上移动时,真正的创新就会发生。

Happy coding.

快乐的编码。

For more lessons and tips for Uno, checkout my blog.

有关Uno的更多课程和提示,请查看我的博客

翻译自: https://www.freecodecamp.org/news/uno-platform/

neo-6m uno

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值