Skip to content

Commit e5f8553

Browse files
committed
add panedisplaymode option
1 parent 7341f45 commit e5f8553

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed

dev/AlAnvar.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<ItemGroup>
2222
<PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.0.230907" />
23+
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.0.230907" />
2324
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
2425
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
2526
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />

dev/Helpers/AlAnvarSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ public class AlAnvarSettings : JsonSettings, IVersionable
2323
public virtual string LastUpdateCheck { get; set; } = "هرگز";
2424
public virtual bool IsAutoDownloadSound { get; set; } = true;
2525
public virtual string AudiosPath { get; set; } = Constants.AudiosPath;
26+
public virtual NavigationViewPaneDisplayMode PaneDisplayMode { get; set; } = NavigationViewPaneDisplayMode.Top;
2627
}

dev/ViewModels/Settings/GeneralSettingViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
public partial class GeneralSettingViewModel : ObservableRecipient
44
{
5+
[RelayCommand]
6+
private void OnPaneDisplayModeChanged()
7+
{
8+
MainPage.Instance.RefreshPaneDisplayMode();
9+
}
510
}

dev/Views/MainPage.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:settings="using:AlAnvar.Helpers"
78
xmlns:wuc="using:WinUICommunity"
89
mc:Ignorable="d">
910
<Grid>
@@ -46,9 +47,11 @@
4647
</wuc:TitleBar>
4748
<NavigationView x:Name="NavView"
4849
Grid.Row="1"
50+
DisplayModeChanged="NavView_DisplayModeChanged"
4951
FlowDirection="RightToLeft"
5052
IsBackButtonVisible="Collapsed"
51-
IsPaneToggleButtonVisible="False">
53+
IsPaneToggleButtonVisible="False"
54+
PaneDisplayMode="{x:Bind settings:AlAnvarHelper.Settings.PaneDisplayMode, Mode=OneWay}">
5255

5356
<Frame x:Name="NavFrame"
5457
Navigated="NavFrame_Navigated" />

dev/Views/MainPage.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ private void MainPage_Loaded(object sender, RoutedEventArgs e)
3333
settings.Content = "تنظیمات";
3434
}
3535

36+
public void RefreshPaneDisplayMode()
37+
{
38+
NavView.PaneDisplayMode = Settings.PaneDisplayMode;
39+
}
40+
3641
private void Search(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs textChangedEventArgs, AutoSuggestBoxQuerySubmittedEventArgs querySubmittedEventArgs)
3742
{
3843
var rootFrame = ViewModel.JsonNavigationViewService.Frame;
@@ -60,6 +65,7 @@ private void Search(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs te
6065
}
6166
}
6267
}
68+
6369
private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
6470
{
6571
var viewModel = NavFrame.GetPageViewModel();
@@ -113,4 +119,16 @@ private void ThemeButton_Click(object sender, RoutedEventArgs e)
113119
element.RequestedTheme = ElementTheme.Light;
114120
}
115121
}
122+
123+
private void NavView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
124+
{
125+
if (NavView.PaneDisplayMode == NavigationViewPaneDisplayMode.Top)
126+
{
127+
appTitleBar.IsPaneButtonVisible = false;
128+
}
129+
else
130+
{
131+
appTitleBar.IsPaneButtonVisible = true;
132+
}
133+
}
116134
}

dev/Views/Settings/GeneralSettingPage.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:i="using:Microsoft.Xaml.Interactivity"
7+
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
68
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
79
xmlns:settings="using:AlAnvar.Helpers"
810
xmlns:views="using:AlAnvar.Views"
@@ -22,6 +24,22 @@
2224
OffContent="غیر فعال"
2325
OnContent="فعال" />
2426
</wuc:SettingsCard>
27+
<wuc:SettingsCard Description="حالت نمایش منوی اصلی برنامه را مشخص کنید"
28+
Header="حالت نمایش منو"
29+
HeaderIcon="{wuc:BitmapIcon Source=Assets/Fluent/download.png}">
30+
<ComboBox xmlns:enums="using:Microsoft.UI.Xaml.Controls"
31+
xmlns:ui="using:CommunityToolkit.WinUI"
32+
ItemsSource="{ui:EnumValues Type=enums:NavigationViewPaneDisplayMode}"
33+
SelectedItem="{x:Bind settings:AlAnvarHelper.Settings.PaneDisplayMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
34+
<i:Interaction.Behaviors>
35+
<ic:EventTriggerBehavior EventName="SelectionChanged">
36+
<ic:EventTriggerBehavior.Actions>
37+
<ic:InvokeCommandAction Command="{x:Bind ViewModel.PaneDisplayModeChangedCommand}" />
38+
</ic:EventTriggerBehavior.Actions>
39+
</ic:EventTriggerBehavior>
40+
</i:Interaction.Behaviors>
41+
</ComboBox>
42+
</wuc:SettingsCard>
2543
</StackPanel>
2644
</ScrollView>
2745
</Page>

0 commit comments

Comments
 (0)