mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Apply NRT to LoginForm
and remove nullability of IAPIProvider
This commit is contained in:
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
@ -23,19 +21,19 @@ namespace osu.Game.Overlays.Login
|
|||||||
{
|
{
|
||||||
public class LoginForm : FillFlowContainer
|
public class LoginForm : FillFlowContainer
|
||||||
{
|
{
|
||||||
private TextBox username;
|
private TextBox username = null!;
|
||||||
private TextBox password;
|
private TextBox password = null!;
|
||||||
private ShakeContainer shakeSignIn;
|
private ShakeContainer shakeSignIn = null!;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
public Action RequestHide;
|
public Action? RequestHide;
|
||||||
|
|
||||||
private void performLogin()
|
private void performLogin()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
||||||
api?.Login(username.Text, password.Text);
|
api.Login(username.Text, password.Text);
|
||||||
else
|
else
|
||||||
shakeSignIn.Shake();
|
shakeSignIn.Shake();
|
||||||
}
|
}
|
||||||
@ -57,7 +55,7 @@ namespace osu.Game.Overlays.Login
|
|||||||
{
|
{
|
||||||
PlaceholderText = UsersStrings.LoginUsername.ToLower(),
|
PlaceholderText = UsersStrings.LoginUsername.ToLower(),
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Text = api?.ProvidedUsername ?? string.Empty,
|
Text = api.ProvidedUsername,
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
password = new OsuPasswordTextBox
|
password = new OsuPasswordTextBox
|
||||||
@ -110,17 +108,17 @@ namespace osu.Game.Overlays.Login
|
|||||||
Text = "Register",
|
Text = "Register",
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
RequestHide();
|
RequestHide?.Invoke();
|
||||||
accountCreation.Show();
|
accountCreation.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
forgottenPaswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, "https://osu.ppy.sh/home/password-reset");
|
forgottenPaswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset");
|
||||||
|
|
||||||
password.OnCommit += (_, _) => performLogin();
|
password.OnCommit += (_, _) => performLogin();
|
||||||
|
|
||||||
if (api?.LastLoginError?.Message is string error)
|
if (api.LastLoginError?.Message is string error)
|
||||||
errorText.AddErrors(new[] { error });
|
errorText.AddErrors(new[] { error });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user