New startup window.

This commit is contained in:
Burak Kaan Köse
2026-03-05 10:12:03 +01:00
parent d45d3faa89
commit db5ecd60e4
46 changed files with 1857 additions and 234 deletions
+34 -38
View File
@@ -2,11 +2,10 @@
x:Class="Wino.Dialogs.WhatIsNewDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Wino.Mail.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:domain="using:Wino.Core.Domain"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:models="using:Wino.Core.Domain.Models.Updates"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Style="{StaticResource WinoDialogStyle}"
@@ -26,45 +25,42 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<FlipView
x:Name="UpdateFlipView"
ItemsSource="{x:Bind Sections, Mode=OneTime}"
SelectionChanged="OnFlipViewSelectionChanged">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="models:UpdateNoteSection">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel Spacing="16" Padding="12,8">
<controls:MarkdownTextBlock
Text="{x:Bind Title, Mode=OneTime}"
HorizontalAlignment="Center" />
<Image
Source="{x:Bind ImageUrl, Mode=OneTime}"
Width="{x:Bind ActualImageWidth, Mode=OneTime}"
Height="{x:Bind ActualImageHeight, Mode=OneTime}"
HorizontalAlignment="Center"
Stretch="Uniform" />
<controls:MarkdownTextBlock
Text="{x:Bind Description, Mode=OneTime}"
HorizontalAlignment="Stretch" />
</StackPanel>
</ScrollViewer>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
<controls:UpdateNotesFlipViewControl x:Name="UpdateNotesControl" Sections="{x:Bind Sections, Mode=OneTime}" />
<PipsPager
x:Name="FlipViewPager"
<StackPanel
x:Name="MigrationPanel"
Grid.Row="1"
HorizontalAlignment="Center"
SelectedPageIndex="0"
SelectedIndexChanged="OnPipsPagerSelectedIndexChanged" />
Spacing="8"
Visibility="Collapsed">
<TextBlock x:Name="MigrationTitleText" Style="{StaticResource BodyStrongTextBlockStyle}" />
<TextBlock x:Name="MigrationDescriptionText" TextWrapping="WrapWholeWords" />
<ProgressBar
x:Name="MigrationProgressBar"
IsIndeterminate="True"
Visibility="Collapsed" />
<TextBlock
x:Name="MigrationErrorText"
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
TextWrapping="WrapWholeWords"
Visibility="Collapsed" />
</StackPanel>
<Button
x:Name="GetStartedButton"
<StackPanel
Grid.Row="2"
HorizontalAlignment="Right"
Content="{x:Bind domain:Translator.WhatIsNew_GetStartedButton}"
Visibility="Collapsed"
Click="OnGetStartedClicked" />
VerticalAlignment="Center"
Orientation="Horizontal"
Spacing="8">
<Button
x:Name="ContinueAnywayButton"
Click="OnContinueAnywayClicked"
Content="{x:Bind domain:Translator.WhatIsNew_ContinueAnywayButton}"
Visibility="Collapsed" />
<Button
x:Name="GetStartedButton"
Click="OnGetStartedClicked"
Content="{x:Bind domain:Translator.WhatIsNew_GetStartedButton}"
Visibility="Collapsed" />
</StackPanel>
</Grid>
</ContentDialog>
+61 -30
View File
@@ -2,8 +2,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Windows.System;
using Wino.Core.Domain;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Updates;
@@ -12,61 +11,93 @@ namespace Wino.Dialogs;
public sealed partial class WhatIsNewDialog : ContentDialog
{
private readonly IUpdateManager _updateManager;
private readonly UpdateNotes _notes;
public List<UpdateNoteSection> Sections { get; }
private bool _canClose = false;
public WhatIsNewDialog(UpdateNotes notes, IUpdateManager updateManager)
{
InitializeComponent();
_notes = notes;
_updateManager = updateManager;
Sections = notes.Sections;
// Set the number of pages in the pip pager after sections are assigned.
FlipViewPager.NumberOfPages = Sections.Count;
// Show the Get Started button immediately when there is only one page.
if (Sections.Count <= 1)
GetStartedButton.Visibility = Visibility.Visible;
UpdateNotesControl.SelectedIndexChanged += OnUpdateSectionChanged;
UpdateGetStartedButtonVisibility(UpdateNotesControl.SelectedIndex);
InitializeMigrationStatus();
Closing += OnDialogClosing;
}
protected override void OnKeyDown(KeyRoutedEventArgs e)
private void OnUpdateSectionChanged(object? sender, int selectedIndex)
=> UpdateGetStartedButtonVisibility(selectedIndex);
private void UpdateGetStartedButtonVisibility(int selectedIndex)
{
// Block ESC key to prevent accidental dismissal.
if (e.Key == VirtualKey.Escape)
{
e.Handled = true;
return;
}
base.OnKeyDown(e);
}
private void OnFlipViewSelectionChanged(object sender, SelectionChangedEventArgs e)
{
int selectedIndex = UpdateFlipView.SelectedIndex;
// Keep pip pager in sync with the flip view.
FlipViewPager.SelectedPageIndex = selectedIndex;
// Show Get Started button only on the last page.
GetStartedButton.Visibility = selectedIndex == Sections.Count - 1
? Visibility.Visible
: Visibility.Collapsed;
}
private void OnPipsPagerSelectedIndexChanged(PipsPager sender, PipsPagerSelectedIndexChangedEventArgs args)
private void InitializeMigrationStatus()
{
UpdateFlipView.SelectedIndex = sender.SelectedPageIndex;
if (!_notes.HasPendingMigrations ||
string.IsNullOrWhiteSpace(_notes.Migration.TitleKey) ||
string.IsNullOrWhiteSpace(_notes.Migration.DescriptionKey))
return;
MigrationTitleText.Text = Translator.GetTranslatedString(_notes.Migration.TitleKey);
MigrationDescriptionText.Text = Translator.GetTranslatedString(_notes.Migration.DescriptionKey);
}
private void OnDialogClosing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
// Only allow closing when Get Started button was clicked.
if (!_canClose)
args.Cancel = true;
}
private async void OnGetStartedClicked(object sender, RoutedEventArgs e)
{
GetStartedButton.IsEnabled = false;
ContinueAnywayButton.Visibility = Visibility.Collapsed;
MigrationErrorText.Visibility = Visibility.Collapsed;
await _updateManager.RunPendingMigrationsAsync();
if (_notes.HasPendingMigrations)
{
GetStartedButton.Content = Translator.WhatIsNew_PreparingForNewVersionButton;
MigrationPanel.Visibility = Visibility.Visible;
MigrationProgressBar.Visibility = Visibility.Visible;
}
try
{
await _updateManager.RunPendingMigrationsAsync();
_updateManager.MarkUpdateNotesAsSeen();
}
catch (System.Exception ex)
{
MigrationProgressBar.Visibility = Visibility.Collapsed;
MigrationErrorText.Text = string.Format(Translator.WhatIsNew_MigrationFailedMessage, ex.GetType().Name);
MigrationErrorText.Visibility = Visibility.Visible;
ContinueAnywayButton.Visibility = Visibility.Visible;
GetStartedButton.IsEnabled = true;
GetStartedButton.Content = Translator.WhatIsNew_GetStartedButton;
return;
}
_canClose = true;
Hide();
}
private void OnContinueAnywayClicked(object sender, RoutedEventArgs e)
{
_updateManager.MarkUpdateNotesAsSeen();
_canClose = true;
Hide();
}
}