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 view models, updates and adding samples #70

Merged
merged 31 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a0b1be3
added WeekendCalendarPage
MykhailoDav May 30, 2024
51b3c0e
updates
MykhailoDav May 30, 2024
fb647c2
updates
MykhailoDav May 30, 2024
77859c4
updated version and enabled deploy
MykhailoDav Jun 4, 2024
0733da0
installed MauiCommunityToolkit
MykhailoDav Jun 4, 2024
052cfc0
added theme support
MykhailoDav Jun 4, 2024
575eb61
Refactored ViewModels
MykhailoDav Jun 15, 2024
80ffd0b
Merge branch 'added_weekend_calendar' into refactoring_view_models
MykhailoDav Jun 15, 2024
18305d2
refactored weekendCalendar
MykhailoDav Jun 15, 2024
ca564bd
Merge branch 'main' into refactoring_view_models
MykhailoDav Jun 15, 2024
0d19751
instal communityToolkit
MykhailoDav Jun 4, 2024
dc2d0db
Refactored view
MykhailoDav Jun 15, 2024
a07cff9
Added Windows11Calendar
MykhailoDav Jun 15, 2024
12e895d
fix name
MykhailoDav Jun 17, 2024
ccbea26
cleanup
MykhailoDav Jun 18, 2024
d72fc8f
Merge branch 'main' into refactoring_view_models_and_adding_samples
MykhailoDav Jun 19, 2024
76196bc
Merge branch 'main' into refactoring_view_models_and_adding_samples
MykhailoDav Aug 1, 2024
c9a4b99
fix conflicts
MykhailoDav Aug 1, 2024
70a6afb
Merge branch 'main' into refactoring_view_models_and_adding_samples
MykhailoDav Aug 5, 2024
86aa98b
added screenshots
MykhailoDav Aug 5, 2024
c5014f9
added scr
MykhailoDav Aug 5, 2024
aadbd93
Update README.md
MykhailoDav Aug 5, 2024
4020b3f
Merge branch 'update_Readme' into refactoring_view_models_and_adding_…
MykhailoDav Aug 5, 2024
5901209
w11
MykhailoDav Aug 5, 2024
e8bf119
Update README.md
MykhailoDav Aug 5, 2024
78fcf38
Update README.md
MykhailoDav Aug 5, 2024
53a1483
change .
MykhailoDav Aug 5, 2024
b80e8fc
Merge branch 'refactoring_view_models_and_adding_samples' of https://…
MykhailoDav Aug 5, 2024
0f284b6
w11_ios
MykhailoDav Aug 5, 2024
42d6f6c
cleanup
MykhailoDav Aug 5, 2024
98a1cb3
Update README.md
MykhailoDav Aug 5, 2024
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ Simple cross platform plugin for Calendar control featuring:
| ------- | ------ |
| ![Windiws Calendar Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/win.png) | ![Mac Calendar Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/mac.png) |

Theme support
| Ligth | Dark | Setting |
| ------- | ------ | ------ |
| ![Light theme Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/LightTheme.png) | ![Dark theme Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/DarkTheme.png) | ![Setting Page Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/ThemeSettingPage.png) |

# New Samples

Windows 11 calendar
| Win | Mac |
| ------- | ------ |
| ![Windiws 11 android Calendar Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/W11_android.png) | ![Windiws 11 Calendar IOS Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/W11_ios.png) |

Weekend calendar
| Android | IOS |
| ------- | ------ |
| ![Weekend calendar Android Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/WeekendCalendar_android.png) | ![Weekend calendar IOS Screenshot](https://github.com/yurkinh/Plugin.Maui.Calendar/blob/main/res/WeekendCalendar_ios.png) |





Expand All @@ -33,6 +51,10 @@ Simple cross platform plugin for Calendar control featuring:
* Added OnShownDateChangedCommand so we can take action when date is changed.
* Added Dispose method to force handlers disconnect call.
* Added new property **OtherMonthSelectedDayColor**
* Fixed bug with **OtherMonthDayIsVisibleProperty**
* Added a weekend calendar sample
* Added a windows 11 calendar sample
* Added theme support


### Usage
Expand Down
Binary file added res/DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/ThemeSettingPage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/W11Calendar_mac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/W11Calendar_windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/W11_android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/W11_android_d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/W11_ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/WeekendCalendar_android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/WeekendCalendar_ios.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions samples/SampleApp/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SampleApp"
x:Class="SampleApp.App">
<?xml version="1.0" encoding="UTF-8" ?>
<Application
x:Class="SampleApp.App"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SampleApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
15 changes: 10 additions & 5 deletions samples/SampleApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
using SampleApp.Views;
using SampleApp.Model;
using SampleApp.Services;
using SampleApp.Views;

namespace SampleApp;

public partial class App : Application
{
readonly IThemeService themeService;

public static new App Current => (App)Application.Current;
public App()
public App(IThemeService themeService)
{
InitializeComponent();
this.themeService = themeService;
InitializeComponent();

MainPage = new NavigationPage(new MainPage());
}


protected override void OnStart()
{
AppTheme currentTheme = Application.Current.RequestedTheme;
themeService.SetTheme((AppTheme)(Themes.System));
}

protected override void OnResume()
{
AppTheme currentTheme = Application.Current.RequestedTheme;

}

}
Expand Down
13 changes: 6 additions & 7 deletions samples/SampleApp/Controls/CalendarFooter.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
namespace SampleApp.Controls
namespace SampleApp.Controls;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalendarFooter : ContentView
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalendarFooter : ContentView
public CalendarFooter()
{
public CalendarFooter()
{
InitializeComponent();
}
InitializeComponent();
}
}
13 changes: 6 additions & 7 deletions samples/SampleApp/Controls/CalendarHeader.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
namespace SampleApp.Controls
namespace SampleApp.Controls;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalendarHeader : DataTemplate
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalendarHeader : DataTemplate
public CalendarHeader()
{
public CalendarHeader()
{
InitializeComponent();
}
InitializeComponent();
}
}
42 changes: 20 additions & 22 deletions samples/SampleApp/Controls/CalenderEvent.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
using SampleApp.Model;
using System.Windows.Input;
using System.Windows.Input;

namespace SampleApp.Controls
namespace SampleApp.Controls;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalenderEvent : ContentView
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CalenderEvent : ContentView
{
public static BindableProperty CalenderEventCommandProperty =
BindableProperty.Create(nameof(CalenderEventCommand), typeof(ICommand), typeof(CalenderEvent), null);
public static BindableProperty CalenderEventCommandProperty =
BindableProperty.Create(nameof(CalenderEventCommand), typeof(ICommand), typeof(CalenderEvent), null);

public CalenderEvent()
{
InitializeComponent();
}
public CalenderEvent()
{
InitializeComponent();
}

public ICommand CalenderEventCommand
{
get => (ICommand)GetValue(CalenderEventCommandProperty);
set => SetValue(CalenderEventCommandProperty, value);
}
public ICommand CalenderEventCommand
{
get => (ICommand)GetValue(CalenderEventCommandProperty);
set => SetValue(CalenderEventCommandProperty, value);
}

private void TapGestureRecognizer_Tapped(object sender, System.EventArgs e)
{
if (BindingContext is AdvancedEventModel eventModel)
CalenderEventCommand?.Execute(eventModel);
}
private void TapGestureRecognizer_Tapped(object sender, System.EventArgs e)
{
if (BindingContext is AdvancedEventModel eventModel)
CalenderEventCommand?.Execute(eventModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
x:Class="SampleApp.Controls.Windows11CalendarHeader"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:SampleApp.Controls"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Name="Header"
x:DataType="controls:CalendarHeader">
<ContentView.Resources>
<ResourceDictionary>
<Style x:Key="arrowButtonPrevStyle" TargetType="Button">
<Setter Property="FontFamily" Value="FontAwesomeSolid" />
<Setter Property="BorderColor" Value="Transparent" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="Text" Value="&#xf062;" />
<Setter Property="FontSize" Value="15" />
<Setter Property="TextColor" Value="DimGray" />
</Style>

<Style x:Key="arrowButtonNextStyle" TargetType="Button">
<Setter Property="FontFamily" Value="FontAwesomeSolid" />
<Setter Property="Text" Value="&#xf063;" />
<Setter Property="BorderColor" Value="Transparent" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontSize" Value="15" />
<Setter Property="TextColor" Value="DimGray" />
</Style>
<Style x:Key="ArrowFooterButtonUpStyle" TargetType="Button">
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="FontAwesomeSolid" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="FontSize" Value="15" />
<Setter Property="HorizontalOptions" Value="End" />
<Setter Property="Text" Value="&#xf063;" />
<Setter Property="TextColor" Value="DimGray" />
<Setter Property="VerticalOptions" Value="Center" />
</Style>
</ResourceDictionary>
</ContentView.Resources>
<Grid
Padding="12,0,12,0"
ColumnDefinitions="*,Auto,Auto"
HorizontalOptions="Fill"
IsVisible="{Binding BindingContext.ShowMonthPicker, Source={x:Reference Header}}"
RowDefinitions="Auto"
VerticalOptions="Start">
<Label
Grid.Column="0"
FontAttributes="Bold"
FontSize="14"
HorizontalOptions="Start"
Style="{StaticResource HeaderLabelStyle}"
TextColor="{toolkit:AppThemeResource DaysTitleLabelTextColorMinimalistic}"
VerticalOptions="Center">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding BindingContext.LayoutUnitText, Source={x:Reference Header}, Mode=TwoWay}" />
<Span Text=" " />
<Span Text="{Binding BindingContext.Year, Source={x:Reference Header}, Mode=TwoWay}" />
</FormattedString>
</Label.FormattedText>
</Label>
<Button
Grid.Column="1"
Command="{Binding BindingContext.PrevLayoutUnitCommand, Source={x:Reference Header}, Mode=OneWay}"
Style="{StaticResource arrowButtonPrevStyle}" />
<Button
Grid.Column="2"
Command="{Binding BindingContext.NextLayoutUnitCommand, Source={x:Reference Header}, Mode=OneWay}"
Style="{StaticResource arrowButtonNextStyle}" />
</Grid>
</ContentView>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SampleApp.Controls;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Windows11CalendarHeader : ContentView
{
public Windows11CalendarHeader()
{
InitializeComponent();
}
}
4 changes: 4 additions & 0 deletions samples/SampleApp/GlobalNamespaces.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using SampleApp.Model;
global using SampleApp.ViewModels;
10 changes: 10 additions & 0 deletions samples/SampleApp/Helpers/ServiceHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SampleApp.Helpers;
public static class ServiceHelper
{
public static IServiceProvider Services { get; private set; }

public static void Initialize(IServiceProvider serviceProvider) =>
Services = serviceProvider;

public static T GetService<T>() => Services.GetService<T>();
}
40 changes: 32 additions & 8 deletions samples/SampleApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using Microsoft.Extensions.Logging;
using Mopups.Hosting;
using SampleApp.Helpers;
using SampleApp.Services;
using SampleApp.Views;

namespace SampleApp;

Expand All @@ -11,19 +15,39 @@ public static MauiApp CreateMauiApp()
builder
.UseMauiApp<App>()
.ConfigureMopups()
.ConfigureFonts(fonts =>
.UseMauiCommunityToolkit()
.InjectServices()
.InjectViewsAndViewModels()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("font-awesome-5-free-solid.otf", "FontAwesomeSolid");
fonts.AddFont("font-awesome-5-free-regular.otf", "FontAwesomeRegular");
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("font-awesome-6-free-solid.otf", "FontAwesomeSolid");
fonts.AddFont("font-awesome-6-free-regular.otf", "FontAwesomeRegular");
fonts.AddFont("DarkerGrotesque-VariableFont_wght.ttf", "DarkerGrotesque");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
var app = builder.Build();

//we must initialize our service helper before using it
ServiceHelper.Initialize(app.Services);

return app;
}
static MauiAppBuilder InjectViewsAndViewModels(this MauiAppBuilder builder)
{
builder.Services.AddTransient<UserSettingPage>();
builder.Services.AddTransient<UserSettingViewModel>();
return builder;
}
static MauiAppBuilder InjectServices(this MauiAppBuilder builder)
{
builder.Services.AddSingleton<IThemeService, ThemeService>();
return builder;
}
}

13 changes: 6 additions & 7 deletions samples/SampleApp/Model/AdvancedEventModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace SampleApp.Model
namespace SampleApp.Model;

public class AdvancedEventModel
{
public class AdvancedEventModel
{
public string Name { get; set; }
public string Description { get; set; }
public DateTime Starting { get; set; }
}
public string Name { get; set; }
public string Description { get; set; }
public DateTime Starting { get; set; }
}
11 changes: 4 additions & 7 deletions samples/SampleApp/Model/CalendarPickerResult.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
namespace SampleApp.Model;

namespace SampleApp.Model
public class CalendarPickerResult
{
public class CalendarPickerResult
{
public bool IsSuccess { get; set; }
public bool IsSuccess { get; set; }

public DateTime? SelectedDate { get; set; }
}
public DateTime? SelectedDate { get; set; }
}
16 changes: 6 additions & 10 deletions samples/SampleApp/Model/CalendarRangePickerResult.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
namespace SampleApp.Model;

namespace SampleApp.Model
public class CalendarRangePickerResult
{
public class CalendarRangePickerResult
{
public bool IsSuccess { get; set; }
public List<DateTime> SelectedDates { get; set; } = new List<DateTime>();
public DateTime? SelectedStartDate { get; set; }
public DateTime? SelectedEndDate { get; set; }
}
public bool IsSuccess { get; set; }
public List<DateTime> SelectedDates { get; set; } = new List<DateTime>();
public DateTime? SelectedStartDate { get; set; }
public DateTime? SelectedEndDate { get; set; }
}
Loading
Loading