1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Hide notification read light when in a toast state

Also adds test coverage of read state and light.
This commit is contained in:
Dean Herbert 2022-09-12 15:16:45 +09:00
parent 9ef23c79ce
commit 92beb6cbe7
2 changed files with 27 additions and 4 deletions

View File

@ -219,6 +219,26 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("cancel notification", () => notification.State = ProgressNotificationState.Cancelled);
}
[Test]
public void TestReadState()
{
SimpleNotification notification = null!;
AddStep(@"post", () => notificationOverlay.Post(notification = new BackgroundNotification { Text = @"Welcome to osu!. Enjoy your stay!" }));
AddUntilStep("check is toast", () => !notification.IsInToastTray);
AddAssert("light is not visible", () => notification.ChildrenOfType<Notification.NotificationLight>().Single().Alpha == 0);
AddUntilStep("wait for forward to overlay", () => !notification.IsInToastTray);
setState(Visibility.Visible);
AddAssert("state is not read", () => !notification.Read);
AddUntilStep("light is visible", () => notification.ChildrenOfType<Notification.NotificationLight>().Single().Alpha == 1);
setState(Visibility.Hidden);
setState(Visibility.Visible);
AddAssert("state is read", () => notification.Read);
AddUntilStep("light is not visible", () => notification.ChildrenOfType<Notification.NotificationLight>().Single().Alpha == 0);
}
[Test]
public void TestBasicFlow()
{

View File

@ -75,12 +75,17 @@ namespace osu.Game.Overlays.Notifications
/// </summary>
public bool IsInToastTray
{
private get => isInToastTray;
get => isInToastTray;
set
{
isInToastTray = value;
if (!isInToastTray)
{
dragContainer.ResetPosition();
if (!Read)
Light.FadeIn(100);
}
}
}
@ -97,6 +102,7 @@ namespace osu.Game.Overlays.Notifications
{
Light = new NotificationLight
{
Alpha = 0,
Margin = new MarginPadding { Right = 5 },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
@ -239,10 +245,7 @@ namespace osu.Game.Overlays.Notifications
WasClosed = true;
if (dragContainer.FlingLeft())
{
Light.FadeOut(100);
this.FadeOut(600, Easing.In);
}
else
{
Closed?.Invoke();