Skip to content

Commit d5ed0b6

Browse files
updated sample changes (#31646)
1 parent 42f05d9 commit d5ed0b6

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

src/Templates/src/templates/maui-mobile/PageModels/MainPageModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public partial class MainPageModel : ObservableObject, IProjectTaskPageModel
3535
[ObservableProperty]
3636
private string _today = DateTime.Now.ToString("dddd, MMM d");
3737

38+
[ObservableProperty]
39+
private Project? selectedProject;
40+
3841
public bool HasCompletedTasks
3942
=> Tasks?.Any(t => t.IsCompleted) ?? false;
4043

@@ -149,8 +152,8 @@ private Task AddTask()
149152
=> Shell.Current.GoToAsync($"task");
150153

151154
[RelayCommand]
152-
private Task NavigateToProject(Project project)
153-
=> Shell.Current.GoToAsync($"project?id={project.ID}");
155+
private Task? NavigateToProject(Project project)
156+
=> project is null ? null : Shell.Current.GoToAsync($"project?id={project.ID}");
154157

155158
[RelayCommand]
156159
private Task NavigateToTask(ProjectTask task)

src/Templates/src/templates/maui-mobile/Pages/MainPage.xaml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,37 @@
3838
RefreshCommand="{Binding RefreshCommand}">
3939
<pullToRefresh:SfPullToRefresh.PullableContent>
4040
<ScrollView>
41-
<VerticalStackLayout Spacing="{StaticResource LayoutSpacing}" Padding="{StaticResource LayoutPadding}">
42-
<Label Text="Task Categories" Style="{StaticResource Title2}" SemanticProperties.HeadingLevel="Level1"/>
43-
<controls:CategoryChart />
44-
<Label Text="Projects" Style="{StaticResource Title2}" SemanticProperties.HeadingLevel="Level1"/>
45-
<ScrollView Orientation="Horizontal" Margin="-30,0">
46-
<HorizontalStackLayout
47-
Spacing="15" Padding="30,0"
48-
BindableLayout.ItemsSource="{Binding Projects}">
49-
<BindableLayout.ItemTemplate>
50-
<DataTemplate x:DataType="models:Project">
51-
<controls:ProjectCardView WidthRequest="200">
52-
<controls:ProjectCardView.GestureRecognizers>
53-
<TapGestureRecognizer Command="{Binding NavigateToProjectCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}" CommandParameter="{Binding .}"/>
54-
</controls:ProjectCardView.GestureRecognizers>
55-
</controls:ProjectCardView>
56-
</DataTemplate>
57-
</BindableLayout.ItemTemplate>
58-
</HorizontalStackLayout>
59-
</ScrollView>
60-
<Grid MinimumHeightRequest="44">
41+
<Grid RowSpacing="{StaticResource LayoutSpacing}" Padding="{StaticResource LayoutPadding}">
42+
<Grid.RowDefinitions>
43+
<RowDefinition Height="Auto" />
44+
<RowDefinition Height="Auto" />
45+
<RowDefinition Height="Auto" />
46+
<RowDefinition Height="Auto" />
47+
<RowDefinition Height="Auto" />
48+
<RowDefinition Height="Auto" />
49+
</Grid.RowDefinitions>
50+
51+
<Label Grid.Row="0" Text="Task Categories" Style="{StaticResource Title2}" SemanticProperties.HeadingLevel="Level1"/>
52+
<controls:CategoryChart Grid.Row="1" />
53+
<Label Grid.Row="2" Text="Projects" Style="{StaticResource Title2}" SemanticProperties.HeadingLevel="Level1"/>
54+
<CollectionView Grid.Row="3" ItemsSource="{Binding Projects}"
55+
Margin="-7.5,0"
56+
MinimumHeightRequest="250"
57+
x:Name="ProjectsCollectionView"
58+
SelectionMode="Single"
59+
SelectedItem="{Binding SelectedProject}"
60+
SelectionChangedCommand="{Binding NavigateToProjectCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}"
61+
SelectionChangedCommandParameter="{Binding SelectedProject}">
62+
<CollectionView.ItemsLayout>
63+
<LinearItemsLayout Orientation="Horizontal" ItemSpacing="7.5"/>
64+
</CollectionView.ItemsLayout>
65+
<CollectionView.ItemTemplate>
66+
<DataTemplate x:DataType="models:Project">
67+
<controls:ProjectCardView WidthRequest="200" />
68+
</DataTemplate>
69+
</CollectionView.ItemTemplate>
70+
</CollectionView>
71+
<Grid Grid.Row="4" MinimumHeightRequest="44">
6172
<Label Text="Tasks" Style="{StaticResource Title2}" VerticalOptions="Center" SemanticProperties.HeadingLevel="Level1"/>
6273
<ImageButton
6374
Source="{StaticResource IconClean}"
@@ -70,15 +81,15 @@
7081
Command="{Binding CleanTasksCommand}"
7182
SemanticProperties.Description="Clean tasks" />
7283
</Grid>
73-
<VerticalStackLayout Spacing="15"
84+
<VerticalStackLayout Grid.Row="5" Spacing="15"
7485
BindableLayout.ItemsSource="{Binding Tasks}">
7586
<BindableLayout.ItemTemplate>
7687
<DataTemplate>
7788
<controls:TaskView TaskCompletedCommand="{Binding TaskCompletedCommand, Source={RelativeSource AncestorType={x:Type pageModels:MainPageModel}}, x:DataType=pageModels:MainPageModel}" />
7889
</DataTemplate>
7990
</BindableLayout.ItemTemplate>
8091
</VerticalStackLayout>
81-
</VerticalStackLayout>
92+
</Grid>
8293
</ScrollView>
8394
</pullToRefresh:SfPullToRefresh.PullableContent>
8495
</pullToRefresh:SfPullToRefresh>

0 commit comments

Comments
 (0)