mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-28 17:08:29 +01:00
Add the network information widget to regular list of dashboard widgets
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
PODS:
|
||||
- camera_avfoundation (0.0.1):
|
||||
- Flutter
|
||||
- connectivity_plus (0.0.1):
|
||||
- Flutter
|
||||
- Flutter (1.0.0)
|
||||
- flutter_keyboard_visibility (0.0.1):
|
||||
- Flutter
|
||||
@@ -12,13 +14,46 @@ PODS:
|
||||
- Flutter
|
||||
- package_info_plus (0.4.5):
|
||||
- Flutter
|
||||
- path_provider_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- pointer_interceptor_ios (0.0.1):
|
||||
- Flutter
|
||||
- powersync-sqlite-core (0.4.11)
|
||||
- powersync_flutter_libs (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- powersync-sqlite-core (~> 0.4.11)
|
||||
- rive_common (0.0.1):
|
||||
- Flutter
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- sqlite3 (3.51.1):
|
||||
- sqlite3/common (= 3.51.1)
|
||||
- sqlite3/common (3.51.1)
|
||||
- sqlite3/dbstatvtab (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3/fts5 (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3/math (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3/perf-threadsafe (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3/rtree (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3/session (3.51.1):
|
||||
- sqlite3/common
|
||||
- sqlite3_flutter_libs (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- sqlite3 (~> 3.51.1)
|
||||
- sqlite3/dbstatvtab
|
||||
- sqlite3/fts5
|
||||
- sqlite3/math
|
||||
- sqlite3/perf-threadsafe
|
||||
- sqlite3/rtree
|
||||
- sqlite3/session
|
||||
- url_launcher_ios (0.0.1):
|
||||
- Flutter
|
||||
- video_player_avfoundation (0.0.1):
|
||||
@@ -27,21 +62,32 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
|
||||
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
|
||||
- flutter_zxing (from `.symlinks/plugins/flutter_zxing/ios`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- integration_test (from `.symlinks/plugins/integration_test/ios`)
|
||||
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
|
||||
- powersync_flutter_libs (from `.symlinks/plugins/powersync_flutter_libs/darwin`)
|
||||
- rive_common (from `.symlinks/plugins/rive_common/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/darwin`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- powersync-sqlite-core
|
||||
- sqlite3
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
camera_avfoundation:
|
||||
:path: ".symlinks/plugins/camera_avfoundation/ios"
|
||||
connectivity_plus:
|
||||
:path: ".symlinks/plugins/connectivity_plus/ios"
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
flutter_keyboard_visibility:
|
||||
@@ -54,12 +100,18 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/integration_test/ios"
|
||||
package_info_plus:
|
||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||
path_provider_foundation:
|
||||
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||
pointer_interceptor_ios:
|
||||
:path: ".symlinks/plugins/pointer_interceptor_ios/ios"
|
||||
powersync_flutter_libs:
|
||||
:path: ".symlinks/plugins/powersync_flutter_libs/darwin"
|
||||
rive_common:
|
||||
:path: ".symlinks/plugins/rive_common/ios"
|
||||
shared_preferences_foundation:
|
||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||
sqlite3_flutter_libs:
|
||||
:path: ".symlinks/plugins/sqlite3_flutter_libs/darwin"
|
||||
url_launcher_ios:
|
||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||
video_player_avfoundation:
|
||||
@@ -67,15 +119,21 @@ EXTERNAL SOURCES:
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
camera_avfoundation: 5675ca25298b6f81fa0a325188e7df62cc217741
|
||||
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
|
||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||
flutter_keyboard_visibility: 4625131e43015dbbe759d9b20daaf77e0e3f6619
|
||||
flutter_zxing: e8bcc43bd3056c70c271b732ed94e7a16fd62f93
|
||||
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
|
||||
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||
pointer_interceptor_ios: da06a662d5bfd329602b45b2ab41bc0fb5fdb0f0
|
||||
powersync-sqlite-core: aae0128de5f062c8e5a6bc450090ebba0b398222
|
||||
powersync_flutter_libs: 20381b877038d27d8fa918f8c3fff08bfc3925d0
|
||||
rive_common: dd421daaf9ae69f0125aa761dd96abd278399952
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
sqlite3: 8d708bc63e9f4ce48f0ad9d6269e478c5ced1d9b
|
||||
sqlite3_flutter_libs: d13b8b3003f18f596e542bcb9482d105577eff41
|
||||
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
||||
video_player_avfoundation: dd410b52df6d2466a42d28550e33e4146928280a
|
||||
|
||||
|
||||
@@ -1129,6 +1129,7 @@
|
||||
"darkMode": "Always dark mode",
|
||||
"lightMode": "Always light mode",
|
||||
"systemMode": "System settings",
|
||||
"networkInfo": "Network information",
|
||||
"youAreOffline": "You are offline",
|
||||
"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.",
|
||||
"productNotFoundOpenFoodFacts": "You can add this product to Open Food Facts to help the community!",
|
||||
|
||||
@@ -28,6 +28,7 @@ import 'package:wger/models/user/profile.dart';
|
||||
import 'package:wger/providers/base_provider.dart';
|
||||
|
||||
enum DashboardWidget {
|
||||
networkInfo('networkInfo'),
|
||||
trophies('trophies'),
|
||||
routines('routines'),
|
||||
nutrition('nutrition'),
|
||||
|
||||
@@ -24,6 +24,7 @@ import 'package:wger/providers/user.dart';
|
||||
import 'package:wger/widgets/core/app_bar.dart';
|
||||
import 'package:wger/widgets/dashboard/calendar.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/measurements.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/network.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/nutrition.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/routines.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets/trophies.dart';
|
||||
@@ -35,9 +36,9 @@ class DashboardScreen extends StatelessWidget {
|
||||
static const routeName = '/dashboard';
|
||||
|
||||
Widget _getDashboardWidget(DashboardWidget widget) {
|
||||
// TODO: DashboardNetworkInfo(),
|
||||
|
||||
switch (widget) {
|
||||
case DashboardWidget.networkInfo:
|
||||
return const DashboardNetworkInfo();
|
||||
case DashboardWidget.routines:
|
||||
return const DashboardRoutineWidget();
|
||||
case DashboardWidget.weight:
|
||||
|
||||
@@ -78,8 +78,15 @@ class _HomeTabsScreenState extends ConsumerState<HomeTabsScreen>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Loading data here, since the build method can be called more than once
|
||||
_initialData = _loadEntries();
|
||||
// Start loading initial data after the first frame so that
|
||||
// InheritedWidgets (Localizations, MediaQuery, Providers) are
|
||||
// available. We still keep didChangeDependencies() as a
|
||||
// fallback in case dependencies change later.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
_initialData ??= _loadEntries();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -140,7 +147,7 @@ class _HomeTabsScreenState extends ConsumerState<HomeTabsScreen>
|
||||
// ref.read(weightEntryProvider);
|
||||
|
||||
// await ref.watch(workoutLogProvider.future);
|
||||
// await ref.read(workoutLogProvider.future);
|
||||
await ref.read(workoutLogProvider.future);
|
||||
|
||||
final routinesProvider = ref.read(routinesRiverpodProvider.notifier);
|
||||
final routines = ref.read(routinesRiverpodProvider);
|
||||
|
||||
@@ -30,6 +30,8 @@ class SettingsDashboardVisibility extends StatelessWidget {
|
||||
|
||||
String getTitle(DashboardWidget w) {
|
||||
switch (w) {
|
||||
case DashboardWidget.networkInfo:
|
||||
return i18n.networkInfo;
|
||||
case DashboardWidget.routines:
|
||||
return i18n.routines;
|
||||
case DashboardWidget.weight:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (c) 2020, 2020- wger Team
|
||||
* Copyright (c) 2020 - 2026 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
|
||||
|
||||
@@ -96,10 +96,11 @@ void main() {
|
||||
await tester.pumpWidget(createWidget());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Initial order: trophies, routines, nutrition, weight...
|
||||
expect(userProvider.dashboardWidgets[0], DashboardWidget.trophies);
|
||||
expect(userProvider.dashboardWidgets[1], DashboardWidget.routines);
|
||||
expect(userProvider.dashboardWidgets[2], DashboardWidget.nutrition);
|
||||
// Initial order: network info, trophies, routines, nutrition, weight...
|
||||
expect(userProvider.dashboardWidgets[0], DashboardWidget.networkInfo);
|
||||
expect(userProvider.dashboardWidgets[1], DashboardWidget.trophies);
|
||||
expect(userProvider.dashboardWidgets[2], DashboardWidget.routines);
|
||||
expect(userProvider.dashboardWidgets[3], DashboardWidget.nutrition);
|
||||
|
||||
// Find drag handle for Trophies (index 0)
|
||||
final handleFinder = find.byIcon(Icons.drag_handle);
|
||||
@@ -110,10 +111,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify order changed
|
||||
// 100px drag seems to skip 2 items (trophies moves to index 2)
|
||||
// [routines, nutrition, trophies, ...]
|
||||
expect(userProvider.dashboardWidgets[0], DashboardWidget.routines);
|
||||
expect(userProvider.dashboardWidgets[1], DashboardWidget.nutrition);
|
||||
expect(userProvider.dashboardWidgets[2], DashboardWidget.trophies);
|
||||
// 100px drag seems to skip 2 items (network moves to index 2)
|
||||
expect(userProvider.dashboardWidgets[0], DashboardWidget.trophies);
|
||||
expect(userProvider.dashboardWidgets[1], DashboardWidget.routines);
|
||||
expect(userProvider.dashboardWidgets[2], DashboardWidget.networkInfo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,11 +106,12 @@ void main() {
|
||||
|
||||
group('dashboard config', () {
|
||||
test('initial config should be default (all visible, default order)', () {
|
||||
expect(userProvider.dashboardWidgets.length, 6);
|
||||
expect(userProvider.dashboardWidgets.length, 7);
|
||||
|
||||
expect(
|
||||
userProvider.allDashboardWidgets,
|
||||
orderedEquals([
|
||||
DashboardWidget.networkInfo,
|
||||
DashboardWidget.trophies,
|
||||
DashboardWidget.routines,
|
||||
DashboardWidget.nutrition,
|
||||
@@ -166,19 +167,22 @@ void main() {
|
||||
|
||||
// assert
|
||||
// Loaded: [nutrition, routines]
|
||||
// Missing: trophies (0), weight (3), measurements (4), calendar (5)
|
||||
// 1. trophies (index 0) inserted at 0 -> [trophies, nutrition, routines]
|
||||
// 2. weight (index 3) inserted at 3 -> [trophies, nutrition, routines, weight]
|
||||
expect(newProvider.allDashboardWidgets[0], DashboardWidget.trophies);
|
||||
expect(newProvider.allDashboardWidgets[1], DashboardWidget.nutrition);
|
||||
expect(newProvider.allDashboardWidgets[2], DashboardWidget.routines);
|
||||
expect(newProvider.allDashboardWidgets[3], DashboardWidget.weight);
|
||||
// Missing: network(0), trophies (1), weight (4), measurements (5), calendar (6)
|
||||
// 1. network (index 0) inserted at 0 -> [network, trophies, nutrition, routines]
|
||||
// 2. trophies (index 1) inserted at 1 -> [network, trophies, nutrition, routines]
|
||||
// 3. weight (index 4) inserted at 4 -> [network, trophies, nutrition, routines, weight]
|
||||
expect(newProvider.allDashboardWidgets[0], DashboardWidget.networkInfo);
|
||||
expect(newProvider.allDashboardWidgets[1], DashboardWidget.trophies);
|
||||
expect(newProvider.allDashboardWidgets[2], DashboardWidget.nutrition);
|
||||
expect(newProvider.allDashboardWidgets[3], DashboardWidget.routines);
|
||||
expect(newProvider.allDashboardWidgets[4], DashboardWidget.weight);
|
||||
|
||||
// Check visibility
|
||||
expect(newProvider.isDashboardWidgetVisible(DashboardWidget.nutrition), true);
|
||||
expect(newProvider.isDashboardWidgetVisible(DashboardWidget.routines), false);
|
||||
|
||||
// Missing items should be visible by default
|
||||
expect(newProvider.isDashboardWidgetVisible(DashboardWidget.networkInfo), true);
|
||||
expect(newProvider.isDashboardWidgetVisible(DashboardWidget.weight), true);
|
||||
expect(newProvider.isDashboardWidgetVisible(DashboardWidget.trophies), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user