UI javítás + beküldés, képméretezés
This commit is contained in:
@@ -2,13 +2,37 @@
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.System.SyncPage"
|
||||
Title="Adatok szinkronizálása">
|
||||
<VerticalStackLayout>
|
||||
<Button x:Name="SyncBtn" Text="Adat szinkronizálás" Clicked="OnSyncClicked" Margin="10,10,10,10" />
|
||||
<ActivityIndicator x:Name="LoadingIndicator"
|
||||
Title="Adatok szinkronizálása"
|
||||
BackgroundColor="#f0f0f0">
|
||||
<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="Adat szinkronizálás" Clicked="OnSyncClicked" Margin="10,10,10,10" />
|
||||
<ActivityIndicator x:Name="LoadingIndicator"
|
||||
IsRunning="False"
|
||||
IsVisible="False"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center" />
|
||||
</VerticalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
@@ -13,22 +13,52 @@ public partial class SyncPage : ContentPage
|
||||
|
||||
private async void OnSyncClicked(object sender, EventArgs e)
|
||||
{
|
||||
SyncBtn.IsEnabled = false;
|
||||
LoadingIndicator.IsRunning = true;
|
||||
LoadingIndicator.IsVisible = true;
|
||||
progressLabel.Text = "Szinkronizálás indítása...";
|
||||
progressBar.Progress = 0;
|
||||
|
||||
try
|
||||
{
|
||||
await _syncService.SyncDatas();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await _syncService.SyncDatas((percentage, infostring) =>
|
||||
{
|
||||
// Direkt UI frissítés
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
progressBar.Progress = percentage / 100;
|
||||
progressLabel.Text = $"{infostring}: {percentage:0.00}%";
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
throw;
|
||||
progressLabel.Text = "Szinkronizálás befejezve!";
|
||||
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;
|
||||
}
|
||||
LoadingIndicator.IsVisible = false;
|
||||
LoadingIndicator.IsRunning = false;
|
||||
|
||||
}
|
||||
|
||||
private async Task SimulateLongRunningTask(IProgress<double> progress)
|
||||
{
|
||||
int totalSteps = 50;
|
||||
for (int i = 1; i <= totalSteps; i++)
|
||||
{
|
||||
await Task.Delay(100); // Szimulált hosszú mûvelet
|
||||
double percentage = (double)i / totalSteps * 100;
|
||||
progress.Report(percentage);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnBackButtonPressed()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user