finish update button controls

This commit is contained in:
IsWaffle 2024-03-27 09:26:11 -04:00
parent 992931b15c
commit 94b7d04908
5 changed files with 55 additions and 50 deletions

View File

@ -10,17 +10,37 @@
<Panel> <Panel>
<StackPanel Orientation="Horizontal" IsVisible="False" IsEnabled="False"> <StackPanel Orientation="Horizontal">
<Button Content="Update Installer to v2.56" CornerRadius="20 0 0 20" Classes="yellow"/> <StackPanel.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="!Updating" RelativeSource="{RelativeSource AncestorType=UserControl}"/>
<Binding Path="UpdateAvailable" RelativeSource="{RelativeSource AncestorType=UserControl}"/>
</MultiBinding>
</StackPanel.IsVisible>
<Button Content="{Binding InfoText, RelativeSource={RelativeSource AncestorType=UserControl}}"
CornerRadius="20 0 0 20"
Classes="yellow"
Command="{Binding UpdateCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
<Button Content="Not now" CornerRadius="0 20 20 0" /> <Button Content="Not now" CornerRadius="0 20 20 0"
Command="{Binding DismissCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
</StackPanel> </StackPanel>
<Panel IsVisible="True" IsEnabled="True"> <Panel Margin="0 10">
<Panel.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.Or}">
<Binding Path="Updating" RelativeSource="{RelativeSource AncestorType=UserControl}"/>
<Binding Path="CheckingForUpdate" RelativeSource="{RelativeSource AncestorType=UserControl}"/>
</MultiBinding>
</Panel.IsVisible>
<ProgressBar CornerRadius="20" VerticalAlignment="Stretch" <ProgressBar CornerRadius="20" VerticalAlignment="Stretch"
Value="10" IsIndeterminate="True" Value="{Binding DownloadProgress, RelativeSource={RelativeSource AncestorType=UserControl}}"
IsIndeterminate="{Binding IsIndeterminate, RelativeSource={RelativeSource AncestorType=UserControl}}"
/> />
<Label Content="Downloading v2.56" VerticalAlignment="Center" HorizontalAlignment="Center" <Label Content="{Binding InfoText, RelativeSource={RelativeSource AncestorType=UserControl}}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Foreground="Black" FontWeight="SemiBold"/> Foreground="Black" FontWeight="SemiBold"/>
</Panel> </Panel>
</Panel> </Panel>

View File

@ -20,13 +20,13 @@ public partial class UpdateButton : UserControl
set => SetValue(InfoTextProperty, value); set => SetValue(InfoTextProperty, value);
} }
public static readonly StyledProperty<bool> ShowProperty = AvaloniaProperty.Register<UpdateButton, bool>( public static readonly StyledProperty<bool> CheckingForUpdateProperty = AvaloniaProperty.Register<UpdateButton, bool>(
"Show"); "CheckingForUpdate");
public bool Show public bool CheckingForUpdate
{ {
get => GetValue(ShowProperty); get => GetValue(CheckingForUpdateProperty);
set => SetValue(ShowProperty, value); set => SetValue(CheckingForUpdateProperty, value);
} }
public static readonly StyledProperty<ICommand> DismissCommandProperty = AvaloniaProperty.Register<UpdateButton, ICommand>( public static readonly StyledProperty<ICommand> DismissCommandProperty = AvaloniaProperty.Register<UpdateButton, ICommand>(

View File

@ -20,11 +20,11 @@ public class InstallerUpdateInfo : ReactiveObject
set => this.RaiseAndSetIfChanged(ref _updateInfoText, value); set => this.RaiseAndSetIfChanged(ref _updateInfoText, value);
} }
private bool _showCard = false; private bool _show = false;
public bool ShowCard public bool Show
{ {
get => _showCard; get => _show;
set => this.RaiseAndSetIfChanged(ref _showCard, value); set => this.RaiseAndSetIfChanged(ref _show, value);
} }
private bool _updating = false; private bool _updating = false;
@ -89,7 +89,7 @@ public class InstallerUpdateInfo : ReactiveObject
private async Task<string> DownloadNewInstaller() private async Task<string> DownloadNewInstaller()
{ {
UpdateInfoText = $"Downloading new installer v{_newVersion}"; UpdateInfoText = $"Downloading installer v{_newVersion}";
var progress = new Progress<double>(x => DownloadProgress = (int)x); var progress = new Progress<double>(x => DownloadProgress = (int)x);
@ -112,21 +112,7 @@ public class InstallerUpdateInfo : ReactiveObject
} }
UpdateInfoText = infoText; UpdateInfoText = infoText;
Show = updateAvailable;
if (!updateAvailable)
{
Task.Run(async () =>
{
// delay card dismiss
await Task.Delay(TimeSpan.FromSeconds(2));
ShowCard = updateAvailable;
});
}
else
{
ShowCard = updateAvailable;
}
CheckingForUpdates = false; CheckingForUpdates = false;
UpdateAvailable = updateAvailable; UpdateAvailable = updateAvailable;
} }
@ -137,7 +123,7 @@ public class InstallerUpdateInfo : ReactiveObject
return; return;
UpdateInfoText = "Checking for installer updates"; UpdateInfoText = "Checking for installer updates";
ShowCard = true; Show = true;
CheckingForUpdates = true; CheckingForUpdates = true;
try try
@ -172,7 +158,7 @@ public class InstallerUpdateInfo : ReactiveObject
NewInstallerUrl = latest.Assets[0].BrowserDownloadUrl; NewInstallerUrl = latest.Assets[0].BrowserDownloadUrl;
EndCheck($"Update available, version {latestVersion}", true); EndCheck($"Update available: v{latestVersion}", true);
return; return;
} }

View File

@ -220,7 +220,7 @@ public class PreChecksViewModel : ViewModelBase
StartInstallCommand = ReactiveCommand.Create(async () => StartInstallCommand = ReactiveCommand.Create(async () =>
{ {
UpdateInfo.ShowCard = false; UpdateInfo.Show = false;
NavigateTo(new InstallViewModel(HostScreen)); NavigateTo(new InstallViewModel(HostScreen));
}); });
@ -233,7 +233,7 @@ public class PreChecksViewModel : ViewModelBase
DismissUpdateCommand = ReactiveCommand.Create(() => DismissUpdateCommand = ReactiveCommand.Create(() =>
{ {
UpdateInfo.ShowCard = false; UpdateInfo.Show = false;
}); });

View File

@ -75,10 +75,10 @@
<!-- Start install button --> <!-- Start install button -->
<Button Grid.Column="2" Grid.Row="3" Padding="20 10" <Button Grid.Column="2" Grid.Row="3" Padding="20 10"
IsVisible="False" IsVisible="{Binding !UpdateInfo.Show}"
IsEnabled="{Binding AllowInstall}"
FontSize="15" FontWeight="SemiBold" FontSize="15" FontWeight="SemiBold"
Classes="yellow" Classes="yellow"
IsEnabled="{Binding AllowInstall}"
Command="{Binding StartInstallCommand}" Command="{Binding StartInstallCommand}"
CornerRadius="15" CornerRadius="15"
> >
@ -89,18 +89,17 @@
</Button> </Button>
<!-- Update installer button --> <!-- Update installer button -->
<cc:UpdateButton Grid.Column="2" Grid.Row="3" Padding="20 10"/> <cc:UpdateButton Grid.Column="2" Grid.Row="3"
IsVisible="{Binding UpdateInfo.Show}"
<!-- <cc:UpdateInfoCard Grid.Row="1" Grid.RowSpan="5" Grid.ColumnSpan="5" Padding="10" --> IsEnabled="{Binding UpdateInfo.Show}"
<!-- VerticalAlignment="Center" HorizontalAlignment="Center" --> IsIndeterminate="{Binding UpdateInfo.CheckingForUpdates}"
<!-- InfoText="{Binding UpdateInfo.UpdateInfoText}" --> InfoText="{Binding UpdateInfo.UpdateInfoText}"
<!-- ShowUpdateCard="{Binding UpdateInfo.ShowCard}" --> Updating="{Binding UpdateInfo.Updating}"
<!-- NotNowCommand="{Binding DismissUpdateCommand}" --> DismissCommand="{Binding DismissUpdateCommand}"
<!-- UpdateInstallerCommand="{Binding UpdateInstallerCommand}" --> UpdateCommand="{Binding UpdateInstallerCommand}"
<!-- Updating="{Binding UpdateInfo.Updating}" --> DownloadProgress="{Binding UpdateInfo.DownloadProgress}"
<!-- DownloadProgress="{Binding UpdateInfo.DownloadProgress}" --> UpdateAvailable="{Binding UpdateInfo.UpdateAvailable}"
<!-- IndeterminateProgress="{Binding UpdateInfo.CheckingForUpdates}" --> CheckingForUpdate="{Binding UpdateInfo.CheckingForUpdates}"
<!-- UpdateAvailable="{Binding UpdateInfo.UpdateAvailable}" --> />
<!-- /> -->
</Grid> </Grid>
</UserControl> </UserControl>