Refactor Menu
This commit is contained in:
@@ -30,16 +30,19 @@ 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();
|
||||
}
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
page.Title = item.Title;
|
||||
await Detail.Navigation.PushAsync(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Page> 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)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<ItemGroup>
|
||||
<None Remove="Resources\Images\Banner.png" />
|
||||
<None Remove="Resources\Images\Help.png" />
|
||||
<None Remove="Resources\Images\Home.png" />
|
||||
<None Remove="Resources\Images\Info.png" />
|
||||
<None Remove="Resources\Images\Logo_Gray.png" />
|
||||
<None Remove="Resources\Images\Settings.png" />
|
||||
@@ -22,6 +23,7 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Images\Banner.png" />
|
||||
<EmbeddedResource Include="Resources\Images\Help.png" />
|
||||
<EmbeddedResource Include="Resources\Images\Home.png" />
|
||||
<EmbeddedResource Include="Resources\Images\Info.png" />
|
||||
<EmbeddedResource Include="Resources\Images\Logo_Gray.png" />
|
||||
<EmbeddedResource Include="Resources\Images\Settings.png" />
|
||||
|
||||
BIN
PlantBox.Client/PlantBox.Client/Resources/Images/Home.png
Normal file
BIN
PlantBox.Client/PlantBox.Client/Resources/Images/Home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 B |
Reference in New Issue
Block a user