Skip to content

Commit

Permalink
修改了一部分页面的自适应边距
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Sep 9, 2024
1 parent 9bf7ad0 commit b4437b2
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@
<Button Command="{Binding CancelCommand}" Visibility="{Binding CancelButtonVisibility}">
<TextBlock x:Uid="Buttons_Cancel" Text="Cancel" />
</Button>
<Button Style="{ThemeResource AccentButtonStyle}" Visibility="{Binding CanLaunch, Converter={ThemeResource BoolToVisibilityConverter}}">
<Button
Command="{Binding LaunchCommand}"
Style="{ThemeResource AccentButtonStyle}"
Visibility="{Binding CanLaunch, Converter={ThemeResource BoolToVisibilityConverter}}">
<TextBlock x:Uid="Buttons_Launch" Text="Launch" />
</Button>
</StackPanel>
Expand Down
26 changes: 13 additions & 13 deletions Natsurainko.FluentLauncher/Services/UI/AppearanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ public void ApplySettingsBeforePageInit()
{
App.Current.Resources["RawSystemAccentColor"] = App.Current.Resources["SystemAccentColor"];

if (_settingsService.UseNarrowMargin)
{
App.Current.Resources["PageMarginWithBorder"] = new Thickness(20, 0, 20, 20);
App.Current.Resources["PageMarginWithBreadcrumbBar"] = new Thickness(10);
App.Current.Resources["PageMarginWithStackPanel"] = new Thickness(20, 10, 20, 20);
App.Current.Resources["PagePaddingWithScrollViewer"] = new Thickness(20, 0, 20, 0);
App.Current.Resources["PageEndMarginWithScrollViewer"] = new Thickness(0, 0, 0, 20);

App.Current.Resources["PagePaddingWithInstallWizardPageGrid"] = new Thickness(20);
App.Current.Resources["PagePaddingWithInstallWizardPageStackPanel"] = new Thickness(10);
App.Current.Resources["PagePaddingWithInstallWizardPageFrame"] = new Thickness(20, 0, 20, 0);
App.Current.Resources["PageMarginWithInstallWizardPageStackPanel"] = new Thickness(10, 0, 10, 0);
}
//if (_settingsService.UseNarrowMargin)
//{
// App.Current.Resources["PageMarginWithBorder"] = new Thickness(20, 0, 20, 20);
// App.Current.Resources["PageMarginWithBreadcrumbBar"] = new Thickness(10);
// App.Current.Resources["PageMarginWithStackPanel"] = new Thickness(20, 10, 20, 20);
// App.Current.Resources["PagePaddingWithScrollViewer"] = new Thickness(20, 0, 20, 0);
// App.Current.Resources["PageEndMarginWithScrollViewer"] = new Thickness(0, 0, 0, 20);

// App.Current.Resources["PagePaddingWithInstallWizardPageGrid"] = new Thickness(20);
// App.Current.Resources["PagePaddingWithInstallWizardPageStackPanel"] = new Thickness(10);
// App.Current.Resources["PagePaddingWithInstallWizardPageFrame"] = new Thickness(20, 0, 20, 0);
// App.Current.Resources["PageMarginWithInstallWizardPageStackPanel"] = new Thickness(10, 0, 10, 0);
//}

if (!_settingsService.UseSystemAccentColor)
{
Expand Down
6 changes: 6 additions & 0 deletions Natsurainko.FluentLauncher/ViewModels/Common/TaskViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ internal partial class InstallInstanceTaskViewModel : TaskViewModel
{
private readonly IInstanceInstaller _installer;
private readonly InstanceInstallConfig _instanceInstallConfig;
private MinecraftInstance _minecraftInstance;

public IEnumerable<InstallationStageViewModel> StageViewModels { get; }

Expand All @@ -343,6 +344,7 @@ public InstallInstanceTaskViewModel(
}

[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(LaunchCommand))]
private bool canLaunch = false;

public override string TaskIcon => TaskState switch
Expand Down Expand Up @@ -396,6 +398,7 @@ protected override async void Run()
TaskState = resultState;
CanLaunch = resultState == TaskState.Finished;
_minecraftInstance = instance;
});

if (resultState == TaskState.Finished && instance != null)
Expand Down Expand Up @@ -450,6 +453,9 @@ void NotifyException()
{

}

[RelayCommand(CanExecute = nameof(CanLaunch))]
void Launch() => App.GetService<LaunchService>().LaunchFromUI(_minecraftInstance);
}

#endregion
Expand Down
25 changes: 24 additions & 1 deletion Natsurainko.FluentLauncher/Views/News/DefaultPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</Page.Resources>

<ScrollViewer>
<Border Margin="{ThemeResource PageMarginWithBorder}">
<Border x:Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -274,5 +274,28 @@
</GridView>
</StackPanel>
</Border>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="border.Margin" Value="20, 0, 20, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ScrollViewer>
</Page>
24 changes: 24 additions & 0 deletions Natsurainko.FluentLauncher/Views/News/NavigationPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</Grid.RowDefinitions>

<BreadcrumbBar
x:Name="breadcrumbBar"
Grid.Row="0"
MaxWidth="1020"
Margin="{ThemeResource PageMarginWithBreadcrumbBar}"
Expand Down Expand Up @@ -58,5 +59,28 @@
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="breadcrumbBar.Margin" Value="10" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>
26 changes: 26 additions & 0 deletions Natsurainko.FluentLauncher/Views/News/NotePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBlock
Name="TextBlock_Title"
Margin="40,15,40,25"
HorizontalAlignment="Center"
FontFamily="{ThemeResource MinecraftTen}"
Style="{ThemeResource TitleLargeTextBlockStyle}"
Text="{Binding PatchNoteData.Title}"
TextWrapping="WrapWholeWords" />
<WebView2
Name="webView2"
Grid.Row="1"
MaxWidth="1000"
Margin="30,0"
Expand All @@ -32,5 +34,29 @@
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
</WebView2>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="TextBlock_Title.Margin" Value="20,15,20,20" />
<Setter Target="webView2.Margin" Value="10,0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>
25 changes: 24 additions & 1 deletion Natsurainko.FluentLauncher/Views/Settings/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mc:Ignorable="d">

<ScrollViewer>
<Border Margin="{ThemeResource PageMarginWithBorder}">
<Border x:Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -105,5 +105,28 @@
</controls:SettingsExpander>
</StackPanel>
</Border>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="border.Margin" Value="20, 0, 20, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ScrollViewer>
</Page>
26 changes: 24 additions & 2 deletions Natsurainko.FluentLauncher/Views/Settings/AccountPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
mc:Ignorable="d">

<ScrollViewer>
<Border Margin="{ThemeResource PageMarginWithBorder}">
<Border x:Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -226,6 +226,28 @@
</controls:SettingsCard>
</StackPanel>
</Border>
</ScrollViewer>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="border.Margin" Value="20, 0, 20, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ScrollViewer>
</Page>
35 changes: 24 additions & 11 deletions Natsurainko.FluentLauncher/Views/Settings/AppearancePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
</Page.Resources>

<ScrollViewer>
<Border Margin="{ThemeResource PageMarginWithBorder}">
<Border x:Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -721,17 +721,30 @@
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>

<TextBlock Style="{ThemeResource SettingsSectionHeaderTextBlockStyle}" Text="Details" />

<controls:SettingsCard
Description="Reduce margins to increase content fill ratio"
Header="Narrow Margin Mode"
HeaderIcon="{xh:FontIcon Glyph=&#xf573;}">
<ToggleSwitch IsOn="{Binding UseNarrowMargin, Mode=TwoWay}" />
</controls:SettingsCard>

</StackPanel>
</Border>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="border.Margin" Value="20, 0, 20, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ScrollViewer>
</Page>
25 changes: 24 additions & 1 deletion Natsurainko.FluentLauncher/Views/Settings/DefaultPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
mc:Ignorable="d">

<ScrollViewer>
<Border Margin="{ThemeResource PageMarginWithBorder}">
<Border x:Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -98,5 +98,28 @@
</controls:SettingsCard>
</StackPanel>
</Border>

<!-- Visual states reflect the application's window size -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger>
<AdaptiveTrigger.MinWindowWidth>
<x:Double>641</x:Double>
</AdaptiveTrigger.MinWindowWidth>
</AdaptiveTrigger>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="border.Margin" Value="20, 0, 20, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ScrollViewer>
</Page>
Loading

0 comments on commit b4437b2

Please sign in to comment.