wonders/lib/ui/app_scaffold.dart

36 lines
1.2 KiB
Dart

import 'package:wonders/common_libs.dart';
import 'package:wonders/ui/common/app_scroll_behavior.dart';
class WondersAppScaffold extends StatelessWidget {
const WondersAppScaffold({Key? key, required this.child}) : super(key: key);
final Widget child;
static AppStyle get style => _style;
static AppStyle _style = AppStyle();
@override
Widget build(BuildContext context) {
// Listen to the device size, and update AppStyle when it changes
MediaQuery.of(context);
appLogic.handleAppSizeChanged();
// Set default timing for animations in the app
Animate.defaultDuration = _style.times.fast;
// Create a style object that will be passed down the widget tree
_style = AppStyle(screenSize: context.sizePx);
return KeyedSubtree(
key: ValueKey($styles.scale),
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,
),
),
),
);
}
}