提交 d14dac9d 编写于 作者: R Richasy

调整用户账户显示

上级 6a2f66f2
......@@ -10,7 +10,7 @@
d:DesignWidth="400"
mc:Ignorable="d">
<Grid>
<Grid ToolTipService.ToolTip="{x:Bind ViewModel.TipText, Mode=OneWay}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Common">
<VisualState x:Name="NormalState" />
......@@ -24,6 +24,7 @@
</VisualStateManager.VisualStateGroups>
<local:UserAvatar
x:Name="UserAvatar"
AutomationProperties.Name="{x:Bind ViewModel.TipText, Mode=OneWay}"
Width="{x:Bind Width, Mode=OneWay}"
Height="{x:Bind Height, Mode=OneWay}"
Avatar="{x:Bind ViewModel.Avatar, Mode=OneWay}"
......
......@@ -204,6 +204,9 @@
<data name="Persional" xml:space="preserve">
<value>个人</value>
</data>
<data name="PleaseSignIn" xml:space="preserve">
<value>请登录</value>
</data>
<data name="QRCodeExpired" xml:space="preserve">
<value>二维码已过期,请刷新</value>
</data>
......
......@@ -63,6 +63,7 @@ namespace Richasy.Bili.Models.Enums
FailedToLoadQRCode,
QRCodeExpired,
LoginFailed,
PleaseSignIn,
#pragma warning restore SA1602 // Enumeration items should be documented
}
}
......@@ -3,6 +3,7 @@
using System;
using ReactiveUI.Fody.Helpers;
using Richasy.Bili.Controller.Uwp;
using Richasy.Bili.Toolkit.Interfaces;
namespace Richasy.Bili.ViewModels.Uwp
{
......@@ -33,6 +34,7 @@ namespace Richasy.Bili.ViewModels.Uwp
public partial class AccountViewModel
{
private readonly BiliController _controller;
private readonly IResourceToolkit _resourceToolkit;
/// <summary>
/// <see cref="AccountViewModel"/>的实例.
......@@ -56,5 +58,11 @@ namespace Richasy.Bili.ViewModels.Uwp
/// </summary>
[Reactive]
public string DisplayName { get; set; }
/// <summary>
/// 工具提示及自动化文本.
/// </summary>
[Reactive]
public string TipText { get; set; }
}
}
......@@ -4,7 +4,9 @@ using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Richasy.Bili.Controller.Uwp;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Models.BiliBili;
using Richasy.Bili.Models.Enums;
namespace Richasy.Bili.ViewModels.Uwp
{
......@@ -24,6 +26,8 @@ namespace Richasy.Bili.ViewModels.Uwp
_controller.LoggedOut += OnLoggedOut;
_controller.AccountChanged += OnAccountChanged;
Status = AccountViewModelStatus.Logout;
ServiceLocator.Instance.LoadService(out _resourceToolkit);
TipText = _resourceToolkit.GetLocaleString(LanguageNames.PleaseSignIn);
}
/// <summary>
......@@ -57,6 +61,7 @@ namespace Richasy.Bili.ViewModels.Uwp
private void OnLoggedOut(object sender, EventArgs e)
{
this.Status = AccountViewModelStatus.Logout;
TipText = _resourceToolkit.GetLocaleString(LanguageNames.PleaseSignIn);
}
private void OnLoggedFailed(object sender, Exception e)
......@@ -85,6 +90,7 @@ namespace Richasy.Bili.ViewModels.Uwp
{
Avatar = e.Avatar;
DisplayName = e.Name;
TipText = $"{e.Name} Lv.{e.Level}";
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册