Skip to content

Commit

Permalink
💾 Feat(Dashboard): Added canceled animation for ExchangeDeviceKey win…
Browse files Browse the repository at this point in the history
…dow.
  • Loading branch information
Dynesshely committed Mar 5, 2024
1 parent 53f36c5 commit 57f3146
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
4 changes: 2 additions & 2 deletions KitX Dashboard/Models/DeviceCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public override void InitCommands()
window.OnCancel(async () =>
{
window.Close();
window.Canceled();
ConstantTable.IsExchangingDeviceKey = false;
Expand All @@ -116,7 +116,7 @@ public override void InitCommands()
ViewInstances.ShowWindow(window);
EventService.OnReceiveCancelExchangingDeviceKey += () => Dispatcher.UIThread.Post(window.Close);
EventService.OnReceiveCancelExchangingDeviceKey += () => Dispatcher.UIThread.Post(() => window.Canceled());
using var http = new HttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public IActionResult ExchangeKey([FromQuery] string verifyCodeSHA1, [FromQuery]
{
var window = new ExchangeDeviceKeyWindow();
EventService.OnReceiveCancelExchangingDeviceKey += () => Dispatcher.UIThread.Post(window.Close);
EventService.OnReceiveCancelExchangingDeviceKey += () => Dispatcher.UIThread.Post(() => window.Canceled());
ViewInstances.ShowWindow(
window.OnVerificationCodeEntered(async code =>
Expand Down Expand Up @@ -119,7 +119,7 @@ public IActionResult ExchangeKey([FromQuery] string verifyCodeSHA1, [FromQuery]
}
}).OnCancel(async () =>
{
window.Close();
window.Canceled();
ConstantTable.IsExchangingDeviceKey = false;
Expand Down
8 changes: 8 additions & 0 deletions KitX Dashboard/ViewModels/ExchangeDeviceKeyWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public double SuccessedPanelOpacity
set => this.RaiseAndSetIfChanged(ref successedPanelOpacity, value);
}

private double canceledPanelOpacity = 0.0;

public double CanceledPanelOpacity
{
get => canceledPanelOpacity;
set => this.RaiseAndSetIfChanged(ref canceledPanelOpacity, value);
}

public string CurrentCodeIndex => updatingIndex.ToString();

public ObservableCollection<string> Logs { get; } = [];
Expand Down
29 changes: 27 additions & 2 deletions KitX Dashboard/Views/ExchangeDeviceKeyWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
</DoubleTransition>
</Transitions>
</Grid.Transitions>
<icon:MaterialIcon Width="50"
Height="50"
<icon:MaterialIcon Width="70"
Height="70"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Kind="CheckCircle">
Expand All @@ -156,5 +156,30 @@
</icon:MaterialIcon.Foreground>
</icon:MaterialIcon>
</Grid>
<Grid Background="{DynamicResource ThemePrimaryAccent}"
IsHitTestVisible="False"
Opacity="{Binding CanceledPanelOpacity}">
<Grid.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.3">
<DoubleTransition.Easing>
<CubicEaseInOut/>
</DoubleTransition.Easing>
</DoubleTransition>
</Transitions>
</Grid.Transitions>
<icon:MaterialIcon Width="70"
Height="70"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Kind="CloseCircle">
<icon:MaterialIcon.Foreground>
<LinearGradientBrush>
<GradientStop Offset="0" Color="#F05F57"/>
<GradientStop Offset="1" Color="#360940"/>
</LinearGradientBrush>
</icon:MaterialIcon.Foreground>
</icon:MaterialIcon>
</Grid>
</Grid>
</Window>
21 changes: 20 additions & 1 deletion KitX Dashboard/Views/ExchangeDeviceKeyWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,30 @@ public ExchangeDeviceKeyWindow ClearLogs()
return this;
}

public ExchangeDeviceKeyWindow Canceled()
{
viewModel.CanceledPanelOpacity = 1.0;

var timer = new Timer(2 * 1000);

timer.Elapsed += (_, _) =>
{
Dispatcher.UIThread.Post(Close);
timer.Stop();
timer.Dispose();
};

timer.Start();

return this;
}

public ExchangeDeviceKeyWindow Success()
{
viewModel.SuccessedPanelOpacity = 1.0;

var timer = new Timer(3 * 1000);
var timer = new Timer(2 * 1000);

timer.Elapsed += (_, _) =>
{
Expand Down

0 comments on commit 57f3146

Please sign in to comment.