update app outdated dialog

This commit is contained in:
kwan.nguyen 2025-01-07 13:56:10 +07:00
parent 7f32fa1cb8
commit 869502a72c
4 changed files with 108 additions and 10 deletions

View File

@ -135,16 +135,18 @@ namespace PCUT
if (e.Exception is AppOutdatedException outdatedException) if (e.Exception is AppOutdatedException outdatedException)
{ {
e.Handled = true; e.Handled = true;
var dialog = new MessageDialog(outdatedException.Message); //var dialog = new MessageDialog(outdatedException.Message);
dialog.Commands.Add(new UICommand("Download", async (command) => //dialog.Commands.Add(new UICommand("Download", async (command) =>
{ //{
var _ = await Windows.System.Launcher.LaunchUriAsync( // var _ = await Windows.System.Launcher.LaunchUriAsync(
new Uri("https://pcut.vn/download"), // new Uri("https://pcut.vn/download"),
new Windows.System.LauncherOptions { TreatAsUntrusted = false }); // new Windows.System.LauncherOptions { TreatAsUntrusted = false });
})); //}));
dialog.Commands.Add(new UICommand("Close")); //dialog.Commands.Add(new UICommand("Close"));
dialog.DefaultCommandIndex = 0; //dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1; //dialog.CancelCommandIndex = 1;
//await dialog.ShowAsync();
var dialog = new AppOutdatedDialog();
await dialog.ShowAsync(); await dialog.ShowAsync();
} }
} }

View File

@ -183,6 +183,9 @@
<Compile Include="Models\Categories\CategoryTemplateSelector.cs" /> <Compile Include="Models\Categories\CategoryTemplateSelector.cs" />
<Compile Include="Models\NotificationBase.cs" /> <Compile Include="Models\NotificationBase.cs" />
<Compile Include="Models\Users\UsersModel.cs" /> <Compile Include="Models\Users\UsersModel.cs" />
<Compile Include="Pages\AppOutdatedDialog.xaml.cs">
<DependentUpon>AppOutdatedDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\CategoriesManagement\CategoryUpsertDialog.xaml.cs"> <Compile Include="Pages\CategoriesManagement\CategoryUpsertDialog.xaml.cs">
<DependentUpon>CategoryUpsertDialog.xaml</DependentUpon> <DependentUpon>CategoryUpsertDialog.xaml</DependentUpon>
</Compile> </Compile>
@ -351,6 +354,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="Pages\AppOutdatedDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\CategoriesManagement\CategoryUpsertDialog.xaml"> <Page Include="Pages\CategoriesManagement\CategoryUpsertDialog.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,50 @@
<ContentDialog
x:Class="PCUT.Pages.AppOutdatedDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PCUT.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Text="Your app version is no longer supported. Please update to the newest version."/>
<Grid
Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0.2*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="Download latest version" VerticalAlignment="Center" />
<Button
x:Name="DownloadBtn"
Width="140" Height="40"
Background="{ThemeResource SystemAccentColor}" CornerRadius="20"
Margin="10 0 0 0"
Click="DownloadBtn_Click">
<StackPanel Orientation="Horizontal" Margin="10 0 0 0">
<TextBlock Text="Download"/>
<SymbolIcon Symbol="Download" Margin="10 0 0 0" />
</StackPanel>
</Button>
</StackPanel>
<Button
x:Name="CloseBtn"
Grid.Column="1"
Width="100" Height="40"
CornerRadius="20"
HorizontalAlignment="Center"
Content="Close"
Click="CloseBtn_Click"/>
</Grid>
</Grid>
</ContentDialog>

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace PCUT.Pages
{
public sealed partial class AppOutdatedDialog : ContentDialog
{
public AppOutdatedDialog()
{
this.InitializeComponent();
}
private async void DownloadBtn_Click(object sender, RoutedEventArgs e)
{
var _ = await Windows.System.Launcher.LaunchUriAsync(
new Uri("https://pcut.vn/download"),
new Windows.System.LauncherOptions { TreatAsUntrusted = false });
}
private void CloseBtn_Click(object sender, RoutedEventArgs e)
{
Hide();
}
}
}