Skip to content

Commit ac02e41

Browse files
committed
feat: Start WinUI new design
1 parent 027d202 commit ac02e41

8 files changed

Lines changed: 343 additions & 364 deletions

File tree

Nickvision.Application.WinUI/Controls/AboutDialog.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public AboutDialog(AppInfo appInfo, ITranslationService translator)
2929
LblAppName.Text = appInfo.ShortName;
3030
LblAppDescription.Text = appInfo.Description;
3131
LblAppVersion.Text = appInfo.Version!.ToString();
32-
LblAppCopyright.Text = "© Nickvision 2021-2025";
32+
LblAppCopyright.Text = "© Nickvision 2021-2026";
3333
LblChangelog.Text = appInfo.Changelog!;
3434
LblCopyDebugInformation.Text = _translator._("Copy Debug Information");
3535
if (string.IsNullOrEmpty(_appInfo.TranslationCredits) || _appInfo.TranslationCredits == "translation-credits")

Nickvision.Application.WinUI/Nickvision.Application.WinUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
3737
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.28000.1721" />
3838
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.260317003" />
39-
<PackageReference Include="Nickvision.Desktop.WinUI" Version="2026.4.0" />
39+
<PackageReference Include="Nickvision.Desktop.WinUI" Version="2026.4.1" />
4040
</ItemGroup>
4141
<ItemGroup>
4242
<ProjectReference Include="..\Nickvision.Application.Shared\Nickvision.Application.Shared.csproj" />

Nickvision.Application.WinUI/Views/MainWindow.xaml

Lines changed: 147 additions & 131 deletions
Large diffs are not rendered by default.

Nickvision.Application.WinUI/Views/MainWindow.xaml.cs

Lines changed: 75 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using Microsoft.UI.Windowing;
44
using Microsoft.UI.Xaml;
55
using Microsoft.UI.Xaml.Controls;
6-
using Microsoft.UI.Xaml.Controls.Primitives;
7-
using Microsoft.UI.Xaml.Input;
86
using Microsoft.Windows.AppNotifications;
97
using Microsoft.Windows.AppNotifications.Builder;
108
using Microsoft.Windows.Storage.Pickers;
@@ -15,13 +13,11 @@
1513
using Nickvision.Application.WinUI.Controls;
1614
using Nickvision.Desktop.Application;
1715
using Nickvision.Desktop.Globalization;
18-
using Nickvision.Desktop.Network;
1916
using Nickvision.Desktop.Notifications;
17+
using Nickvision.Desktop.WinUI.Controls;
2018
using Nickvision.Desktop.WinUI.Helpers;
2119
using System;
2220
using System.IO;
23-
using System.Threading.Tasks;
24-
using Windows.Storage;
2521
using Windows.System;
2622

2723
namespace Nickvision.Application.WinUI.Views;
@@ -50,6 +46,12 @@ public MainWindow(IServiceProvider serviceProvider, MainWindowController control
5046
_translationService = translationService;
5147
_notificationClickHandler = null;
5248
// Config
49+
AppWindow.TitleBar.PreferredTheme = _controller.Theme switch
50+
{
51+
Theme.Light => TitleBarTheme.Light,
52+
Theme.Dark => TitleBarTheme.Dark,
53+
_ => TitleBarTheme.UseDefaultAppMode
54+
};
5355
MainGrid.RequestedTheme = _controller.Theme switch
5456
{
5557
Theme.Light => ElementTheme.Light,
@@ -70,27 +72,30 @@ public MainWindow(IServiceProvider serviceProvider, MainWindowController control
7072
eventsService.FolderChanged += App_FolderChanged;
7173
// Translations
7274
AppWindow.Title = _appInfo.ShortName;
73-
TitleBar.Title = _appInfo.ShortName;
74-
TitleBar.Subtitle = _appInfo.Version!.IsPreview ? _translationService._("Preview") : string.Empty;
75-
NavItemHome.Content = _translationService._("Home");
76-
NavItemFolder.Content = _translationService._("Folder");
77-
NavItemUpdates.Content = _translationService._("Updating");
78-
NavItemHelp.Content = _translationService._("Help");
75+
LblTitle.Text = _appInfo.ShortName;
76+
MenuFile.Title = _translationService._("File");
77+
MenuOpenFolder.Text = _translationService._("Open Folder");
78+
MenuCloseFolder.Text = _translationService._("Close Folder");
79+
MenuExit.Text = _translationService._("Exit");
80+
MenuEdit.Title = _translationService._("Edit");
81+
MenuHelp.Title = _translationService._("Help");
82+
MenuSettings.Text = _translationService._("Settings");
7983
MenuCheckForUpdates.Text = _translationService._("Check for Updates");
8084
MenuGitHubRepo.Text = _translationService._("GitHub Repo");
8185
MenuReportABug.Text = _translationService._("Report a Bug");
8286
MenuDiscussions.Text = _translationService._("Discussions");
8387
MenuAbout.Text = _translationService._("About {0}", _appInfo.ShortName!);
84-
NavItemSettings.Content = _translationService._("Settings");
85-
StatusHome.Title = _controller.Greeting;
86-
StatusHome.Description = _translationService._("Open a folder to get started");
87-
LblHomeOpenFolder.Text = _translationService._("Open Folder");
88-
BtnFolderOpenFolder.Label = _translationService._("Open");
89-
BtnFolderCloseFolder.Label = _translationService._("Close");
88+
BtnPreview.Visibility = _appInfo.Version!.IsPreview ? Visibility.Visible : Visibility.Collapsed;
89+
ToolTipService.SetToolTip(BtnPreview, _translationService._("You are running a preview version of {0}", _appInfo.ShortName!));
90+
LblPreview.Text = _translationService._("Thank you for testing the upcoming features and changes! ❤️");
91+
LblOpenFolder.Text = _translationService._("Open Folder");
92+
LblSettings.Text = _translationService._("Settings");
93+
BtnCloseFolder.Label = _translationService._("Close");
9094
}
9195

92-
private async void Window_Loaded(object sender, RoutedEventArgs e)
96+
private async void Window_Loaded(object sender, RoutedEventArgs args)
9397
{
98+
ViewStack.SelectedIndex = (int)Pages.Home;
9499
MenuCheckForUpdates.IsEnabled = false;
95100
await _controller.CheckForUpdatesAsync(false);
96101
MenuCheckForUpdates.IsEnabled = true;
@@ -100,39 +105,13 @@ private void Window_Closing(AppWindow sender, AppWindowClosingEventArgs args)
100105
{
101106
if (!_controller.CanShutdown)
102107
{
103-
args.Cancel = true;
108+
args?.Cancel = true;
104109
return;
105110
}
106111
_controller.WindowGeometry = this.Geometry;
107112
_serviceProvider.GetRequiredService<IHostApplicationLifetime>().StopApplication();
108113
}
109114

110-
private void TitleBar_PaneToggleRequested(TitleBar sender, object args)
111-
{
112-
NavView.IsPaneOpen = !NavView.IsPaneOpen;
113-
}
114-
115-
private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
116-
{
117-
if (args.SelectedItem is NavigationViewItem item)
118-
{
119-
var tag = item.Tag as string;
120-
FrameCustom.Content = tag switch
121-
{
122-
"Settings" => _serviceProvider.GetRequiredService<SettingsPage>(),
123-
_ => null
124-
};
125-
ViewStack.SelectedIndex = tag switch
126-
{
127-
"Folder" => (int)Pages.Folder,
128-
"Settings" => (int)Pages.Custom,
129-
_ => (int)Pages.Home
130-
};
131-
}
132-
}
133-
134-
private void NavItem_Tapped(object sender, TappedRoutedEventArgs e) => FlyoutBase.ShowAttachedFlyout(sender as FrameworkElement);
135-
136115
private void App_AppNotificationSent(object? sender, AppNotificationSentEventArgs args)
137116
{
138117
if (args.Notification is ShellNotification shellNotification)
@@ -182,6 +161,12 @@ private void App_ConfigurationSaved(object? sender, ConfigurationSavedEventArgs
182161
{
183162
if (args.ChangedPropertyName == "Theme")
184163
{
164+
AppWindow.TitleBar.PreferredTheme = _controller.Theme switch
165+
{
166+
Theme.Light => TitleBarTheme.Light,
167+
Theme.Dark => TitleBarTheme.Dark,
168+
_ => TitleBarTheme.UseDefaultAppMode
169+
};
185170
MainGrid.RequestedTheme = _controller.Theme switch
186171
{
187172
Theme.Light => ElementTheme.Light,
@@ -227,50 +212,29 @@ private async void App_DatabasePasswordRequired(object? sender, PasswordRequired
227212

228213
private void App_FolderChanged(object? sender, FolderChangedEventArgs args)
229214
{
230-
foreach (var item in ListFolderFiles.Items)
231-
{
232-
if (item is ListViewItem listViewItem)
233-
{
234-
listViewItem.DoubleTapped -= ListFolderFiles_ItemDoubleTapped;
235-
}
236-
}
237-
ListFolderFiles.Items.Clear();
215+
TitleBar.IsBackButtonVisible = false;
216+
ListFiles.Items.Clear();
238217
if (args.IsOpen)
239218
{
240-
NavItemFolder.Visibility = Visibility.Visible;
241-
NavItemFolder.IsSelected = true;
242-
InfoBadgeFolder.Value = args.Files.Count;
243-
LblFolderPath.Text = args.Path;
244-
foreach (var file in args.Files)
219+
ViewStack.SelectedIndex = (int)Pages.Folder;
220+
foreach(var file in args.Files)
245221
{
246-
var item = new ListViewItem();
247-
item.Content = Path.GetFileName(file);
248-
item.Tag = file;
249-
item.DoubleTapped += ListFolderFiles_ItemDoubleTapped;
250-
ListFolderFiles.Items.Add(item);
222+
ListFiles.Items.Add(Path.GetFileName(file));
251223
}
252224
}
253225
else
254226
{
255-
NavItemFolder.Visibility = Visibility.Collapsed;
256-
NavItemHome.IsSelected = true;
227+
ViewStack.SelectedIndex = (int)Pages.Home;
257228
}
258229
}
259230

260-
private async void ListFolderFiles_ItemDoubleTapped(object sender, DoubleTappedRoutedEventArgs args)
231+
private void TitleBar_BackRequested(TitleBar sender, object args)
261232
{
262-
if (sender is ListViewItem item)
263-
{
264-
var tag = item.Tag as string;
265-
if (string.IsNullOrEmpty(tag))
266-
{
267-
return;
268-
}
269-
await Launcher.LaunchFileAsync(await StorageFile.GetFileFromPathAsync(tag));
270-
}
233+
TitleBar.IsBackButtonVisible = false;
234+
ViewStack.SelectedIndex = ViewStack.PreviousSelectedIndex;
271235
}
272236

273-
private async void OpenFolder(object sender, RoutedEventArgs e)
237+
private async void OpenFolder(object sender, RoutedEventArgs args)
274238
{
275239
var picker = new FolderPicker(AppWindow.Id);
276240
var result = await picker.PickSingleFolderAsync();
@@ -281,22 +245,31 @@ private async void OpenFolder(object sender, RoutedEventArgs e)
281245
_controller.OpenFolder(result.Path);
282246
}
283247

284-
private void CloseFolder(object sender, RoutedEventArgs e) => _controller.CloseFolder();
248+
private void CloseFolder(object sender, RoutedEventArgs args) => _controller.CloseFolder();
249+
250+
private void Exit(object sender, RoutedEventArgs args) => Window_Closing(AppWindow, null);
251+
252+
private void Settings(object sender, RoutedEventArgs args)
253+
{
254+
TitleBar.IsBackButtonVisible = true;
255+
ViewStack.SelectedIndex = (int)Pages.Custom;
256+
FrameCustom.Content = _serviceProvider.GetRequiredService<SettingsPage>();
257+
}
285258

286-
private async void CheckForUpdates(object sender, RoutedEventArgs e)
259+
private async void CheckForUpdates(object sender, RoutedEventArgs args)
287260
{
288261
MenuCheckForUpdates.IsEnabled = false;
289262
await _controller.CheckForUpdatesAsync(true);
290263
MenuCheckForUpdates.IsEnabled = true;
291264
}
292265

293-
private async void GitHubRepo(object sender, RoutedEventArgs e) => await LaunchUriAsync(_appInfo.SourceRepository);
266+
private async void GitHubRepo(object sender, RoutedEventArgs args) => await Launcher.LaunchUriAsync(_appInfo.SourceRepository!);
294267

295-
private async void ReportABug(object sender, RoutedEventArgs e) => await LaunchUriAsync(_appInfo.IssueTracker);
268+
private async void ReportABug(object sender, RoutedEventArgs args) => await Launcher.LaunchUriAsync(_appInfo.IssueTracker!);
296269

297-
private async void Discussions(object sender, RoutedEventArgs e) => await LaunchUriAsync(_appInfo.DiscussionsForum);
270+
private async void Discussions(object sender, RoutedEventArgs args) => await Launcher.LaunchUriAsync(_appInfo.DiscussionsForum!);
298271

299-
private async void About(object sender, RoutedEventArgs e)
272+
private async void About(object sender, RoutedEventArgs args)
300273
{
301274
var aboutDialog = _serviceProvider.GetRequiredService<AboutDialog>();
302275
aboutDialog.DebugInformation = _controller.GetDebugInformation();
@@ -305,35 +278,26 @@ private async void About(object sender, RoutedEventArgs e)
305278
await aboutDialog.ShowAsync();
306279
}
307280

308-
private async void WindowsUpdate(object sender, RoutedEventArgs e)
281+
private async void WindowsUpdate(object sender, RoutedEventArgs args)
309282
{
310-
var progress = new Progress<DownloadProgress>();
311-
progress.ProgressChanged += (s, p) =>
312-
{
313-
DispatcherQueue.TryEnqueue(() =>
314-
{
315-
if (p.Completed)
316-
{
317-
FlyoutProgress.Hide();
318-
NavItemUpdates.Visibility = Visibility.Collapsed;
319-
return;
320-
}
321-
var message = _translationService._("Downloading update: {0}%", Math.Round(p.Percentage * 100));
322-
NavItemUpdates.Visibility = Visibility.Visible;
323-
StsProgress.Description = message;
324-
BarProgress.Value = p.Percentage * 100;
325-
});
326-
};
327-
InfoBar.IsOpen = false;
328-
await _controller.WindowsUpdateAsync(progress);
329-
}
330-
331-
private async Task LaunchUriAsync(Uri? uri)
332-
{
333-
if (uri is null)
334-
{
335-
return;
336-
}
337-
await Launcher.LaunchUriAsync(uri);
283+
//var progress = new Progress<DownloadProgress>();
284+
//progress.ProgressChanged += (s, p) =>
285+
//{
286+
// DispatcherQueue.TryEnqueue(() =>
287+
// {
288+
// if (p.Completed)
289+
// {
290+
// FlyoutProgress.Hide();
291+
// NavItemUpdates.Visibility = Visibility.Collapsed;
292+
// return;
293+
// }
294+
// var message = _translationService._("Downloading update: {0}%", Math.Round(p.Percentage * 100));
295+
// NavItemUpdates.Visibility = Visibility.Visible;
296+
// StsProgress.Description = message;
297+
// BarProgress.Value = p.Percentage * 100;
298+
// });
299+
//};
300+
//InfoBar.IsOpen = false;
301+
//await _controller.WindowsUpdateAsync(progress);
338302
}
339303
}

Nickvision.Application.WinUI/Views/SettingsPage.xaml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,32 @@
88
xmlns:community="using:CommunityToolkit.WinUI.Controls"
99
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1010
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
11-
mc:Ignorable="d" Loaded="Page_Loaded">
11+
mc:Ignorable="d" Loaded="Page_Loaded" Unloaded="Page_Unloaded">
1212

13-
<Grid x:Name="MainGrid" RowSpacing="12">
14-
<Grid.Transitions>
15-
<TransitionCollection>
16-
<EntranceThemeTransition/>
17-
</TransitionCollection>
18-
</Grid.Transitions>
13+
<NavigationView x:Name="NavigationView" IsPaneToggleButtonVisible="False" IsBackButtonVisible="Collapsed" IsSettingsVisible="False"
14+
PaneDisplayMode="Left" SelectionChanged="NavigationView_SelectionChanged">
15+
<NavigationView.Resources>
16+
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent"/>
17+
<SolidColorBrush x:Key="NavigationViewContentGridBorderBrush" Color="Transparent"/>
18+
</NavigationView.Resources>
1919

20-
<Grid.RowDefinitions>
21-
<RowDefinition Height="Auto"/>
22-
<RowDefinition Height="Auto"/>
23-
<RowDefinition Height="*"/>
24-
</Grid.RowDefinitions>
25-
26-
<TextBlock x:Name="LblSettings" Grid.Row="0" Margin="24,24,0,0" Style="{ThemeResource SubtitleTextBlockStyle}"/>
27-
28-
<SelectorBar Grid.Row="1" Margin="24,0,0,0" SelectionChanged="SelectorBar_SelectionChanged">
29-
<SelectorBarItem x:Name="SelectorUI" IsSelected="True">
30-
<SelectorBarItem.Icon>
20+
<NavigationView.MenuItems>
21+
<NavigationViewItem x:Name="NavUserInterface" Tag="0" IsSelected="True">
22+
<NavigationViewItem.Icon>
3123
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE790;"/>
32-
</SelectorBarItem.Icon>
33-
</SelectorBarItem>
34-
</SelectorBar>
24+
</NavigationViewItem.Icon>
25+
</NavigationViewItem>
26+
</NavigationView.MenuItems>
3527

36-
<ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
37-
<nickvision:ViewStack x:Name="ViewStack" Margin="24,0,24,24">
28+
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
29+
<nickvision:ViewStack x:Name="ViewStack" Margin="12,12,12,12">
3830
<nickvision:ViewStack.Pages>
3931
<StackPanel Spacing="6">
40-
<StackPanel.Transitions>
41-
<TransitionCollection>
42-
<EntranceThemeTransition/>
43-
</TransitionCollection>
44-
</StackPanel.Transitions>
45-
4632
<community:SettingsCard x:Name="RowTheme">
4733
<community:SettingsCard.HeaderIcon>
48-
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE793;"/>
34+
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE793;"/>
4935
</community:SettingsCard.HeaderIcon>
50-
36+
5137
<ComboBox x:Name="CmbTheme" SelectionChanged="Cmb_SelectionChanged">
5238
<ComboBox.ItemTemplate>
5339
<DataTemplate x:DataType="helpers:BindableSelectionItem">
@@ -82,5 +68,5 @@
8268
</nickvision:ViewStack.Pages>
8369
</nickvision:ViewStack>
8470
</ScrollViewer>
85-
</Grid>
71+
</NavigationView>
8672
</Page>

0 commit comments

Comments
 (0)