Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
73
lib/Peach/configs/Navigator.dart
Normal file
73
lib/Peach/configs/Navigator.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:page_transition/page_transition.dart';
|
||||
|
||||
import '../about/internal/application/NavigatorType.dart';
|
||||
|
||||
/// Every screen transition in the app funnels through here. Destinations are
|
||||
/// widget instances, not route names — there is no route table. Keeping one
|
||||
/// choke point means a guard (session, device, connectivity) can be applied to
|
||||
/// all routing by editing a single method.
|
||||
class PeachNavigation {
|
||||
void navigateToPage(NavigatorType type, dynamic path, BuildContext context) {
|
||||
_runSec(context, type, path);
|
||||
}
|
||||
|
||||
Future _runSec(BuildContext context, NavigatorType type, dynamic path) async {
|
||||
switch (type) {
|
||||
case NavigatorType.openFully:
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (BuildContext context) => path),
|
||||
);
|
||||
break;
|
||||
case NavigatorType.justOpen:
|
||||
Navigator.push(
|
||||
context,
|
||||
PageTransition(
|
||||
type: PageTransitionType.size,
|
||||
alignment: Alignment.center,
|
||||
opaque: true,
|
||||
child: path,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case NavigatorType.replaceCurrent:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
PageTransition(
|
||||
type: PageTransitionType.scale,
|
||||
alignment: Alignment.center,
|
||||
opaque: true,
|
||||
curve: Curves.ease,
|
||||
duration: const Duration(microseconds: 9000),
|
||||
child: path,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case NavigatorType.makeNewMain:
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
PageTransition(
|
||||
type: PageTransitionType.fade,
|
||||
alignment: Alignment.center,
|
||||
opaque: true,
|
||||
child: path,
|
||||
),
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens [path] and returns whatever it pops with — the reload-on-return
|
||||
/// channel: a child calls `Navigator.pop(context, true)` and the parent
|
||||
/// refreshes on a truthy result.
|
||||
Future<dynamic> navigateToPageWithData(
|
||||
dynamic path,
|
||||
BuildContext context,
|
||||
) async {
|
||||
return await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => path),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
lib/Peach/configs/ThemeController.dart
Normal file
23
lib/Peach/configs/ThemeController.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// App-wide theme mode. `main.dart` listens to this and rebuilds MaterialApp;
|
||||
/// any screen can set it. Persisting the choice is the ViewModel's job — this
|
||||
/// only carries the live value.
|
||||
class ThemeController {
|
||||
ThemeController._();
|
||||
|
||||
static final ValueNotifier<ThemeMode> mode = ValueNotifier<ThemeMode>(
|
||||
ThemeMode.dark,
|
||||
);
|
||||
|
||||
/// The stored string ('dark' | 'light' | 'system') for the current mode.
|
||||
static String get name => mode.value.name;
|
||||
|
||||
static void apply(String stored) {
|
||||
mode.value = switch (stored) {
|
||||
'light' => ThemeMode.light,
|
||||
'system' => ThemeMode.system,
|
||||
_ => ThemeMode.dark,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user