Skip to content

Commit

Permalink
修复部分错误 完善边距自适应
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Sep 12, 2024
1 parent 1d6cdf3 commit e81d058
Show file tree
Hide file tree
Showing 20 changed files with 390 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Natsurainko.FluentLauncher/Experimental/Saves/SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public SaveManager(string savesFolder)

public async IAsyncEnumerable<SaveInfo> EnumerateSavesAsync()
{
if (!Directory.Exists(SavesFolder))
yield break;

foreach (var dir in Directory.EnumerateDirectories(SavesFolder))
{
var levelDataFile = new FileInfo(Path.Combine(dir, "level.dat"));
Expand Down
3 changes: 1 addition & 2 deletions Natsurainko.FluentLauncher/Natsurainko.FluentLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<ItemGroup>
<!-- NuGet Packages -->
<PackageReference Include="ColorCode.WinUI" Version="2.0.15" />
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.240823-build.1737" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.Animations" Version="8.1.240821" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.1.240821" />
Expand All @@ -70,7 +69,7 @@
<PackageReference Include="HelixToolkit.WinUI" Version="2.25.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240802000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="NbtToolkit" Version="0.1.2-beta" />
Expand Down
14 changes: 0 additions & 14 deletions Natsurainko.FluentLauncher/Services/UI/AppearanceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@ 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.UseSystemAccentColor)
{
App.Current.Resources["SystemAccentColorLight1"] = _settingsService.CustomThemeColor.GetValueOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public void ItemClickedEvent(object args)
[RelayCommand]
public void BreadcrumbBarLoadingEvent(object args)
{
var breadcrumbBar = args.As<BreadcrumbBar, object>().sender;
var converter = breadcrumbBar.Resources["BreadcrumbBarLocalizationConverter"] as BreadcrumbBarLocalizationConverter;

var converter = args as BreadcrumbBarLocalizationConverter;
converter.IgnoredText.Add(InstanceId);
}
}
24 changes: 12 additions & 12 deletions Natsurainko.FluentLauncher/ViewModels/Downloads/DetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ public async Task MarkdownTextBlockLoadedEvent(object args)
}
}

if (sender is CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownTextBlock markdownTextBlock)
{
if (_resource is ModrinthResource modrinthResource)
{
var markdown = await _modrinthClient.GetResourceDescriptionAsync(modrinthResource.Id);
App.DispatcherQueue.TryEnqueue(() =>
{
markdownTextBlock.Config = new CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig();
markdownTextBlock.Text = markdown;
});
}
}
//if (sender is CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownTextBlock markdownTextBlock)
//{
// if (_resource is ModrinthResource modrinthResource)
// {
// var markdown = await _modrinthClient.GetResourceDescriptionAsync(modrinthResource.Id);
// App.DispatcherQueue.TryEnqueue(() =>
// {
// markdownTextBlock.Config = new CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig();
// markdownTextBlock.Text = markdown;
// });
// }
//}
}

[RelayCommand]
Expand Down
32 changes: 31 additions & 1 deletion Natsurainko.FluentLauncher/Views/Cores/CoresPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</Grid.RowDefinitions>

<StackPanel
Name="stackPanel"
MaxWidth="1000"
Margin="{ThemeResource PageMarginWithStackPanel}"
Spacing="15">
Expand Down Expand Up @@ -84,8 +85,12 @@
</controls:WrapPanel>
</StackPanel>

<ScrollViewer Grid.Row="2" Padding="{ThemeResource PagePaddingWithScrollViewer}">
<ScrollViewer
Name="scrollViewer"
Grid.Row="2"
Padding="{ThemeResource PagePaddingWithScrollViewer}">
<ItemsRepeater
Name="itemsRepeater"
MaxWidth="1000"
Margin="{ThemeResource PageEndMarginWithScrollViewer}"
ItemsSource="{Binding DisplayMinecraftInstances}">
Expand Down Expand Up @@ -185,5 +190,30 @@
<behaviors:EmptyListVisibleBehavior IsObservableCollection="False" ItemsSource="{Binding DisplayMinecraftInstances}" />
</i:Interaction.Behaviors>
</StackPanel>

<!-- 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="stackPanel.Margin" Value="20, 10, 20, 20" />
<Setter Target="scrollViewer.Padding" Value="20, 0" />
<Setter Target="itemsRepeater.Margin" Value="0, 0, 0, 20" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions Natsurainko.FluentLauncher/Views/Cores/Install/WizardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</i:Interaction.Behaviors>

<StackPanel
Name="stackPanel"
MaxWidth="1060"
Margin="{ThemeResource PageMarginWithInstallWizardPageStackPanel}"
Padding="{ThemeResource PagePaddingWithInstallWizardPageStackPanel}">
Expand Down Expand Up @@ -73,6 +74,7 @@
Height="1"
Background="{ThemeResource NavigationViewContentGridBorderBrush}" />
<Grid
Name="grid"
Grid.Row="3"
MaxWidth="1080"
Padding="{ThemeResource PagePaddingWithInstallWizardPageGrid}"
Expand Down Expand Up @@ -114,5 +116,31 @@
</Button>
</Grid>
</Grid>

<!-- 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="grid.Padding" Value="20" />
<Setter Target="stackPanel.Margin" Value="10,0" />
<Setter Target="stackPanel.Padding" Value="10" />
<Setter Target="contentFrame.Padding" Value="20,0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>
25 changes: 24 additions & 1 deletion Natsurainko.FluentLauncher/Views/Cores/Manage/ConfigPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
mc:Ignorable="d">

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

</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/Cores/Manage/DefaultPage.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 Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -153,8 +153,30 @@
</controls:SettingsCard.Description>
<TextBlock Text="{Binding FormatSize}" />
</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/Cores/Manage/ModPage.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 Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -152,5 +152,28 @@
</StackPanel>
</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>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</Grid.RowDefinitions>

<BreadcrumbBar
Name="breadcrumbBar"
Grid.Row="0"
MaxWidth="1020"
Margin="{ThemeResource PageMarginWithBreadcrumbBar}"
Expand All @@ -30,7 +31,7 @@
<actions:ModifiedInvokeCommandAction Command="{Binding ItemClickedEventCommand}" />
</core:EventTriggerBehavior>
<core:EventTriggerBehavior EventName="Loading">
<actions:ModifiedInvokeCommandAction Command="{Binding BreadcrumbBarLoadingEventCommand}" />
<actions:ModifiedInvokeCommandAction Command="{Binding BreadcrumbBarLoadingEventCommand}" CommandParameter="{StaticResource BreadcrumbBarLocalizationConverter}" />
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>

Expand Down Expand Up @@ -61,5 +62,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>
25 changes: 24 additions & 1 deletion Natsurainko.FluentLauncher/Views/Cores/Manage/SavePage.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 Name="border" Margin="{ThemeResource PageMarginWithBorder}">
<StackPanel
MaxWidth="1000"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -128,5 +128,28 @@

</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 e81d058

Please sign in to comment.