Add removable mock mode for a clickable preview

Runs the whole app on seeded in-memory data with no backend or device
storage, behind useMockData in lib/Grounded/mock/MockSwitch.dart. To
remove: delete lib/Grounded/mock/ and the lines tagged "MOCK:" in
ParentViewModel (or revert this commit, keeping the notification guard).

Also skips local notifications on web, where the plugin and dart:io
Platform both throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
This commit is contained in:
alvocool
2026-11-02 08:45:41 +03:00
parent 1a5867a98f
commit b31bc47cc0
7 changed files with 860 additions and 2 deletions

View File

@@ -18,6 +18,9 @@ import '../../designs/text/Text.dart';
import '../../informatics/AppDataManager.dart';
import '../../informatics/DataManager.dart';
import '../../memory/InternalMemory.dart';
import '../../mock/MockComms.dart'; // MOCK: remove with lib/Grounded/mock/
import '../../mock/MockMemory.dart'; // MOCK: remove with lib/Grounded/mock/
import '../../mock/MockSwitch.dart'; // MOCK: remove with lib/Grounded/mock/
import '../../utils/Colors.dart';
import '../system/sessionexpired/SessionExpired.dart';
import '../system/updateme/UpdateMe.dart';
@@ -41,7 +44,11 @@ class ParentViewModel extends ChangeNotifier {
ParentViewModel(this.context) {
overlayState = Overlay.of(context);
dataManager =
AppDataManager(InternalMemory(), Comms(InternalMemory()), FileStorage());
// MOCK: restore to the single real line below when removing mocks.
useMockData
? AppDataManager(MockMemory(), MockComms(), FileStorage())
: AppDataManager(
InternalMemory(), Comms(InternalMemory()), FileStorage());
}
DataManager getDataManager() {
@@ -199,6 +206,11 @@ class ParentViewModel extends ChangeNotifier {
Future<bool> hasNetwork(Function() actions) async {
closeLoading();
// MOCK: mock mode never needs a connection.
if (useMockData) {
return true;
}
List<ConnectivityResult> resultList =
await (Connectivity().checkConnectivity());