Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring pages; update readme; fixed Dark/Light theme; added compile bindings; #92

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Basic control usage:
Month="5"
Year="2019"
VerticalOptions="Fill"
HorizontalOptions="Fill">
HorizontalOptions="Fill"/>
```

Bindable properties:
Expand All @@ -91,7 +91,7 @@ __Remark: You can use `ShownDate` as an alternative to `Year`, `Month` and `Day`
<controls:Calendar
ShownDate="2019-05-14"
VerticalOptions="Fill"
HorizontalOptions="Fill">
HorizontalOptions="Fill"/>
```

#### Binding events:
Expand Down Expand Up @@ -129,51 +129,51 @@ public EventCollection Events { get; set; }

Initialize Events with your data:
```csharp
Events = new EventCollection
{
Events = new EventCollection
{
[DateTime.Now] = new List<EventModel>
{
new EventModel { Name = "Cool event1", Description = "This is Cool event1's description!" },
new EventModel { Name = "Cool event2", Description = "This is Cool event2's description!" }
new() { Name = "Cool event1", Description = "This is Cool event1's description!" },
new() { Name = "Cool event2", Description = "This is Cool event2's description!" }
},
// 5 days from today
[DateTime.Now.AddDays(5)] = new List<EventModel>
{
new EventModel { Name = "Cool event3", Description = "This is Cool event3's description!" },
new EventModel { Name = "Cool event4", Description = "This is Cool event4's description!" }
new() { Name = "Cool event3", Description = "This is Cool event3's description!" },
new() { Name = "Cool event4", Description = "This is Cool event4's description!" }
},
// 3 days ago
[DateTime.Now.AddDays(-3)] = new List<EventModel>
{
new EventModel { Name = "Cool event5", Description = "This is Cool event5's description!" }
new() { Name = "Cool event5", Description = "This is Cool event5's description!" }
},
// custom date
[new DateTime(2020, 3, 16))] = new List<EventModel>
[new DateTime(2024, 3, 16)] = new List<EventModel>
{
new EventModel { Name = "Cool event6", Description = "This is Cool event6's description!" }
new() { Name = "Cool event6", Description = "This is Cool event6's description!" }
}
};
};
```

Initialize Events with your data and a different dot color per day:
```csharp
Events = new EventCollection
{
//2 days ago
[DateTime.Now.AddDays(-2)] = new DayEventCollection<EventModel>( Color.Purple, Color.Purple)
[DateTime.Now.AddDays(-2)] = new DayEventCollection<EventModel>(Colors.Purple, Colors.Purple)
{
new EventModel { Name = "Cool event1", Description = "This is Cool event1's description!" },
new EventModel { Name = "Cool event2", Description = "This is Cool event2's description!" }
new() { Name = "Cool event1", Description = "This is Cool event1's description!" },
new() { Name = "Cool event2", Description = "This is Cool event2's description!" }
},
// 5 days ago
[DateTime.Now.AddDays(-5)] = new DayEventCollection<EventModel>(Color.Blue, Color.Blue)
[DateTime.Now.AddDays(-5)] = new DayEventCollection<EventModel>(Colors.Blue, Colors.Blue)
{
new EventModel { Name = "Cool event3", Description = "This is Cool event3's description!" },
new EventModel { Name = "Cool event4", Description = "This is Cool event4's description!" }
new() { Name = "Cool event3", Description = "This is Cool event3's description!" },
new() { Name = "Cool event4", Description = "This is Cool event4's description!" }
},
};
//4 days ago
Events.Add(DateTime.Now.AddDays(-4), new DayEventCollection<EventModel>(GenerateEvents(10, "Cool")) { EventIndicatorColor = Color.Green, EventIndicatorSelectedColor = Color.Green });
Events.Add(DateTime.Now.AddDays(-4), new DayEventCollection<EventModel>(GenerateEvents(10, "Cool")) { EventIndicatorColor = Colors.Green, EventIndicatorSelectedColor = Colors.Green });
```

Where `EventModel` is just an example, it can be replaced by any data model you desire.
Expand All @@ -192,7 +192,7 @@ public CultureInfo Culture => new CultureInfo("hr-HR")
In XAML add Culture binding
```xml
<controls:Calendar
Culture="{Binding Culture}">
Culture="{Binding Culture}"/>
</controls:Calendar>
```

Expand Down
2 changes: 1 addition & 1 deletion samples/SampleApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public App(IThemeService themeService)

protected override void OnStart()
{
themeService.SetTheme((AppTheme)(Themes.System));
themeService.SetTheme(AppTheme.Unspecified);
}

protected override void OnResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
FontAttributes="Bold"
FontSize="14"
HorizontalOptions="Start"
Style="{StaticResource HeaderLabelStyle}"
TextColor="{toolkit:AppThemeResource DaysTitleLabelTextColorMinimalistic}"
VerticalOptions="Center">
<Label.FormattedText>
Expand Down
97 changes: 97 additions & 0 deletions samples/SampleApp/Controls/ThemeButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
x:Class="SampleApp.Controls.ThemeButton"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Name="This">
<ContentView.Resources>
<ControlTemplate x:Key="RadioButtonTemplate">
<Grid Margin="4" WidthRequest="100">
<ContentPresenter />
</Grid>
</ControlTemplate>

<Style TargetType="RadioButton">
<Setter Property="ControlTemplate" Value="{StaticResource RadioButtonTemplate}" />
</Style>

<toolkit:AppThemeColor
x:Key="CheeckedColor"
Dark="#B3FCF8"
Light="#B3FCF8" />
<toolkit:AppThemeColor
x:Key="UncheckedColor"
Dark="#2F3E46"
Light="#2F3E46" />
</ContentView.Resources>

<RadioButton GroupName="{Binding GroupName, Source={x:Reference This}}" IsChecked="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}">
<RadioButton.Content>
<Border
HeightRequest="100"
StrokeShape="RoundRectangle 10"
StrokeThickness="1">
<VerticalStackLayout HorizontalOptions="Center">
<Label
Margin="0,10"
FontFamily="FontAwesomeSolid"
FontSize="30"
HorizontalOptions="Center"
Text="{Binding Icon, Source={x:Reference This}}">
<Label.Triggers>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Label"
Value="True">
<Setter Property="TextColor" Value="{toolkit:AppThemeResource UncheckedColor}" />
</DataTrigger>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Label"
Value="False">
<Setter Property="TextColor" Value="{toolkit:AppThemeResource CheeckedColor}" />
</DataTrigger>
</Label.Triggers>
</Label>
<Label
FontSize="20"
HorizontalOptions="Center"
Text="{Binding Title, Source={x:Reference This}}"
TextColor="{toolkit:AppThemeResource TextColor}">
<Label.Triggers>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Label"
Value="True">
<Setter Property="TextColor" Value="{toolkit:AppThemeResource UncheckedColor}" />
</DataTrigger>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Label"
Value="False">
<Setter Property="TextColor" Value="{toolkit:AppThemeResource CheeckedColor}" />
</DataTrigger>
</Label.Triggers>
</Label>
</VerticalStackLayout>
<Border.Triggers>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Border"
Value="True">
<Setter Property="Stroke" Value="{toolkit:AppThemeResource CheeckedColor}" />
<Setter Property="BackgroundColor" Value="{toolkit:AppThemeResource CheeckedColor}" />
</DataTrigger>
<DataTrigger
Binding="{Binding IsChecked, Source={x:Reference This}, Mode=TwoWay}"
TargetType="Border"
Value="False">
<Setter Property="Stroke" Value="{toolkit:AppThemeResource CheeckedColor}" />
<Setter Property="BackgroundColor" Value="{toolkit:AppThemeResource UncheckedColor}" />
</DataTrigger>
</Border.Triggers>
</Border>
</RadioButton.Content>
</RadioButton>
</ContentView>
41 changes: 41 additions & 0 deletions samples/SampleApp/Controls/ThemeButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace SampleApp.Controls;

public partial class ThemeButton : ContentView
{
public ThemeButton()
{
InitializeComponent();
}

public static readonly BindableProperty IsCheckedProperty =
BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(ThemeButton), false, BindingMode.TwoWay);
public bool IsChecked
{
get => (bool)GetValue(IsCheckedProperty);
set => SetValue(IsCheckedProperty, value);
}

public static readonly BindableProperty GroupNameProperty =
BindableProperty.Create(nameof(GroupName), typeof(string), typeof(ThemeButton), string.Empty);
public string GroupName
{
get => (string)GetValue(GroupNameProperty);
set => SetValue(GroupNameProperty, value);
}

public static readonly BindableProperty TitleProperty =
BindableProperty.Create(nameof(Title), typeof(string), typeof(ThemeButton), string.Empty);
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}

public static readonly BindableProperty IconProperty =
BindableProperty.Create(nameof(Icon), typeof(string), typeof(ThemeButton), string.Empty);
public string Icon
{
get => (string)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}
}
7 changes: 0 additions & 7 deletions samples/SampleApp/Model/Themes.cs

This file was deleted.

42 changes: 38 additions & 4 deletions samples/SampleApp/Resources/AppIcon/appicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 38 additions & 7 deletions samples/SampleApp/Resources/AppIcon/appiconfg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions samples/SampleApp/Resources/Styles/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,24 @@
x:Key="BackgroundColor"
Dark="#212121"
Light="White" />
<toolkit:AppThemeColor
x:Key="BackgroundPageColor"
Dark="#2F3E46"
Light="#edf2f4" />
<toolkit:AppThemeColor
x:Key="ButtonColor"
Dark="#CAD2C5"
Light="#a4ac86" />
<toolkit:AppThemeColor
x:Key="PopupBackgroundColor"
Dark="#212121"
Light="#edf2f4" />
<toolkit:AppThemeColor
x:Key="BackgroundColorfullPageColor"
Dark="#2F3E46"
Light="#c2c5aa" />
<toolkit:AppThemeColor
x:Key="TextColor"
Dark="#B3FCF8"
Light="#2F3E46" />
</ResourceDictionary>
Loading
Loading