xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Enhancement] Managed UI For Xamarin.Forms=> Xamarin.UI #10127

Closed John0King closed 2 years ago

John0King commented 4 years ago

Summary

Today there are many managed/web based UI Framework has achieve great success for mobile develop
For example :

and their success all come with that the UI is very easy to control ! and now Xamarin.Forms is still working on to use platform native controls/layout. that cause many devs to release third party UI Framework much harder , we had to build each render for each platform (although this ability is great), otherwise it will not work. that also make harder to customize the UI (for example , TextBox's border , background color), and also make dev who new to Xamarin.Forms harder to learn .

I'm hoping that there is a set of managed UI , that can work together to Xamarin.Forms but should lighter than Xamarin.Forms (app lunch faster).

The managed UI should also have a virtual graphic engine that enable any kind of control/UI can be implement.

Features

managed pages, managed layouts and managed controls give us the full screen as a "canvas" , we can "draw" anything on it. managed controls may not be fully managed, it also may be a native controls that play with the "drawing styles" (backgroundColor, borderThinkness, FontColor, margin, borderRadius, ect ) , for example the TextBox managed control

John0King commented 4 years ago

an idea of the lightweight :

at last, these will make third party UI framework release easier.

and for the virtual graphic engine , maybe the opensource C# game engine can help:

With a drawing engine abstract by DirectX, OpenGL, Vulken and WebGL , Xamarin's Managed UI should be really fast and smooth.

bondarenkod commented 4 years ago

It would be awesome to have .Net based tool from Xamarin family with flutter-like approach to render UI.

yurkinh commented 4 years ago

Here are some Proof of Concepts for this idea:

charlesroddie commented 4 years ago

Good goals here. But you can basically do this already, and so it's not necessary to do a lot of extra work inside or replacing Xamarin.Forms.

that cause many devs to release third party UI Framework much harder , we had to build each render for each platform

Just write a control using SkiaSharp, and it can be used it on any .Net UI platform. This work will complete the picture: https://github.com/mono/SkiaSharp.Extended/pull/79

yurkinh commented 4 years ago

Here is one more PoC of SkiaSharp backend for two platforms link. Very close to what this topic is about

John0King commented 4 years ago

a little suggestion here, the drawing engine is not the primary goal here, it's jut one tech to support complex graphic, the main goal here should be unify ui controls (look the same on every platform), some thought:

the final goal is that if you UI app do not require any platform tech (at least 90% of app are only force on UI , that's why html5 and flutter popular, because they can define the UI that the customer/boss/designer want ) just a ridicule (吐槽一下,do not know how to translate) : xamarin.forms is tech that build UI applications, but the most vulnerable part is to control UI 🤣


another part is Xaml, that I do not know where should I fill the issue : here ? maui ? xaml stanard ? roslyn? runtime?

thought 1: base on current XAML,

XAML is the most powerful UI language in the past, but it not been innovate since it was born, as a "language" it missing control flow and loop flow .

  1. we should add x:if x:foreach to the xaml compiler
  2. command and event , event give us more control, and event today there are more event than command, and command is just a { CanExcuate:boolean, Action: (...args)=>void } and we can use <Button Tap="e=> doSomeThing(e)" />
  3. more compiler power by drop the DataContext and in favor of direct ref , eg. <Entry x:Name="txt" Text="2020-1-1" /> <Label Text="{ txt?.Text | DateFormater: 'yyyy/MM/dd' | Formate: 'Time is {0} , cheers' }" />

so why not just blazor, blazor requir us have full C# syntax understand, that will have a dependency on Roslyn compiler and we have to compile it xaml=>C# => il , it then not possible to be just a template language . with is version , we can have both a full compiled version and an interpreter (we only need understand only a few syntax, and it's part of the XAML : member access, index , lambda , formater+convert)
angular's template is greet, and we should lean from it

thought 2 : component language , maybe just a fantasy

it's a little magical, this one need to do in roslyn , since Xaml will fully compile to IL, and C# is also comple to IL , and Xaml is great to represent Cascade UI maybe one day we can use them as we want

public class OurUI :  View
{
     public View Body =>{
        return  >>>>xaml
         <Grid>  ....  </Grid>
<<<< 
     }
}

// equal to
public class OurUI :  View
{
     public View Body =>{
        return  new Grid()
        {
            //....
        }
     }
}

a little out of the topic , but when this can be use , imaging


public const byte[] ImageBytes =  >>>>bytesloader   ./Image.png    <<<< // read the image and return it's array
// equal to 
public const byte[] ImageBytes = 0xFF00CCDDEEFFAA0366......;
---------------
public const string Tempalte  = >>>> static-compile
var tag = new TagBuilder("div");
div.AddClass("btn")

return div.ToString()
<<<<;
jfversluis commented 2 years ago

Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.

If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!