Skip to content

Commit 436c91e

Browse files
authored
Merge pull request WolvenKit#2628 from rayshader/fix/welcome_page_ui
feat(WelcomePageView): improve layout and responsiveness
2 parents bc39fcc + 829852e commit 436c91e

File tree

7 files changed

+990
-679
lines changed

7 files changed

+990
-679
lines changed

WolvenKit.App/ViewModels/HomePage/HomePageViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using System;
21
using System.Windows;
32
using CommunityToolkit.Mvvm.ComponentModel;
43
using CommunityToolkit.Mvvm.Input;
54
using WolvenKit.App.Services;
65
using WolvenKit.App.ViewModels.Shell;
7-
using WolvenKit.Core.Extensions;
86

97
namespace WolvenKit.App.ViewModels.HomePage;
108

@@ -28,7 +26,7 @@ public HomePageViewModel(AppViewModel appViewModel, ISettingsManager settingsMan
2826
{
2927
_appViewModel = appViewModel;
3028
_settingsManager = settingsManager;
31-
29+
3230
CurrentWindowState = WindowState.Normal;
3331
}
3432

@@ -39,6 +37,8 @@ public HomePageViewModel(AppViewModel appViewModel, ISettingsManager settingsMan
3937

4038
public string VersionNumber => _settingsManager.GetVersionNumber();
4139

40+
public bool IsNightly => VersionNumber.Contains("nightly");
41+
4242

4343
[RelayCommand]
4444
private void CloseHomePage()
@@ -50,5 +50,5 @@ private void CloseHomePage()
5050

5151
[RelayCommand]
5252
private void CheckForUpdates() => _appViewModel.CheckForUpdatesCommand.Execute(false);
53-
53+
5454
}

WolvenKit.App/ViewModels/Shell/AppViewModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,12 @@ private void HandleActivation()
307307
ShowHomePageSync();
308308
}
309309

310-
#if !DEBUG
310+
#if !DEBUG
311311
if (SettingsManager.AutoUpdateOnStartup)
312312
{
313313
CheckForUpdatesCommand.SafeExecute(true);
314314
}
315-
#endif
315+
#endif
316316

317317
CheckForScriptUpdatesCommand.SafeExecute();
318318
CheckForLongPathSupport();
@@ -2471,7 +2471,9 @@ private void UpdateScalesResource()
24712471
resources["WolvenKitHomeSharedPaddingLeft"] = new Thickness(10, 0, 0, 0).Mul(_uiScalePercentage).Round();
24722472

24732473
// WelcomePageView
2474-
resources["WolvenKitWelcomeRightLength"] = new GridLength(380).Mul(_uiScalePercentage).Round();
2474+
resources["WolvenKitWelcomeLogoMaxHeight"] = Math.Round(150 * _uiScalePercentage);
2475+
resources["WolvenKitWelcomeLeftMinWidth"] = Math.Round(315 * _uiScalePercentage);
2476+
resources["WolvenKitWelcomeRightLength"] = Math.Round(380 * _uiScalePercentage);
24752477
resources["WolvenKitWelcomeOrderWidth"] = Math.Round(140 * _uiScalePercentage);
24762478
resources["WolvenKitWelcomeCardSammyWidth"] = new GridLength(70).Mul(_uiScalePercentage).Round();
24772479
resources["WolvenKitWelcomeCardSammyHeight"] = Math.Round(70 * _uiScalePercentage);
@@ -2486,6 +2488,9 @@ private void UpdateScalesResource()
24862488
resources["WolvenKitWelcomeStackMargin"] = new Thickness(0, 4, 50, 0).Mul(_uiScalePercentage).Round();
24872489
resources["WolvenKitWelcomeSocialButtonHeight"] = Math.Round(50 * _uiScalePercentage);
24882490

2491+
resources["WolvenKitWelcomeBreakWidth"] = Math.Round(1250 * _uiScalePercentage);
2492+
resources["WolvenKitWelcomeActionsColumnBreakWidth"] = Math.Round(914 * _uiScalePercentage);
2493+
24892494
// SettingsPageView
24902495
resources["WolvenKitSettingsGridLabelWidth"] = new GridLength(200).Mul(_uiScalePercentage).Round();
24912496

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace WolvenKit.Converters
7+
{
8+
/// <summary>
9+
/// Runs condition `Value < Parameter` where `Parameter` can be:
10+
/// - a number as a double
11+
/// - a resource as a string (as found in App.Sizes.xaml)
12+
/// </summary>
13+
[ValueConversion(typeof(double), typeof(bool))]
14+
public sealed class LessThanConverter : IValueConverter
15+
{
16+
public static readonly LessThanConverter Default = new();
17+
18+
public object Convert(object rawValue, Type targetType, object parameter, CultureInfo culture)
19+
{
20+
if (rawValue is double value)
21+
{
22+
if (double.TryParse(parameter as string, out var threshold))
23+
{
24+
return value < threshold;
25+
}
26+
else
27+
{
28+
var resources = Application.Current.Resources;
29+
return value < (double)resources[parameter as string]!;
30+
}
31+
}
32+
return false;
33+
}
34+
35+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
36+
{
37+
throw new NotImplementedException();
38+
}
39+
}
40+
}

WolvenKit/Themes/App.Sizes.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@
120120
<Thickness x:Key="WolvenKitHomeSharedPaddingLeft">10,0,0,0</Thickness>
121121

122122
<!-- WelcomePageView -->
123-
<GridLength x:Key="WolvenKitWelcomeRightLength">380</GridLength>
123+
<system:Double x:Key="WolvenKitWelcomeLogoMaxHeight">150</system:Double>
124+
<system:Double x:Key="WolvenKitWelcomeLeftMinWidth">315</system:Double>
125+
<system:Double x:Key="WolvenKitWelcomeRightLength">380</system:Double>
124126
<system:Double x:Key="WolvenKitWelcomeOrderWidth">140</system:Double>
125127
<GridLength x:Key="WolvenKitWelcomeCardSammyWidth">70</GridLength>
126128
<system:Double x:Key="WolvenKitWelcomeCardSammyHeight">70</system:Double>
@@ -135,6 +137,9 @@
135137
<Thickness x:Key="WolvenKitWelcomeStackMargin">0,4,50,0</Thickness>
136138
<system:Double x:Key="WolvenKitWelcomeSocialButtonHeight">50</system:Double>
137139

140+
<system:Double x:Key="WolvenKitWelcomeBreakWidth">1250</system:Double>
141+
<system:Double x:Key="WolvenKitWelcomeActionsColumnBreakWidth">914</system:Double>
142+
138143
<!-- SettingsPageView -->
139144
<GridLength x:Key="WolvenKitSettingsGridLabelWidth">200</GridLength>
140145

WolvenKit/Views/HomePage/HomePageView.xaml

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@
4848
<RowDefinition />
4949
</Grid.RowDefinitions>
5050

51-
<!-- Left Bottom Button -->
51+
<!-- Continue to Editor Button -->
5252
<Button
5353
x:Name="ToEditorButton"
5454
Grid.Row="0"
5555
Margin="4,4,4,30"
5656
Padding="0"
57-
HorizontalAlignment="Stretch"
57+
HorizontalAlignment="Left"
5858
Background="{StaticResource ContentBackgroundAlt}"
5959
BorderThickness="0">
6060
<Grid>
@@ -82,12 +82,42 @@
8282
</Grid>
8383
</Button>
8484

85-
<!-- Left Bottom Version Number -->
86-
<StackPanel
85+
<!-- Version Number -->
86+
<Grid
8787
Grid.Row="1"
8888
Margin="{DynamicResource WolvenKitHomeVersionMargin}"
89-
HorizontalAlignment="Left"
90-
Orientation="Horizontal">
89+
HorizontalAlignment="Left">
90+
<Grid.Resources>
91+
<Style
92+
x:Key="NightlyResponsiveStyle"
93+
TargetType="{x:Type StackPanel}">
94+
<Setter Property="Grid.Column" Value="1" />
95+
<Setter Property="Grid.Row" Value="0" />
96+
97+
<Style.Triggers>
98+
<DataTrigger
99+
Binding="{Binding IsNightly}"
100+
Value="True">
101+
<Setter Property="Grid.Column" Value="0" />
102+
<Setter Property="Grid.ColumnSpan" Value="2" />
103+
<Setter Property="Grid.Row" Value="1" />
104+
<Setter Property="HorizontalAlignment" Value="Right" />
105+
</DataTrigger>
106+
</Style.Triggers>
107+
</Style>
108+
</Grid.Resources>
109+
110+
<Grid.RowDefinitions>
111+
<RowDefinition />
112+
<!-- 2nd row reserved for responsiveness -->
113+
<RowDefinition />
114+
</Grid.RowDefinitions>
115+
116+
<Grid.ColumnDefinitions>
117+
<ColumnDefinition />
118+
<ColumnDefinition />
119+
</Grid.ColumnDefinitions>
120+
91121
<TextBlock
92122
Margin="{DynamicResource WolvenKitHomeVersionMargin}"
93123
VerticalAlignment="Center"
@@ -97,19 +127,21 @@
97127
FlowDirection="LeftToRight"
98128
Text="{Binding VersionNumber}" />
99129

100-
<templates:IconBox
101-
IconPack="Codicons"
102-
Kind="Versions"
103-
Size="{DynamicResource WolvenKitIcon}"
104-
Foreground="{StaticResource WolvenKitRed}" />
105-
106-
<Button
107-
x:Name="CheckForUpdateButton"
108-
Margin="{DynamicResource WolvenKitHomeVersionMargin}"
109-
Padding="0"
110-
Background="Transparent"
111-
BorderThickness="0">
112-
<Grid>
130+
<StackPanel
131+
Style="{StaticResource NightlyResponsiveStyle}"
132+
Orientation="Horizontal">
133+
<templates:IconBox
134+
IconPack="Codicons"
135+
Kind="Versions"
136+
Size="{DynamicResource WolvenKitIcon}"
137+
Foreground="{StaticResource WolvenKitRed}" />
138+
139+
<Button
140+
x:Name="CheckForUpdateButton"
141+
Margin="{DynamicResource WolvenKitHomeVersionMargin}"
142+
Padding="0"
143+
Background="Transparent"
144+
BorderThickness="0">
113145
<templates:IconBox
114146
IconPack="Material"
115147
Kind="Update"
@@ -118,10 +150,9 @@
118150
VerticalAlignment="Center"
119151
Size="{DynamicResource WolvenKitIconMilli}"
120152
Foreground="{StaticResource WolvenKitRed}" />
121-
</Grid>
122-
</Button>
123-
124-
</StackPanel>
153+
</Button>
154+
</StackPanel>
155+
</Grid>
125156
</Grid>
126157

127158
<!-- Left Navigation -->

0 commit comments

Comments
 (0)