Browse Source

Improve update settings ui state updates

pull/324/head
Ionite 1 year ago
parent
commit
4523f6fa2e
No known key found for this signature in database
  1. 34
      StabilityMatrix.Avalonia/ViewModels/Settings/UpdateSettingsViewModel.cs
  2. 17
      StabilityMatrix.Avalonia/Views/Settings/UpdateSettingsPage.axaml

34
StabilityMatrix.Avalonia/ViewModels/Settings/UpdateSettingsViewModel.cs

@ -9,6 +9,7 @@ using CommunityToolkit.Mvvm.Input;
using Exceptionless.DateTimeExtensions;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Media.Animation;
using Semver;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Services;
@ -107,7 +108,7 @@ public partial class UpdateSettingsViewModel : PageViewModelBase
accountsService.LykosAccountStatusUpdate += (_, args) =>
{
var isSelectable = args.IsPatreonConnected;
var isBetaChannelsEnabled = args.User?.IsActiveSupporter == true;
foreach (
var card in AvailableUpdateChannelCards.Where(
@ -115,7 +116,7 @@ public partial class UpdateSettingsViewModel : PageViewModelBase
)
)
{
card.IsSelectable = isSelectable;
card.IsSelectable = isBetaChannelsEnabled;
}
};
@ -171,7 +172,11 @@ public partial class UpdateSettingsViewModel : PageViewModelBase
Dispatcher.UIThread
.InvokeAsync(async () =>
{
var dialog = DialogHelper.CreateTaskDialog("Become a Supporter", "uwu");
var dialog = DialogHelper.CreateTaskDialog(
"Become a Supporter",
""
+ "Support the Stability Matrix Team and get access to early development builds and be the first to test new features. "
);
dialog.Buttons = new[]
{
@ -205,27 +210,20 @@ public partial class UpdateSettingsViewModel : PageViewModelBase
partial void OnUpdateStatusChanged(UpdateStatusChangedEventArgs? value)
{
// Update the update channel cards
// Use maximum version from platforms equal or lower than current
foreach (var card in AvailableUpdateChannelCards)
{
card.LatestVersion = value?.UpdateChannels
.GetValueOrDefault(card.UpdateChannel)
.Where(kv => kv.Key <= card.UpdateChannel)
.Select(kv => kv.Value)
.MaxBy(info => info.Version, SemVersion.PrecedenceComparer)
?.Version;
}
}
partial void OnPreferredUpdateChannelChanged(UpdateChannel oldValue, UpdateChannel newValue)
{
if (newValue == UpdateChannel.Stable)
{
return;
}
if (accountsService.LykosStatus?.User?.IsActiveSupporter == true)
{
return;
/*card.LatestVersion = value?.UpdateChannels
.GetValueOrDefault(card.UpdateChannel)
?.Version;*/
}
PreferredUpdateChannel = UpdateChannel.Stable;
}
/// <inheritdoc />

17
StabilityMatrix.Avalonia/Views/Settings/UpdateSettingsPage.axaml

@ -15,11 +15,16 @@
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels"
xmlns:vmSettings="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Settings"
xmlns:converters="clr-namespace:StabilityMatrix.Avalonia.Converters"
d:DataContext="{x:Static mocks:DesignData.UpdateSettingsViewModel}"
d:DesignHeight="550"
d:DesignWidth="800"
x:DataType="vmSettings:UpdateSettingsViewModel"
mc:Ignorable="d">
<controls:UserControlBase.Resources>
<converters:BooleanChoiceMultiConverter x:Key="BoolChoiceMultiConverter" />
</controls:UserControlBase.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="16,16,24,16" Spacing="2">
@ -84,14 +89,20 @@
<DataTemplate DataType="{x:Type models:UpdateChannelCard}">
<RadioButton
GroupName="UpdateChannel"
IsEnabled="{Binding IsSelectable}"
IsChecked="{Binding $parent[ListBoxItem].IsSelected}" >
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal" Spacing="5">
<TextBlock
IsEnabled="False"
VerticalAlignment="Center"
Text="{Binding DisplayName}" />
Text="{Binding DisplayName}">
<TextBlock.Foreground>
<MultiBinding Converter="{StaticResource BoolChoiceMultiConverter}">
<Binding Path="IsSelectable" />
<DynamicResource ResourceKey="TextFillColorPrimaryBrush"/>
<DynamicResource ResourceKey="TextFillColorTertiaryBrush"/>
</MultiBinding>
</TextBlock.Foreground>
</TextBlock>
<Ellipse
HorizontalAlignment="Left"
VerticalAlignment="Center"

Loading…
Cancel
Save