97 lines
2.8 KiB
Dart
97 lines
2.8 KiB
Dart
part of 'widgets.dart';
|
|
|
|
mixin Template {
|
|
PreferredSizeWidget buildAppBar(
|
|
String title,
|
|
BuildContext context, [
|
|
dynamic Function()? backAction,
|
|
dynamic Function()? frontAction,
|
|
]) {
|
|
final theme = FlutterFlowTheme.of(context);
|
|
return AppBar(
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
automaticallyImplyLeading: false,
|
|
title: Text(
|
|
title,
|
|
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
|
fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily,
|
|
color: FlutterFlowTheme.of(context).primaryText,
|
|
fontSize: 16.0,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).headlineMediumFamily),
|
|
),
|
|
),
|
|
leading: _backButton(context, theme, backAction),
|
|
centerTitle: true,
|
|
elevation: 0.0,
|
|
actions: _frontButton(context, theme, frontAction),
|
|
);
|
|
}
|
|
|
|
List<Widget> _frontButton(BuildContext context, FlutterFlowTheme theme,
|
|
dynamic Function()? action) {
|
|
if (action == null) return [];
|
|
return [
|
|
IconButton(
|
|
onPressed: () async => await showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text('Info'),
|
|
content: Text('This is a sample app.'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: Text('Close'))
|
|
],
|
|
)),
|
|
icon: Icon(
|
|
Symbols.info_i_rounded,
|
|
color: Colors.black,
|
|
))
|
|
];
|
|
}
|
|
|
|
Widget? _backButton(BuildContext context, FlutterFlowTheme theme,
|
|
dynamic Function()? onPressed) {
|
|
if (onPressed == null) return null;
|
|
return FlutterFlowIconButton(
|
|
key: ValueKey<String>('BackNavigationAppBar'),
|
|
borderColor: Colors.transparent,
|
|
borderRadius: 30.0,
|
|
borderWidth: 1.0,
|
|
buttonSize: 60.0,
|
|
icon: Icon(
|
|
Icons.keyboard_arrow_left,
|
|
color: theme.primaryText,
|
|
size: 30.0,
|
|
),
|
|
onPressed: onPressed,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// [PageWidget]
|
|
|
|
abstract class PageWidget<T> extends Widget {
|
|
const PageWidget({super.key});
|
|
}
|
|
|
|
abstract class ModelPage<T> extends ModelWidget implements PageWidget<T> {
|
|
const ModelPage({super.key});
|
|
}
|
|
|
|
abstract class StatelessPage<T> extends StatelessWidget
|
|
with Template
|
|
implements PageWidget<T> {
|
|
const StatelessPage({super.key});
|
|
}
|
|
|
|
abstract class StatefulPage<T> extends StatefulWidget implements PageWidget<T> {
|
|
const StatefulPage({super.key});
|
|
}
|
|
|
|
abstract class PageState<T extends StatefulPage> extends State<T>
|
|
with Template {}
|