guide view

This commit is contained in:
Lightczx
2023-08-28 17:25:25 +08:00
parent 32a780f460
commit 605a48f8f2
9 changed files with 438 additions and 23 deletions

View File

@@ -0,0 +1,18 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml.Markup;
namespace Snap.Hutao.Control.Markup;
[MarkupExtensionReturnType(ReturnType = typeof(uint))]
internal sealed class UInt32Extension : MarkupExtension
{
public string Value { get; set; } = default!;
protected override object ProvideValue()
{
_ = uint.TryParse(Value, out uint result);
return result;
}
}

View File

@@ -150,7 +150,7 @@ internal sealed class Activation : IActivation
// Increase launch times
LocalSetting.Set(SettingKeys.LaunchTimes, LocalSetting.Get(SettingKeys.LaunchTimes, 0) + 1);
if (false && LocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, (uint)GuideState.None) < (uint)GuideState.Completed)
if (true && LocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, (uint)GuideState.Language) < (uint)GuideState.Completed)
{
await taskContext.SwitchToMainThreadAsync();
serviceProvider.GetRequiredService<GuideWindow>();

View File

@@ -4,17 +4,11 @@
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:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvg="using:Snap.Hutao.View.Guide"
mc:Ignorable="d">
<Grid x:Name="RootGrid">
<mxi:Interaction.Behaviors>
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
</mxi:Interaction.Behaviors>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>

View File

@@ -2535,6 +2535,87 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 我已阅读 的本地化字符串。
/// </summary>
internal static string ViewGuideStepAgreementIHaveReadText {
get {
return ResourceManager.GetString("ViewGuideStepAgreementIHaveReadText", resourceCulture);
}
}
/// <summary>
/// 查找类似 问题报告方式与流程 的本地化字符串。
/// </summary>
internal static string ViewGuideStepAgreementIssueReport {
get {
return ResourceManager.GetString("ViewGuideStepAgreementIssueReport", resourceCulture);
}
}
/// <summary>
/// 查找类似 Snap Hutao 开源许可 的本地化字符串。
/// </summary>
internal static string ViewGuideStepAgreementOpenSourceLicense {
get {
return ResourceManager.GetString("ViewGuideStepAgreementOpenSourceLicense", resourceCulture);
}
}
/// <summary>
/// 查找类似 用户数据与隐私权益 的本地化字符串。
/// </summary>
internal static string ViewGuideStepAgreementPrivacyPolicy {
get {
return ResourceManager.GetString("ViewGuideStepAgreementPrivacyPolicy", resourceCulture);
}
}
/// <summary>
/// 查找类似 用户使用协议与法律声明 的本地化字符串。
/// </summary>
internal static string ViewGuideStepAgreementTermOfService {
get {
return ResourceManager.GetString("ViewGuideStepAgreementTermOfService", resourceCulture);
}
}
/// <summary>
/// 查找类似 文档 的本地化字符串。
/// </summary>
internal static string ViewGuideStepDocument {
get {
return ResourceManager.GetString("ViewGuideStepDocument", resourceCulture);
}
}
/// <summary>
/// 查找类似 环境 的本地化字符串。
/// </summary>
internal static string ViewGuideStepEnvironment {
get {
return ResourceManager.GetString("ViewGuideStepEnvironment", resourceCulture);
}
}
/// <summary>
/// 查找类似 语言 的本地化字符串。
/// </summary>
internal static string ViewGuideStepLanguage {
get {
return ResourceManager.GetString("ViewGuideStepLanguage", resourceCulture);
}
}
/// <summary>
/// 查找类似 资源 的本地化字符串。
/// </summary>
internal static string ViewGuideStepStaticResource {
get {
return ResourceManager.GetString("ViewGuideStepStaticResource", resourceCulture);
}
}
/// <summary>
/// 查找类似 深渊统计 的本地化字符串。
/// </summary>
@@ -2985,6 +3066,42 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 我已阅读并同意上方的条款 的本地化字符串。
/// </summary>
internal static string ViewModelGuideActionAgreement {
get {
return ResourceManager.GetString("ViewModelGuideActionAgreement", resourceCulture);
}
}
/// <summary>
/// 查找类似 完成 的本地化字符串。
/// </summary>
internal static string ViewModelGuideActionComplete {
get {
return ResourceManager.GetString("ViewModelGuideActionComplete", resourceCulture);
}
}
/// <summary>
/// 查找类似 下一步 的本地化字符串。
/// </summary>
internal static string ViewModelGuideActionNext {
get {
return ResourceManager.GetString("ViewModelGuideActionNext", resourceCulture);
}
}
/// <summary>
/// 查找类似 下载资源文件中,请稍后 的本地化字符串。
/// </summary>
internal static string ViewModelGuideActionStaticResourceBegin {
get {
return ResourceManager.GetString("ViewModelGuideActionStaticResourceBegin", resourceCulture);
}
}
/// <summary>
/// 查找类似 请输入正确的邮箱 的本地化字符串。
/// </summary>

View File

@@ -998,6 +998,33 @@
<data name="ViewGachaLogHeader" xml:space="preserve">
<value>祈愿记录</value>
</data>
<data name="ViewGuideStepAgreementIHaveReadText" xml:space="preserve">
<value>我已阅读</value>
</data>
<data name="ViewGuideStepAgreementIssueReport" xml:space="preserve">
<value>问题报告方式与流程</value>
</data>
<data name="ViewGuideStepAgreementOpenSourceLicense" xml:space="preserve">
<value>Snap Hutao 开源许可</value>
</data>
<data name="ViewGuideStepAgreementPrivacyPolicy" xml:space="preserve">
<value>用户数据与隐私权益</value>
</data>
<data name="ViewGuideStepAgreementTermOfService" xml:space="preserve">
<value>用户使用协议与法律声明</value>
</data>
<data name="ViewGuideStepDocument" xml:space="preserve">
<value>文档</value>
</data>
<data name="ViewGuideStepEnvironment" xml:space="preserve">
<value>环境</value>
</data>
<data name="ViewGuideStepLanguage" xml:space="preserve">
<value>语言</value>
</data>
<data name="ViewGuideStepStaticResource" xml:space="preserve">
<value>资源</value>
</data>
<data name="ViewHutaoDatabaseHeader" xml:space="preserve">
<value>深渊统计</value>
</data>
@@ -1148,6 +1175,18 @@
<data name="ViewModelGachaLogUploadToHutaoCloudProgress" xml:space="preserve">
<value>正在上传到胡桃云服务</value>
</data>
<data name="ViewModelGuideActionAgreement" xml:space="preserve">
<value>我已阅读并同意上方的条款</value>
</data>
<data name="ViewModelGuideActionComplete" xml:space="preserve">
<value>完成</value>
</data>
<data name="ViewModelGuideActionNext" xml:space="preserve">
<value>下一步</value>
</data>
<data name="ViewModelGuideActionStaticResourceBegin" xml:space="preserve">
<value>下载资源文件中,请稍后</value>
</data>
<data name="ViewModelHutaoPassportEmailNotValidHint" xml:space="preserve">
<value>请输入正确的邮箱</value>
</data>

View File

@@ -2,27 +2,130 @@
x:Class="Snap.Hutao.View.Guide.GuideView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvg="using:Snap.Hutao.ViewModel.Guide"
d:DataContext="{d:DesignInstance shvg:GuideViewModel}"
mc:Ignorable="d">
<mxi:Interaction.Behaviors>
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
</mxi:Interaction.Behaviors>
<Grid Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<cwuc:SwitchPresenter/>
<cwuc:SwitchPresenter Value="{Binding State, Mode=OneWay}">
<cwuc:Case Value="{shcm:UInt32 Value=0}">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<GridView
ItemsSource="{Binding AppOptions.Cultures}"
SelectedItem="{Binding SelectedCulture, Mode=TwoWay}"
SelectionMode="Single">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock
Margin="16"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="{Binding Name}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
</cwuc:Case>
<cwuc:Case Value="{shcm:UInt32 Value=1}">
<Grid>
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
ColumnSpacing="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Image
Grid.Column="0"
Height="152"
Source="ms-appx:///Assets/Square44x44Logo.targetsize-256.png"/>
<StackPanel
Grid.Column="2"
VerticalAlignment="Center"
Spacing="8">
<CheckBox IsChecked="{Binding IsTermOfServiceAgreed, Mode=TwoWay}">
<TextBlock>
<TextBlock.Inlines>
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementIHaveReadText}"/>
<Hyperlink NavigateUri="https://hut.ao/statements/tos.html">
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementTermOfService}"/>
</Hyperlink>
</TextBlock.Inlines>
</TextBlock>
</CheckBox>
<CheckBox IsChecked="{Binding IsPrivacyPolicyAgreed, Mode=TwoWay}">
<TextBlock>
<TextBlock.Inlines>
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementIHaveReadText}"/>
<Hyperlink NavigateUri="https://hut.ao/statements/privacy-notice.html">
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementPrivacyPolicy}"/>
</Hyperlink>
</TextBlock.Inlines>
</TextBlock>
</CheckBox>
<CheckBox IsChecked="{Binding IsIssueReportAgreed, Mode=TwoWay}">
<TextBlock>
<TextBlock.Inlines>
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementIHaveReadText}"/>
<Hyperlink NavigateUri="https://hut.ao/statements/bug-report.html">
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementIssueReport}"/>
</Hyperlink>
</TextBlock.Inlines>
</TextBlock>
</CheckBox>
<CheckBox IsChecked="{Binding IsOpenSourceLicenseAgreed, Mode=TwoWay}">
<TextBlock>
<TextBlock.Inlines>
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementIHaveReadText}"/>
<Hyperlink NavigateUri="https://github.com/DGP-Studio/Snap.Hutao/blob/main/LICENSE">
<Run Text="{shcm:ResourceString Name=ViewGuideStepAgreementOpenSourceLicense}"/>
</Hyperlink>
</TextBlock.Inlines>
</TextBlock>
</CheckBox>
</StackPanel>
</Grid>
</Grid>
</cwuc:Case>
<cwuc:Case Value="{shcm:UInt32 Value=2}">
<Grid>
<TextBlock Text="2"/>
</Grid>
</cwuc:Case>
<cwuc:Case Value="{shcm:UInt32 Value=3}">
<Grid>
<TextBlock Text="3"/>
</Grid>
</cwuc:Case>
</cwuc:SwitchPresenter>
<Grid Grid.Row="1">
<PipsPager
HorizontalAlignment="Center"
CanBeScrollAnchor="False"
IsEnabled="False"
NumberOfPages="5"
SelectedPageIndex="0"/>
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<cwc:Segmented Margin="16" SelectedIndex="{Binding State, Mode=TwoWay}">
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewGuideStepLanguage}" Icon="{shcm:FontIcon Glyph=&#xF2B7;}"/>
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewGuideStepDocument}" Icon="{shcm:FontIcon Glyph=&#xF28B;}"/>
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewGuideStepEnvironment}" Icon="{shcm:FontIcon Glyph=&#xE81E;}"/>
<cwc:SegmentedItem Content="{shcm:ResourceString Name=ViewGuideStepStaticResource}" Icon="{shcm:FontIcon Glyph=&#xE8B9;}"/>
</cwc:Segmented>
<Button
Command="{Binding NextOrCompleteCommand}"
Content="{Binding NextOrCompleteButtonText}"
IsEnabled="{Binding IsNextOrCompleteButtonEnabled}"/>
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@@ -8,14 +8,13 @@
xmlns:mxic="using:Microsoft.Xaml.Interactions.Core"
xmlns:mxim="using:Microsoft.Xaml.Interactions.Media"
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvu="using:Snap.Hutao.ViewModel.User"
d:DataContext="{d:DesignInstance shvu:UserViewModel}"
mc:Ignorable="d">
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="Loaded">
<mxic:InvokeCommandAction Command="{Binding OpenUICommand}"/>
</mxic:EventTriggerBehavior>
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
</mxi:Interaction.Behaviors>
<StackPanel>
<Button

View File

@@ -9,9 +9,24 @@ namespace Snap.Hutao.ViewModel.Guide;
internal enum GuideState : uint
{
/// <summary>
/// 尚未开始
/// 正在选择语言
/// </summary>
None,
Language,
/// <summary>
/// 正在查看文档与隐私政策
/// </summary>
Document,
/// <summary>
/// 正在查看环境配置
/// </summary>
Environment,
/// <summary>
/// 开始下载资源
/// </summary>
StaticResourceBegin,
/// <summary>
/// 完成

View File

@@ -1,16 +1,146 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.Windows.AppLifecycle;
using Snap.Hutao.Core.Setting;
using Snap.Hutao.Model;
using Snap.Hutao.Service;
using System.Globalization;
namespace Snap.Hutao.ViewModel.Guide;
/// <summary>
/// 指引视图模型
/// </summary>
[ConstructorGenerated]
[Injection(InjectAs.Transient)]
internal sealed class GuideViewModel : Abstraction.ViewModel
internal sealed partial class GuideViewModel : Abstraction.ViewModel
{
protected override Task OpenUIAsync()
private readonly AppOptions appOptions;
private string nextOrCompleteButtonText = SH.ViewModelGuideActionNext;
private bool isNextOrCompleteButtonEnabled = true;
private NameValue<string>? selectedCulture;
private bool isTermOfServiceAgreed;
private bool isPrivacyPolicyAgreed;
private bool isIssueReportAgreed;
private bool isOpenSourceLicenseAgreed;
public uint State
{
throw new NotImplementedException();
get
{
uint value = LocalSetting.Get(SettingKeys.Major1Minor7Revision0GuideState, 0U);
GuideState state = (GuideState)value;
if (state is GuideState.Document)
{
IsTermOfServiceAgreed = false;
IsPrivacyPolicyAgreed = false;
IsIssueReportAgreed = false;
IsOpenSourceLicenseAgreed = false;
(NextOrCompleteButtonText, IsNextOrCompleteButtonEnabled) = (SH.ViewModelGuideActionNext, false);
}
else if (state is GuideState.StaticResourceBegin)
{
(NextOrCompleteButtonText, IsNextOrCompleteButtonEnabled) = (SH.ViewModelGuideActionStaticResourceBegin, false);
}
else if (state is GuideState.Completed)
{
(NextOrCompleteButtonText, IsNextOrCompleteButtonEnabled) = (SH.ViewModelGuideActionComplete, true);
}
else
{
(NextOrCompleteButtonText, IsNextOrCompleteButtonEnabled) = (SH.ViewModelGuideActionNext, true);
}
return value;
}
set
{
LocalSetting.Set(SettingKeys.Major1Minor7Revision0GuideState, value);
OnPropertyChanged();
}
}
public string NextOrCompleteButtonText { get => nextOrCompleteButtonText; set => SetProperty(ref nextOrCompleteButtonText, value); }
public bool IsNextOrCompleteButtonEnabled { get => isNextOrCompleteButtonEnabled; set => SetProperty(ref isNextOrCompleteButtonEnabled, value); }
public AppOptions AppOptions { get => appOptions; }
public NameValue<string>? SelectedCulture
{
get => selectedCulture ??= AppOptions.Cultures.FirstOrDefault(c => c.Value == AppOptions.CurrentCulture.Name);
set
{
if (SetProperty(ref selectedCulture, value) && value is not null)
{
AppOptions.CurrentCulture = CultureInfo.GetCultureInfo(value.Value);
++State;
AppInstance.Restart(string.Empty);
}
}
}
public bool IsTermOfServiceAgreed
{
get => isTermOfServiceAgreed; set
{
if (SetProperty(ref isTermOfServiceAgreed, value))
{
OnAgreeSateChanged();
}
}
}
public bool IsPrivacyPolicyAgreed
{
get => isPrivacyPolicyAgreed; set
{
if (SetProperty(ref isPrivacyPolicyAgreed, value))
{
OnAgreeSateChanged();
}
}
}
public bool IsIssueReportAgreed
{
get => isIssueReportAgreed; set
{
if (SetProperty(ref isIssueReportAgreed, value))
{
OnAgreeSateChanged();
}
}
}
public bool IsOpenSourceLicenseAgreed
{
get => isOpenSourceLicenseAgreed; set
{
if (SetProperty(ref isOpenSourceLicenseAgreed, value))
{
OnAgreeSateChanged();
}
}
}
protected override ValueTask<bool> InitializeUIAsync()
{
return ValueTask.FromResult(true);
}
[Command("NextOrCompleteCommand")]
private void NextOrComplete()
{
GuideState previousState = (GuideState)State;
++State;
}
private void OnAgreeSateChanged()
{
IsNextOrCompleteButtonEnabled = IsTermOfServiceAgreed && IsPrivacyPolicyAgreed && IsIssueReportAgreed && IsOpenSourceLicenseAgreed;
}
}