Skip to content

Commit

Permalink
3.0.6-beta - Working on async event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
adospace committed Nov 24, 2024
1 parent c202d27 commit e857571
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
Solution_Name: ./src/MauiReactor.Build.sln
Test_Project: ./samples/UnitTests/UnitTests.csproj
TemplatePack_Name: ./src/MauiReactor.TemplatePack/MauiReactor.TemplatePack.csproj
Version: 3.0.5-beta
Version: 3.0.6-beta

steps:
- name: Checkout
Expand Down
129 changes: 69 additions & 60 deletions templates/MauiReactorTemplate.StartupSampleXaml/Components/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,56 +49,7 @@ public override VisualNode Render()
Grid(
new SfPullToRefresh
{
VScrollView(
VStack(
//new CategoryChart()
// .IsBusy(State.IsBusy)
// .TodoCategoryData(State.TodoCategoryData)
// .TodoCategoryColors(State.TodoCategoryColors)//,

Label("Projects")
.Style(ResourceHelper.GetResource<Style>("Title2")),

HScrollView(
HStack(
State.Projects.Select(project => new ProjectCardView()
.Project(project)
.IsBusy(State.IsBusy)
).ToArray()
)
.Spacing(15)
.Padding(new Thickness(30, 0))
)
.Margin(new Thickness(-30, 0)),

Grid(
Label("Tasks")
.Style(ResourceHelper.GetResource<Style>("Title2"))
.VerticalOptions(LayoutOptions.Center),
ImageButton()
.Source(ResourceHelper.GetResource<ImageSource>("IconClean"))
.HorizontalOptions(LayoutOptions.End)
.VerticalOptions(LayoutOptions.Center)
.Aspect(Aspect.Center)
.HeightRequest(44)
.WidthRequest(44)
.IsVisible(State.Tasks.Any(t => t.IsCompleted))
.OnClicked(CleanTasks)
)
.HeightRequest(44),

VStack(
State.Tasks.Select(task => new TaskView()
.Task(task)
.IsBusy(State.IsBusy)
).ToArray()
)
.Spacing(15)

)
.Spacing(ResourceHelper.GetResource<OnIdiom<double>>("LayoutSpacing"))
.Padding(ResourceHelper.GetResource<OnIdiom<Thickness>>("LayoutPadding"))
)
RenderBody()
}
.IsRefreshing(State.IsRefreshing)
.OnRefreshing(Refresh)
Expand All @@ -109,6 +60,60 @@ public override VisualNode Render()
.OnAppearing(LoadOrRefreshData);
}

VisualNode RenderBody()
{
return VScrollView(
VStack(
new CategoryChart()
.IsBusy(State.IsBusy)
.TodoCategoryData(State.TodoCategoryData)
.TodoCategoryColors(State.TodoCategoryColors),

Label("Projects")
.Style(ResourceHelper.GetResource<Style>("Title2")),

HScrollView(
HStack(
State.Projects.Select(project => new ProjectCardView()
.Project(project)
.IsBusy(State.IsBusy)
).ToArray()
)
.Spacing(15)
.Padding(new Thickness(30, 0))
)
.Margin(new Thickness(-30, 0)),

Grid(
Label("Tasks")
.Style(ResourceHelper.GetResource<Style>("Title2"))
.VerticalOptions(LayoutOptions.Center),
ImageButton()
.Source(ResourceHelper.GetResource<ImageSource>("IconClean"))
.HorizontalOptions(LayoutOptions.End)
.VerticalOptions(LayoutOptions.Center)
.Aspect(Aspect.Center)
.HeightRequest(44)
.WidthRequest(44)
.IsVisible(State.Tasks.Any(t => t.IsCompleted))
.OnClicked(CleanTasks)
)
.HeightRequest(44),

VStack(
State.Tasks.Select(task => new TaskView()
.Task(task)
.IsBusy(State.IsBusy)
).ToArray()
)
.Spacing(15)

)
.Spacing(ResourceHelper.GetResource<OnIdiom<double>>("LayoutSpacing"))
.Padding(ResourceHelper.GetResource<OnIdiom<Thickness>>("LayoutPadding"))
);
}

async Task LoadOrRefreshData()
{
if (!State.DataLoaded)
Expand Down Expand Up @@ -137,6 +142,8 @@ async Task LoadData()
{
SetState(s => s.IsBusy = true);

await Task.Delay(100);

State.Projects = await _projectRepository.ListAsync();

var chartData = new List<CategoryChartData>();
Expand Down Expand Up @@ -169,6 +176,9 @@ async Task Refresh()
try
{
SetState(s => s.IsRefreshing = true);

await Task.Delay(1000);

await LoadData();
}
catch (Exception e)
Expand Down Expand Up @@ -229,11 +239,12 @@ public override VisualNode Render()
.TrackFill(Theme.IsLightTheme ?
ResourceHelper.GetResource<Color>("LightBackground") :
ResourceHelper.GetResource<Color>("DarkBackground"))
.CapStyle(Syncfusion.Maui.Toolkit.Charts.CapStyle.BothCurve)
.CapStyle(Syncfusion.Maui.Toolkit.Charts.CapStyle.BothCurve),

}
}
.CustomView(RenderCustomView())
.IsVisible(_isBusy)
.IsActive(_isBusy)
.BackgroundColor(Colors.Transparent)
.VFill()
)
Expand Down Expand Up @@ -266,11 +277,11 @@ public override VisualNode Render()
{
return Border(
new SfShimmer
{
RenderContent()
{
RenderContent()
}
.CustomView(RenderCustomView())
.IsActive(_isBusy)
.CustomView(RenderCustomView())
.BackgroundColor(Colors.Transparent)
.VFill()
)
Expand Down Expand Up @@ -313,22 +324,20 @@ IEnumerable<VisualNode> RenderTags()
foreach (var tag in _project?.Tags ?? Enumerable.Empty<Tag>())
{
yield return Border(
Label()
.Text(() => tag.Title)
Label(tag.Title)
.TextColor(Theme.IsLightTheme ?
ResourceHelper.GetResource<Color>("LightBackground") :
ResourceHelper.GetResource<Color>("DarkBackground"))
.FontSize(14)
.VerticalOptions(LayoutOptions.Center)
.VCenter()
.VerticalTextAlignment(TextAlignment.Center)
)
.Padding(12, 0, 12, 8)
.OnAndroid(_ => _.Padding(12, 0, 12, 0))
.StrokeCornerRadius(16)
.HeightRequest(32)
.StrokeThickness(0)
.BackgroundColor(tag.DisplayColor)
;
.Background(tag.DisplayColor);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected override void OnAddChild(VisualNode widget, BindableObject childContro
{
NativeControl.PullableContent = view;
}


base.OnAddChild(widget, childControl);
}
Expand Down Expand Up @@ -90,8 +91,10 @@ protected override void OnAddChild(VisualNode widget, BindableObject childContro
{
NativeControl.CustomView = (View)childControl;
}

base.OnAddChild(widget, childControl);
else
{
base.OnAddChild(widget, childControl);
}
}
}

Expand Down

0 comments on commit e857571

Please sign in to comment.