зеркало из https://github.com/dotnet/maui-samples.git
Visibility of nav bar, title, and flyout icon states (#211)
This commit is contained in:
Родитель
4263143b95
Коммит
6dc3f864d8
|
@ -9,6 +9,7 @@
|
|||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
*.idea
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "comet",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "comet: Run"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -12,13 +12,6 @@
|
|||
FlyoutWidth="68" FlyoutBackgroundColor="{StaticResource Background_Mid}"
|
||||
FlyoutBehavior="{OnIdiom Phone=Disabled, Default=Locked}">
|
||||
|
||||
<!--<Shell.FlyoutHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<BoxView HeightRequest="68"/>
|
||||
</DataTemplate>
|
||||
|
||||
</Shell.FlyoutHeaderTemplate>-->
|
||||
|
||||
<Shell.FlyoutFooterTemplate>
|
||||
<DataTemplate>
|
||||
<Grid RowDefinitions="68">
|
||||
|
@ -40,13 +33,13 @@
|
|||
|
||||
|
||||
<!-- Desktop/Tablet-->
|
||||
<FlyoutItem Title="Home" FlyoutIcon="tab_home.png">
|
||||
<FlyoutItem Title="Home" Style="{StaticResource HomeFlyout}">
|
||||
<ShellContent ContentTemplate="{DataTemplate page:HomePage}"/>
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Favorites" FlyoutIcon="tab_favorites.png">
|
||||
<FlyoutItem Title="Favorites" Style="{StaticResource FavFlyout}">
|
||||
<ShellContent ContentTemplate="{DataTemplate page:FavoritesPage}"/>
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Map" FlyoutIcon="tab_map.png">
|
||||
<FlyoutItem Title="Map" Style="{StaticResource MapFlyout}">
|
||||
<ShellContent ContentTemplate="{DataTemplate page:MapPage}"/>
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Settings" Route="settings" FlyoutItemIsVisible="False">
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace WeatherTwentyOne.Converters;
|
||||
|
||||
public class ImageByStateConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var target = (FlyoutItem)value;
|
||||
var allParams = ((string)parameter).Split((';')); // 0=normal, 1=selected
|
||||
|
||||
if (target.IsChecked && allParams.Length > 1)
|
||||
return allParams[1];
|
||||
else
|
||||
return allParams[0];
|
||||
}
|
||||
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (string)value;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
|
||||
ios:Page.UseSafeArea="True"
|
||||
Title="Favorites"
|
||||
Shell.NavBarIsVisible="{OnIdiom True, Desktop=False}"
|
||||
x:Class="WeatherTwentyOne.Pages.FavoritesPage"
|
||||
>
|
||||
<ContentPage.Resources>
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
xmlns:v="clr-namespace:WeatherTwentyOne.Views"
|
||||
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
|
||||
ios:Page.UseSafeArea="True"
|
||||
Title="St. Louis, Missouri USA"
|
||||
x:Class="WeatherTwentyOne.Pages.HomePage">
|
||||
Title="{OnIdiom 'St. Louis, Missouri USA', Desktop=''}"
|
||||
Shell.NavBarIsVisible="{OnPlatform True, MacCatalyst=False}"
|
||||
x:Class="WeatherTwentyOne.Pages.HomePage"
|
||||
x:Name="this">
|
||||
|
||||
<ContentPage.MenuBarItems>
|
||||
<MenuBarItem Text="File">
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:m="clr-namespace:WeatherTwentyOne.Models"
|
||||
xmlns:v="clr-namespace:WeatherTwentyOne.Views"
|
||||
Title="Wind Map"
|
||||
Shell.NavBarIsVisible="{OnIdiom True, Desktop=False}"
|
||||
x:Class="WeatherTwentyOne.Pages.MapPage">
|
||||
|
||||
<Grid
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
|
||||
ios:Page.UseSafeArea="True"
|
||||
Title="Settings"
|
||||
Shell.NavBarIsVisible="{OnIdiom True, Desktop=False}"
|
||||
x:Class="WeatherTwentyOne.Pages.SettingsPage">
|
||||
|
||||
<ContentPage.Resources>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:app="clr-namespace:WeatherTwentyOne.Resources.Styles"
|
||||
x:Class="WeatherTwentyOne.Resources.Styles.DefaultTheme"
|
||||
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls">
|
||||
xmlns:android="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;assembly=Microsoft.Maui.Controls"
|
||||
xmlns:converter="clr-namespace:WeatherTwentyOne.Converters">
|
||||
|
||||
<Color x:Key="Primary">#512BD4</Color>
|
||||
<Color x:Key="Secondary">#DFD8F7</Color>
|
||||
|
@ -363,4 +364,48 @@
|
|||
</Grid>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
|
||||
<converter:ImageByStateConverter x:Key="ImageByStateConverter"/>
|
||||
|
||||
<Style TargetType="FlyoutItem" x:Key="HomeFlyout">
|
||||
<Style.Triggers>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="False">
|
||||
<Setter Property="FlyoutIcon" Value="tab_home.png"/>
|
||||
</Trigger>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="True">
|
||||
<Setter Property="FlyoutIcon" Value="tab_home_on.png"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="FlyoutItem" x:Key="FavFlyout">
|
||||
<Style.Triggers>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="False">
|
||||
<Setter Property="FlyoutIcon" Value="tab_favorites.png"/>
|
||||
</Trigger>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="True">
|
||||
<Setter Property="FlyoutIcon" Value="tab_favorites_on.png"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="FlyoutItem" x:Key="MapFlyout">
|
||||
<Style.Triggers>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="False">
|
||||
<Setter Property="FlyoutIcon" Value="tab_map.png"/>
|
||||
</Trigger>
|
||||
<Trigger TargetType="FlyoutItem"
|
||||
Property="IsChecked" Value="True">
|
||||
<Setter Property="FlyoutIcon" Value="tab_map_on.png"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
|
||||
|
||||
</ResourceDictionary>
|
Загрузка…
Ссылка в новой задаче