You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.1 KiB
Dart
110 lines
3.1 KiB
Dart
import 'package:driverapp/config/config.dart';
|
|
import 'package:driverapp/core/viewModels/base_view_model.dart';
|
|
import 'package:driverapp/uitl/utils.dart';
|
|
import 'package:driverapp/widgets/progress_indicator/app_loader_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:gradient_app_bar/gradient_app_bar.dart';
|
|
|
|
import 'arrow_back.dart';
|
|
import 'network_base_view.dart';
|
|
|
|
class AppScaffold extends StatelessWidget {
|
|
final String appBarTitle;
|
|
final Widget body;
|
|
final bool isLoading;
|
|
final bool isShowAppBar;
|
|
final BaseViewModel baseViewModel;
|
|
final Widget bottomSheet;
|
|
final Color titleColor;
|
|
final Color arrowColor;
|
|
final Color appBarColor;
|
|
final bool isAppBarGradient;
|
|
|
|
AppScaffold(
|
|
{@required this.body,
|
|
this.appBarTitle = '',
|
|
this.isLoading = false,
|
|
this.isShowAppBar = false,
|
|
this.baseViewModel,
|
|
this.bottomSheet,
|
|
this.titleColor,
|
|
this.arrowColor,
|
|
this.appBarColor,
|
|
this.isAppBarGradient});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
AppGlobal.context = context;
|
|
return SafeArea(
|
|
top: false,
|
|
bottom: false,
|
|
child: Scaffold(
|
|
backgroundColor:
|
|
appBarColor ?? Theme.of(context).scaffoldBackgroundColor,
|
|
appBar: isShowAppBar && !isAppBarGradient
|
|
? AppBar(
|
|
elevation: 0,
|
|
backgroundColor: Theme
|
|
.of(context)
|
|
.appBarTheme
|
|
.color,
|
|
textTheme: TextTheme(
|
|
headline6: TextStyle(
|
|
color: titleColor ?? Colors.white,
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
title: Text(Utils.formatStringToPascalCase(appBarTitle)),
|
|
leading: Builder(
|
|
builder: (BuildContext context) {
|
|
return ArrowBack(
|
|
arrowColor: arrowColor,
|
|
);
|
|
},
|
|
),
|
|
centerTitle: true,
|
|
// actions: <Widget>[
|
|
// IconButton(
|
|
// icon: Icon(FontAwesomeIcons.home),
|
|
// color: Colors.white,
|
|
// onPressed: () {
|
|
// // TODO add navigator to home page
|
|
// },
|
|
// ),
|
|
// ],
|
|
)
|
|
: isShowAppBar && isAppBarGradient ? GradientAppBar(
|
|
|
|
gradient: LINEAR_GRADIENT,
|
|
title: Text(
|
|
Utils.formatStringToPascalCase(appBarTitle),
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
centerTitle: true,
|
|
leading: Builder(
|
|
builder: (BuildContext context) {
|
|
return ArrowBack(
|
|
arrowColor: arrowColor,
|
|
);
|
|
},
|
|
)
|
|
) : null,
|
|
body: baseViewModel != null
|
|
? NetworkBaseView(
|
|
child: buildBodyWidget(),
|
|
baseViewModel: baseViewModel,
|
|
)
|
|
: buildBodyWidget(),
|
|
bottomSheet: bottomSheet,
|
|
),
|
|
);
|
|
}
|
|
|
|
buildAppLoaderWidget(bool isLoading) {
|
|
return isLoading ? AppLoaderWidget() : Container();
|
|
}
|
|
|
|
buildBodyWidget() {
|
|
return body;
|
|
}
|
|
}
|