Megy a program letöltése is...
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
Text="Mégse"
|
||||
FontSize="18"
|
||||
TextColor="White"
|
||||
HorizontalOptions="Center"
|
||||
HorizontalOptions="Fill"
|
||||
Clicked="OnCancelButtonClicked" />
|
||||
</VerticalStackLayout>
|
||||
</Frame>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.System.DownloadAPKPage"
|
||||
Title="Program letöltés">
|
||||
<ScrollView>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Frame
|
||||
Grid.Row="1"
|
||||
BorderColor="Gray"
|
||||
CornerRadius="20"
|
||||
Padding="30"
|
||||
Margin="1"
|
||||
HasShadow="True"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center"
|
||||
WidthRequest="{OnPlatform Android=350, iOS=350, WinUI=400, MacCatalyst=400}"
|
||||
MaximumWidthRequest="500">
|
||||
<VerticalStackLayout Margin="10,10,10,0">
|
||||
<Label x:Name="progressLabel" Text="Folyamatjelző" FontSize="Medium" HorizontalOptions="Center" />
|
||||
<ProgressBar x:Name="progressBar" WidthRequest="300" HeightRequest="40" />
|
||||
<Button x:Name="SyncBtn" Text="Program letöltés" Clicked="OnSyncClicked" Margin="10,10,10,10" />
|
||||
<ActivityIndicator x:Name="LoadingIndicator"
|
||||
IsRunning="False"
|
||||
IsVisible="False"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center" />
|
||||
</VerticalStackLayout>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,54 @@
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.System;
|
||||
|
||||
public partial class DownloadAPKPage : ContentPage
|
||||
{
|
||||
private ISyncService _syncService;
|
||||
public DownloadAPKPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
|
||||
}
|
||||
private async void OnSyncClicked(object sender, EventArgs e)
|
||||
{
|
||||
SyncBtn.IsEnabled = false;
|
||||
LoadingIndicator.IsRunning = true;
|
||||
LoadingIndicator.IsVisible = true;
|
||||
progressLabel.Text = "Letöltés indítása...";
|
||||
progressBar.Progress = 0;
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await _syncService.DownloadAPK((percentage, infostring) =>
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
progressBar.Progress = percentage / 100;
|
||||
progressLabel.Text = $"{infostring}: {percentage:0.00}%";
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
progressLabel.Text = "Letöltés kész!";
|
||||
await Shell.Current.GoToAsync("//MainPage");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
progressLabel.Text = $"Hiba történt: {ex.Message}";
|
||||
}
|
||||
finally
|
||||
{
|
||||
SyncBtn.IsEnabled = true;
|
||||
LoadingIndicator.IsVisible = false;
|
||||
LoadingIndicator.IsRunning = false;
|
||||
}
|
||||
}
|
||||
protected override bool OnBackButtonPressed()
|
||||
{
|
||||
Shell.Current.GoToAsync("//MainPage");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user