diff --git a/PlantBox.Client/PlantBox.Client/Forms/MainPage.xaml.cs b/PlantBox.Client/PlantBox.Client/Forms/MainPage.xaml.cs index 7215bbf..b5c6d76 100644 --- a/PlantBox.Client/PlantBox.Client/Forms/MainPage.xaml.cs +++ b/PlantBox.Client/PlantBox.Client/Forms/MainPage.xaml.cs @@ -30,15 +30,18 @@ namespace PlantBox.Client.Forms if (e.Item is MenuPageItem item) { IsPresented = false; - var page = item.PageCreator(); - page.Title = item.Title; + var page = item.Page; - if (Detail.Navigation.NavigationStack.Count > 1) + if (Detail.Navigation.NavigationStack.Count > 1 || page == null) { await Detail.Navigation.PopToRootAsync(); } - await Detail.Navigation.PushAsync(page); + if (page != null) + { + page.Title = item.Title; + await Detail.Navigation.PushAsync(page); + } } } } diff --git a/PlantBox.Client/PlantBox.Client/Forms/MenuPage.xaml.cs b/PlantBox.Client/PlantBox.Client/Forms/MenuPage.xaml.cs index f8a4f26..0a24218 100644 --- a/PlantBox.Client/PlantBox.Client/Forms/MenuPage.xaml.cs +++ b/PlantBox.Client/PlantBox.Client/Forms/MenuPage.xaml.cs @@ -22,8 +22,9 @@ namespace PlantBox.Client.Forms items.ItemsSource = new MenuPageItem[] { - new MenuPageItem(Locale.Settings, ImageResourceExtension.GetImage("Settings.png"), typeof(SettingsPage)), - new MenuPageItem(Locale.About, ImageResourceExtension.GetImage("Info.png"), typeof(AboutPage)) + new MenuPageItem(Locale.HomePageTitle, ImageResourceExtension.GetImage("Home.png"), null), + new MenuPageItem(Locale.Settings, ImageResourceExtension.GetImage("Settings.png"), new SettingsPage()), + new MenuPageItem(Locale.About, ImageResourceExtension.GetImage("Info.png"), new AboutPage()) }; } } diff --git a/PlantBox.Client/PlantBox.Client/Models/MenuPageItem.cs b/PlantBox.Client/PlantBox.Client/Models/MenuPageItem.cs index 1a91204..6c1065f 100644 --- a/PlantBox.Client/PlantBox.Client/Models/MenuPageItem.cs +++ b/PlantBox.Client/PlantBox.Client/Models/MenuPageItem.cs @@ -11,41 +11,15 @@ namespace PlantBox.Client.Models { public event PropertyChangedEventHandler PropertyChanged; - private ImageSource _image; - public ImageSource Image - { - get => _image; - set - { - if (value != _image) - { - _image = value; - OnPropertyChanged(nameof(Image)); - } - } - } + public ImageSource Image { get; } + public string Title { get; } + public Page Page { get; } - private string _title; - public string Title + public MenuPageItem(string title, ImageSource image, Page targetPage) { - get => _title; - set - { - if (value != _title) - { - _title = value; - OnPropertyChanged(nameof(Title)); - } - } - } - - public Func PageCreator { get; } - - public MenuPageItem(string title, ImageSource image, Type targetPage) - { - _image = image; - _title = title; - PageCreator = () => (Page)Activator.CreateInstance(targetPage); + Image = image; + Title = title; + Page = targetPage; } public void OnPropertyChanged([CallerMemberName] string propertyName = null) diff --git a/PlantBox.Client/PlantBox.Client/PlantBox.Client.csproj b/PlantBox.Client/PlantBox.Client/PlantBox.Client.csproj index bceb626..f639f32 100644 --- a/PlantBox.Client/PlantBox.Client/PlantBox.Client.csproj +++ b/PlantBox.Client/PlantBox.Client/PlantBox.Client.csproj @@ -14,6 +14,7 @@ + @@ -22,6 +23,7 @@ + diff --git a/PlantBox.Client/PlantBox.Client/Resources/Images/Home.png b/PlantBox.Client/PlantBox.Client/Resources/Images/Home.png new file mode 100644 index 0000000..134aafd Binary files /dev/null and b/PlantBox.Client/PlantBox.Client/Resources/Images/Home.png differ