Change app to a basic ToDo manager

This commit is contained in:
Manuel Thalmann 2024-06-06 23:28:49 +02:00
parent 4bfc83715f
commit 37f27fa415
2 changed files with 38 additions and 40 deletions

View file

@ -5,33 +5,43 @@
x:Class="TodoDetails.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Image
Source="dotnet_bot.png"
HeightRequest="185"
Aspect="AspectFit"
SemanticProperties.Description="dot net bot in a race car number eight" />
<Label
Text="Hello, World!"
Style="{StaticResource Headline}"
SemanticProperties.HeadingLevel="Level1" />
<Label
Text="Welcome to &#10;.NET Multi-platform App UI"
Style="{StaticResource SubHeadline}"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout>
<CollectionView>
<CollectionView.ItemsSource>
<x:Array Type="{x:Type model:Todo}">
<model:Todo Title="Create ViewModel"
Description="Create a ViewModel in the next step to learn MVVM."
Category="Default"
IsDone="False"/>
<model:Todo Title="Add Theming"
Description="Integrate your own theme in the app."
Category="Default"
IsDone="False"/>
<model:Todo Title="Add local database"
Description="Learn how to add a local database to work with (optional)."
Category="Default"
IsDone="False"/>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Todo">
<HorizontalStackLayout Padding="10"
Spacing="10"
HorizontalOptions="FillAndExpand">
<CheckBox IsChecked="{Binding IsDone}"
VerticalOptions="Start"/>
<VerticalStackLayout VerticalOptions="Center">
<Label Text="{Binding Title}"
VerticalOptions="Center"
FontSize="16"
TextColor="Gray"/>
<Label Text="{Binding Category}"
FontSize="12"
TextColor="Gray"/>
</VerticalStackLayout>
</HorizontalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
</ContentPage>

View file

@ -1,4 +1,4 @@
namespace TodoDetails
namespace TodoDetails
{
public partial class MainPage : ContentPage
{
@ -8,18 +8,6 @@
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
}