2022-08-29 20:38:28 -06:00
|
|
|
import 'package:wonders/common_libs.dart';
|
|
|
|
import 'package:wonders/ui/common/app_scroll_behavior.dart';
|
|
|
|
|
2023-02-13 10:39:07 -07:00
|
|
|
class WondersAppScaffold extends StatelessWidget {
|
2024-02-20 13:56:39 -08:00
|
|
|
const WondersAppScaffold({super.key, required this.child});
|
2022-08-29 20:38:28 -06:00
|
|
|
final Widget child;
|
2023-01-01 12:27:26 -07:00
|
|
|
static AppStyle get style => _style;
|
|
|
|
static AppStyle _style = AppStyle();
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-24 15:42:27 -06:00
|
|
|
// Listen to the device size, and update AppStyle when it changes
|
2023-09-01 14:51:46 -06:00
|
|
|
final mq = MediaQuery.of(context);
|
|
|
|
appLogic.handleAppSizeChanged(mq.size);
|
2023-05-10 14:23:52 -06:00
|
|
|
// Set default timing for animations in the app
|
2023-02-13 23:24:07 -07:00
|
|
|
Animate.defaultDuration = _style.times.fast;
|
2023-05-10 14:23:52 -06:00
|
|
|
// Create a style object that will be passed down the widget tree
|
|
|
|
_style = AppStyle(screenSize: context.sizePx);
|
2023-02-16 00:33:00 -07:00
|
|
|
return KeyedSubtree(
|
2022-10-24 15:42:27 -06:00
|
|
|
key: ValueKey($styles.scale),
|
2023-02-16 00:33:00 -07:00
|
|
|
child: Theme(
|
|
|
|
data: $styles.colors.toThemeData(),
|
|
|
|
// Provide a default texts style to allow Hero's to render text properly
|
|
|
|
child: DefaultTextStyle(
|
|
|
|
style: $styles.text.body,
|
|
|
|
// Use a custom scroll behavior across entire app
|
|
|
|
child: ScrollConfiguration(
|
|
|
|
behavior: AppScrollBehavior(),
|
|
|
|
child: child,
|
2022-08-29 20:38:28 -06:00
|
|
|
),
|
|
|
|
),
|
2023-02-16 00:33:00 -07:00
|
|
|
),
|
2022-08-29 20:38:28 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|