From b8ea38b951837ec93a65ae4427fb905247ab8480 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Fri, 31 Oct 2025 10:35:10 +0100 Subject: [PATCH] Use WarningCard to display offline mode --- lib/helpers/errors.dart | 4 ++-- lib/l10n/app_en.arb | 2 +- lib/widgets/core/cards.dart | 24 ++++++++++++++++++++-- lib/widgets/dashboard/widgets/network.dart | 16 ++------------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lib/helpers/errors.dart b/lib/helpers/errors.dart index aed7bc94..8f835449 100644 --- a/lib/helpers/errors.dart +++ b/lib/helpers/errors.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) 2020, 2021 wger Team + * Copyright (c) 2020, wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -277,7 +277,7 @@ class CopyToClipboardButton extends StatelessWidget { } } -void showDeleteDialog(BuildContext context, String confirmDeleteName, Log log) async { +void showDeleteLogDialog(BuildContext context, String confirmDeleteName, Log log) async { final res = await showDialog( context: context, builder: (BuildContext contextDialog) { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index b54b4695..b954b8eb 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1069,5 +1069,5 @@ "lightMode": "Always light mode", "systemMode": "System settings", "youAreOffline": "You are offline", - "offlineModeInfo": "Some features are unavailable until you reconnect to the internet. Currently, this mainly affects editing routines and nutrition plans, but logging workouts and meals works offline. The data will be synced automatically once you are back online." + "offlineModeInfo": "Some features are unavailable until you reconnect to the internet (buttons and menus will be disabled). Currently, this mainly affects editing routines and nutrition plans, but logging workouts and meals works offline. The data will be synced automatically once you are back online." } diff --git a/lib/widgets/core/cards.dart b/lib/widgets/core/cards.dart index f95b3f2f..3c56f9e3 100644 --- a/lib/widgets/core/cards.dart +++ b/lib/widgets/core/cards.dart @@ -1,6 +1,6 @@ /* * This file is part of wger Workout Manager . - * Copyright (C) wger Team + * Copyright (c) 2020, 2020- wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -31,7 +31,27 @@ class InfoCard extends StatelessWidget { color: theme.colorScheme.primaryContainer, child: ListTile( leading: Icon(Icons.info, color: theme.colorScheme.primary), - subtitle: Text(text), + title: Text(text), + ), + ); + } +} + +class WarningCard extends StatelessWidget { + final String text; + + const WarningCard({super.key, this.text = ''}); + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + + return Card( + color: theme.colorScheme.errorContainer, + child: ListTile( + dense: true, + leading: Icon(Icons.info_outline, color: theme.colorScheme.primary), + title: Text(text), ), ); } diff --git a/lib/widgets/dashboard/widgets/network.dart b/lib/widgets/dashboard/widgets/network.dart index 3738c9bf..0ec0777a 100644 --- a/lib/widgets/dashboard/widgets/network.dart +++ b/lib/widgets/dashboard/widgets/network.dart @@ -20,6 +20,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/providers/network_provider.dart'; +import 'package:wger/widgets/core/cards.dart'; class DashboardNetworkInfo extends ConsumerWidget { const DashboardNetworkInfo({super.key}); @@ -34,20 +35,7 @@ class DashboardNetworkInfo extends ConsumerWidget { : Tooltip( margin: const EdgeInsets.all(8), message: i18n.offlineModeInfo, - child: Card( - color: Theme.of(context).colorScheme.errorContainer, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisSize: MainAxisSize.max, - spacing: 8, - children: [ - const Icon(Icons.info_outline), - Text(i18n.youAreOffline), - ], - ), - ), - ), + child: WarningCard(text: i18n.youAreOffline), ); } }