Whats new implementation.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<ContentDialog
|
||||
x:Class="Wino.Dialogs.WhatIsNewDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
Style="{StaticResource WinoDialogStyle}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ContentDialog.Resources>
|
||||
<x:Double x:Key="ContentDialogMinWidth">480</x:Double>
|
||||
<x:Double x:Key="ContentDialogMaxWidth">560</x:Double>
|
||||
<x:Double x:Key="ContentDialogMinHeight">480</x:Double>
|
||||
<x:Double x:Key="ContentDialogMaxHeight">700</x:Double>
|
||||
</ContentDialog.Resources>
|
||||
|
||||
<Grid RowSpacing="12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<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>
|
||||
|
||||
<PipsPager
|
||||
x:Name="FlipViewPager"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
SelectedPageIndex="0"
|
||||
SelectedIndexChanged="OnPipsPagerSelectedIndexChanged" />
|
||||
|
||||
<Button
|
||||
x:Name="GetStartedButton"
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Right"
|
||||
Content="{x:Bind domain:Translator.WhatIsNew_GetStartedButton}"
|
||||
Visibility="Collapsed"
|
||||
Click="OnGetStartedClicked" />
|
||||
</Grid>
|
||||
</ContentDialog>
|
||||
@@ -0,0 +1,72 @@
|
||||
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.Interfaces;
|
||||
using Wino.Core.Domain.Models.Updates;
|
||||
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class WhatIsNewDialog : ContentDialog
|
||||
{
|
||||
private readonly IUpdateManager _updateManager;
|
||||
|
||||
public List<UpdateNoteSection> Sections { get; }
|
||||
|
||||
public WhatIsNewDialog(UpdateNotes notes, IUpdateManager updateManager)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyRoutedEventArgs e)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
UpdateFlipView.SelectedIndex = sender.SelectedPageIndex;
|
||||
}
|
||||
|
||||
private async void OnGetStartedClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GetStartedButton.IsEnabled = false;
|
||||
|
||||
await _updateManager.RunPendingMigrationsAsync();
|
||||
_updateManager.MarkUpdateNotesAsSeen();
|
||||
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user