Skip to content

Commit

Permalink
Merge branch 'main' into prod/festapp
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Nov 21, 2024
2 parents ece2006 + 29c7824 commit 41d732f
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 14 deletions.
4 changes: 4 additions & 0 deletions assets/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Nainstaluj si aplikaci {title}, aby ti mohly chodit notifikace, aby aplikace mohla fungovat i offline, a aby se dala spustit přes ikonku.",
"Click here to sign in.": "Klikni sem pro přihlášení.",
"Failed to invite {user}. Number of retries: ({retries}).": "Nepodařilo se pozvat {user}. Počet pokusů: ({retries}).",
"Processing...": "Zpracovává se...",
"The processing has finished with error.": "Zpracování skončilo chybou.",
"The processing has been cancelled.": "Zpracování bylo zrušeno.",
"The processing has completed successfully.": "Zpracování bylo úspěšně dokončeno.",
"_": "_"
}
4 changes: 4 additions & 0 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Installiere {title}, um Benachrichtigungen zu erhalten, offline zu arbeiten und eine Schnellstart-Icon zu nutzen.",
"Click here to sign in.": "Klicke hier, um dich anzumelden.",
"Failed to invite {user}. Number of retries: ({retries}).": "Es konnte nicht eingeladen werden: {user}. Anzahl der Versuche: ({retries}).",
"Processing...": "Verarbeitung läuft...",
"The processing has finished with error.": "Die Verarbeitung wurde mit einem Fehler abgeschlossen.",
"The processing has been cancelled.": "Die Verarbeitung wurde abgebrochen.",
"The processing has completed successfully.": "Die Verarbeitung wurde erfolgreich abgeschlossen.",
"_": "_"
}
4 changes: 4 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Install {title} to get notifications, offline functionality, and a quick launch icon.",
"Click here to sign in.": "Click here to sign in.",
"Failed to invite {user}. Number of retries: ({retries}).": "Failed to invite {user}. Number of retries: ({retries}).",
"Processing...": "Processing...",
"The processing has finished with error.": "The processing has finished with error.",
"The processing has been cancelled.": "The processing has been cancelled.",
"The processing has completed successfully.": "The processing has completed successfully.",
"_":"_"
}
4 changes: 4 additions & 0 deletions assets/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Zainstaluj aplikację {title}, aby otrzymywać powiadomienia, korzystać z funkcji offline i mieć szybki dostęp przez ikonę.",
"Click here to sign in.": "Kliknij tutaj, aby się zalogować.",
"Failed to invite {user}. Number of retries: ({retries}).": "Nie udało się zaprosić {user}. Liczba prób: ({retries}).",
"Processing...": "Przetwarzanie...",
"The processing has finished with error.": "Przetwarzanie zakończyło się błędem.",
"The processing has been cancelled.": "Przetwarzanie zostało anulowane.",
"The processing has completed successfully.": "Przetwarzanie zakończyło się pomyślnie.",
"_": "_"
}
4 changes: 4 additions & 0 deletions assets/translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Nainštaluj si aplikáciu {title}, aby ti mohli chodiť notifikácie, aby aplikácia mohla fungovať aj offline, a aby sa dala spustiť cez ikonu.",
"Click here to sign in.": "Klikni sem pre prihlásenie.",
"Failed to invite {user}. Number of retries: ({retries}).": "Nepodarilo sa pozvať {user}. Počet pokusov: ({retries}).",
"Processing...": "Spracováva sa...",
"The processing has finished with error.": "Spracovanie skončilo chybou.",
"The processing has been cancelled.": "Spracovanie bolo zrušené.",
"The processing has completed successfully.": "Spracovanie bolo úspešne dokončené.",
"_": "_"
}
4 changes: 4 additions & 0 deletions assets/translations/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"Install {title} to get notifications, offline functionality, and a quick launch icon.": "Встанови {title}, щоб отримувати сповіщення, працювати офлайн і мати швидкий доступ через іконку.",
"Click here to sign in.": "Натисни тут, щоб увійти.",
"Failed to invite {user}. Number of retries: ({retries}).": "Не вдалося запросити {user}. Кількість спроб: ({retries}).",
"Processing...": "Обробка...",
"The processing has finished with error.": "Обробка завершилася з помилкою.",
"The processing has been cancelled.": "Обробку було скасовано.",
"The processing has completed successfully.": "Обробку успішно завершено.",
"_": "_"
}
1 change: 1 addition & 0 deletions lib/pages/AdministrationOccasion/UsersTab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class _UsersTabState extends State<UsersTab> {
print(
"Retrying to invite user: ${user.data![Tb.occasion_users.data_email]}. Attempt: ${retryAttempts[user]}");
}
await Future.delayed(Duration(milliseconds: 500));
}
}
};
Expand Down
97 changes: 83 additions & 14 deletions lib/services/DialogHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:fstapp/appConfig.dart';

import 'package:flutter/material.dart';
import 'package:cross_file/cross_file.dart';
import 'package:fstapp/themeConfig.dart';
import 'package:fstapp/widgets/PasswordField.dart';
import 'package:search_page/search_page.dart';
import 'package:select_dialog/select_dialog.dart';
Expand Down Expand Up @@ -316,6 +317,11 @@ class DialogHelper{
}) async {
final completer = Completer<void>();
final progressNotifier = ValueNotifier<int>(0);
final isCancelled = ValueNotifier<bool>(false); // Track cancellation state
final statusMessage = ValueNotifier<String>(""); // Track status message
final isStornoActive = ValueNotifier<bool>(true); // Track Storno button state
final isOkActive = ValueNotifier<bool>(false); // Track Ok button state
bool hasError = false; // Track if any error occurred

// Show the dialog
showDialog(
Expand All @@ -333,17 +339,65 @@ class DialogHelper{
Text("${"Progress".tr()}: $progress/$total"),
SizedBox(height: 20),
LinearProgressIndicator(value: total > 0 ? progress / total : 0),
if (progress >= total)
...[
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
completer.complete();
SizedBox(height: 20),
ValueListenableBuilder<String>(
valueListenable: statusMessage,
builder: (context, message, _) {
return Text(
message,
style: TextStyle(
color: hasError
? ThemeConfig.redColor(context)
: ThemeConfig.blackColor(context),
),
textAlign: TextAlign.center,
);
},
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center, // Center the row
children: [
ValueListenableBuilder<bool>(
valueListenable: isStornoActive,
builder: (context, isActive, _) {
return SizedBox(
width: 100, // Set equal width for both buttons
child: ElevatedButton(
onPressed: isActive
? () {
isCancelled.value = true; // Mark as cancelled
isStornoActive.value = false; // Disable Storno
isOkActive.value = true; // Enable Ok button
statusMessage.value =
"The processing has been cancelled.".tr(); // Update status
}
: null,
child: Text("Storno".tr()),
),
);
},
),
SizedBox(width: 20), // Add space between buttons
ValueListenableBuilder<bool>(
valueListenable: isOkActive,
builder: (context, isActive, _) {
return SizedBox(
width: 100, // Set equal width for both buttons
child: ElevatedButton(
onPressed: isActive
? () {
Navigator.of(context).pop();
completer.complete();
}
: null,
child: Text("Ok".tr()),
),
);
},
child: Text("Ok".tr()),
),
],
),
],
),
);
Expand All @@ -353,22 +407,37 @@ class DialogHelper{
);

// Execute futures sequentially
if (futures !=null && futures.isNotEmpty) {
if (futures != null && futures.isNotEmpty) {
for (var future in futures) {
if (isCancelled.value) break; // Stop execution if cancelled
try {
statusMessage.value = "Processing...".tr(); // Update processing message
await future.call(); // Wait for each future to finish
progressNotifier.value++;
if(delay!=null){
if (delay != null) {
await Future.delayed(delay);
}
} catch (e) {
ToastHelper.Show(context, e.toString(), severity: ToastSeverity.NotOk);
// On error: Stop further execution and display the error
statusMessage.value = "$e";
isCancelled.value = true; // Stop further processing
isStornoActive.value = false; // Disable Storno button
isOkActive.value = true; // Enable Ok button
hasError = true; // Mark that an error occurred
break;
}
}
}

// Mark actions as completed
isOkActive.value = true; // Enable Ok button after actions are completed
isStornoActive.value = false; // Disable Storno button whenever Ok is enabled
if (hasError) {
statusMessage.value = "The processing has finished with error.".tr();
} else if (isCancelled.value) {
statusMessage.value = "The processing has been cancelled.".tr();
} else {
// Complete immediately if no futures are provided
completer.complete();
Navigator.of(context).pop();
statusMessage.value = "The processing has completed successfully.".tr();
}

// Await the completer if not already completed
Expand Down

0 comments on commit 41d732f

Please sign in to comment.