1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-02 08:56:54 +01:00

48 lines
1.2 KiB
Dart
Raw Normal View History

2019-10-02 14:58:11 +08:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:provider/provider.dart';
class CommonScaffold extends StatelessWidget {
final Widget title;
final Widget body;
2021-05-16 15:16:35 +08:00
final Widget? action;
final PreferredSizeWidget? bottom;
2019-10-02 14:58:11 +08:00
CommonScaffold({
2021-05-16 15:16:35 +08:00
required this.title,
required this.body,
2019-10-02 14:58:11 +08:00
this.action,
this.bottom,
});
@override
Widget build(BuildContext context) {
2019-11-08 17:24:00 +08:00
final theme = Provider.of<ThemeModel>(context);
2020-01-16 12:45:04 +08:00
// FIXME: A hack to get brightness before MaterialApp been built
theme.setSystemBrightness(MediaQuery.of(context).platformBrightness);
2019-11-08 17:24:00 +08:00
switch (theme.theme) {
2019-10-02 14:58:11 +08:00
case AppThemeType.cupertino:
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: title,
trailing: action,
),
child: SafeArea(child: body),
);
default:
return Scaffold(
appBar: AppBar(
title: title,
actions: [
2021-05-16 15:16:35 +08:00
if (action != null) action!,
2019-10-02 14:58:11 +08:00
],
bottom: bottom,
),
body: body,
);
}
}
}