Skip to content

Commit

Permalink
fix #956
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Sep 24, 2023
1 parent ffcfb8c commit 43aebf7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
Margin="0,0,0,8"
VerticalAlignment="Top"
PlaceholderText="{shcm:ResourceString Name=ViewDialogAchievementArchiveCreateInputPlaceholder}"
Text="{x:Bind Text, Mode=TwoWay}"/>
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TextBox
VerticalAlignment="Top"
PlaceholderText="{shcm:ResourceString Name=ViewDialogCultivateProjectInputPlaceholder}"
Text="{x:Bind Text, Mode=TwoWay}"/>
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<CheckBox
Margin="0,8,0,0"
Content="{shcm:ResourceString Name=ViewDialogCultivateProjectAttachUid}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

<Grid>
<TextBox
x:Name="InputText"
Margin="0,0,0,0"
VerticalAlignment="Top"
PlaceholderText="{shcm:ResourceString Name=ViewDialogLaunchGameAccountInputPlaceholder}"/>
PlaceholderText="{shcm:ResourceString Name=ViewDialogLaunchGameAccountInputPlaceholder}"
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Snap.Hutao.View.Dialog;
/// 游戏账号命名对话框
/// </summary>
[HighQuality]
[DependencyProperty("Text", typeof(string))]
internal sealed partial class LaunchGameAccountNameDialog : ContentDialog
{
private readonly ITaskContext taskContext;
Expand All @@ -33,7 +34,6 @@ public async ValueTask<ValueResult<bool, string>> GetInputNameAsync()
{
await taskContext.SwitchToMainThreadAsync();
ContentDialogResult result = await ShowAsync();
string text = InputText.Text;
return new(result == ContentDialogResult.Primary && (!string.IsNullOrEmpty(text)), text);
return new(result == ContentDialogResult.Primary && (!string.IsNullOrEmpty(Text)), Text);
}
}
4 changes: 1 addition & 3 deletions src/Snap.Hutao/Snap.Hutao/View/Dialog/UserDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@
Title="{shcm:ResourceString Name=ViewDialogUserTitle}"
CloseButtonText="{shcm:ResourceString Name=ContentDialogCancelCloseButtonText}"
DefaultButton="Primary"
IsPrimaryButtonEnabled="False"
PrimaryButtonText="{shcm:ResourceString Name=ContentDialogConfirmPrimaryButtonText}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

<StackPanel>
<TextBox
x:Name="InputText"
Margin="0,0,0,8"
VerticalAlignment="Top"
PlaceholderText="{shcm:ResourceString Name=ViewDialogUserInputPlaceholder}"
TextChanged="InputTextChanged"/>
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<StackPanel Margin="0,0,0,0">
<StackPanel.Resources>
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
Expand Down
11 changes: 3 additions & 8 deletions src/Snap.Hutao/Snap.Hutao/View/Dialog/UserDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Snap.Hutao.View.Dialog;
Expand All @@ -9,6 +10,7 @@ namespace Snap.Hutao.View.Dialog;
/// 添加用户对话框
/// </summary>
[HighQuality]
[DependencyProperty("Text", typeof(string))]
internal sealed partial class UserDialog : ContentDialog
{
private readonly ITaskContext taskContext;
Expand All @@ -33,13 +35,6 @@ public async ValueTask<ValueResult<bool, string>> GetInputCookieAsync()
{
await taskContext.SwitchToMainThreadAsync();
ContentDialogResult result = await ShowAsync();
string cookie = InputText.Text;

return new(result == ContentDialogResult.Primary, cookie);
}

private void InputTextChanged(object sender, TextChangedEventArgs e)
{
IsPrimaryButtonEnabled = !string.IsNullOrEmpty(InputText.Text);
return new(result == ContentDialogResult.Primary && !string.IsNullOrEmpty(Text), Text);
}
}

0 comments on commit 43aebf7

Please sign in to comment.