Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
okmika committed Jun 15, 2024
2 parents 47df8f3 + 32c4bc9 commit 665b95c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
73 changes: 50 additions & 23 deletions src/Tkmm.Launcher/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Windowing;
using Tkmm.Core.Components;
using Tkmm.Core.Helpers;
Expand Down Expand Up @@ -40,36 +42,61 @@ public ShellViewModel(ShellView view)
private async Task Primary()
{
if (PrimaryText is INSTALL or UPDATE) {
if (OperatingSystem.IsWindows()) {
_view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Indeterminate);

try {
await Install();
}

await Task.Run(async () => {
Progress = 10;
await AppManager.Update((progress) => Progress = progress);
await AssetHelper.Download();
Progress = 98;
});

if (InstallShortcuts) {
AppManager.CreateDesktopShortcuts();
catch (Exception ex) {
ContentDialog dialog = new() {
Title = ex.GetType().Name,
Content = ex.Message,
PrimaryButtonCommand = new RelayCommand(async () => {
await (_view.Clipboard?.SetTextAsync($"""
```
{ex}
```
""") ?? Task.CompletedTask);
}),
PrimaryButtonText = "Copy",
SecondaryButtonText = "Dismiss",
DefaultButton = ContentDialogButton.Primary
};

await dialog.ShowAsync();
}
}
else {
AppManager.Start();
}
}

AppManager.CreateProtocol();
private async Task Install()
{
if (OperatingSystem.IsWindows()) {
_view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Indeterminate);

Progress = 100;
}

if (OperatingSystem.IsWindows()) {
_view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Normal);
_view.PlatformFeatures.SetTaskBarProgressBarValue(0, 0);
}
await Task.Run(async () => {
Progress = 10;
await AppManager.Update((progress) => Progress = progress);
await AssetHelper.Download();
Progress = 98;
});

PrimaryText = LAUNCH;
if (InstallShortcuts) {
AppManager.CreateDesktopShortcuts();
}
else {
AppManager.Start();

AppManager.CreateProtocol();

Progress = 100;

if (OperatingSystem.IsWindows()) {
_view.PlatformFeatures.SetTaskBarProgressBarState(TaskBarProgressBarState.Normal);
_view.PlatformFeatures.SetTaskBarProgressBarValue(0, 0);
}

PrimaryText = LAUNCH;
}

[RelayCommand]
Expand Down
2 changes: 1 addition & 1 deletion src/Tkmm/Views/Pages/HomePageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
VerticalAlignment="Stretch"
Command="{Binding RemoveCommand}"
ToolTip.Tip="Remove Mod">
<pi:Icon Value="fa-solid fa-trash" />
<pi:Icon Value="fa-regular fa-trash" />
</Button>
<Button Margin="2.5"
VerticalAlignment="Stretch"
Expand Down
4 changes: 2 additions & 2 deletions src/Tkmm/Views/Pages/ProfilesPageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
VerticalAlignment="Stretch"
Command="{Binding RemoveCommand}"
ToolTip.Tip="Remove Mod">
<pi:Icon Value="fa-solid fa-trash" />
<pi:Icon Value="fa-regular fa-trash" />
</Button>
<Button Margin="2.5"
VerticalAlignment="Stretch"
Expand Down Expand Up @@ -152,7 +152,7 @@
Command="{Binding $parent[UserControl].DataContext.UninstallCommand}"
CommandParameter="{Binding}"
ToolTip.Tip="Uninstall">
<pi:Icon Value="fa-solid fa-trash" />
<pi:Icon Value="fa-solid fa-trash-xmark" />
</Button>
</Grid>
</DataTemplate>
Expand Down

0 comments on commit 665b95c

Please sign in to comment.