This commit is contained in:
Jesse 2022-10-14 10:49:03 +11:00
Родитель 74ed5f448c
Коммит 7568e0b685
3 изменённых файлов: 75 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Maui.Graphics;
/*
// Flutter only support if render
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
if (someCondition == true)
Text('The condition is true!'),
],
);
}
}
// Flutter render list
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
if (someCondition == true) ...[
Text('Widget A'),
Text('Widget B'),
Text('Widget C'),
],
],
);
}
}
*/
namespace Comet.Samples.Comparisons
{
public class Section5 : View
{
bool showMore = true;
int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
string fillColor = "Red";
[Body]
View body() => new VStack {
new Text("Hello Comet!"),
() => {
if(showMore)
return new Text("If condition is working");
else
return new Text("Else condition is working");
},
nums.Select(i => new Text($"Show rows {i}")),
showMore?new Text("Ternary is working"):null,
() => {
switch(fillColor)
{
case "Red":
return new ShapeView(new Rectangle().Fill(Colors.Red)).Frame(100, 60);
default:
return null;
}
}
};
}
}

Просмотреть файл

@ -73,6 +73,7 @@ namespace Comet.Samples
new MenuItem("SwiftUI Tutorial Section 4b", ()=> new Section4b()),
new MenuItem("SwiftUI Tutorial Section 4c", ()=> new Section4c()),
new MenuItem("SwiftUI Tutorial Section 4d", ()=> new Section4c()),
new MenuItem("Compare with Flutter",() => new Section5()),
new MenuItem("DavidSample1",()=> new DavidSample1()),
new MenuItem("DavidSample1a",()=> new DavidSample1a()),
new MenuItem("DavidSample1b",()=> new DavidSample1b()),

Просмотреть файл

@ -30,6 +30,12 @@ namespace Comet
foreach (var v in ieiv)
Add(v);
}
else if (obj is Func<View> func)
{
var view = func();
if (view != null)
Add(view);
}
else
{
throw new NotSupportedException("The object either needs to be a View, IView, or IEnumerable<IView>/IEnumerable<View>");