- stubbed in button for testing locale switching, needs design polish and direction on whether the button is available at all times or just in menu - tested and fixed switching on the fly for wonder views, intro, timeline, artifacts, and menu
56 lines
1.9 KiB
Dart
56 lines
1.9 KiB
Dart
import 'package:wonders/common_libs.dart';
|
|
import 'package:wonders/ui/common/app_scroll_behavior.dart';
|
|
|
|
class WondersAppScaffold extends StatelessWidget with GetItMixin {
|
|
WondersAppScaffold({Key? key, required this.child}) : super(key: key);
|
|
final Widget child;
|
|
|
|
Future<void> _handleSwapLocale() async {
|
|
final currentLocale = settingsLogic.currentLocale.value;
|
|
final newLocale = Locale(currentLocale == 'en' ? 'zh' : 'en');
|
|
settingsLogic.currentLocale.value = newLocale.languageCode;
|
|
await localeLogic.refreshIfChanged(newLocale);
|
|
wondersLogic.init();
|
|
timelineLogic.init();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Animate.defaultDuration = $styles.times.fast;
|
|
return Stack(
|
|
children: [
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
|
|
//TODO: just some test UI to check swapping behavior, need to get finalized design and location
|
|
Align(
|
|
alignment: Alignment.topRight,
|
|
child: SafeArea(
|
|
child: TextButton(
|
|
onPressed: _handleSwapLocale,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: $styles.colors.greyStrong.withOpacity(.7),
|
|
borderRadius: BorderRadius.all(Radius.circular($styles.corners.md)),
|
|
),
|
|
padding: EdgeInsets.all($styles.insets.sm),
|
|
child: Text($strings.localeSwapButton, style: $styles.text.btn.copyWith(color: $styles.colors.white)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|