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.
130 lines
3.6 KiB
Dart
130 lines
3.6 KiB
Dart
import 'package:driverapp/config/config.dart';
|
|
import 'package:driverapp/core/viewModels/base_view_model.dart';
|
|
import 'package:driverapp/pages/dashboard/dashboard_screen.dart';
|
|
import 'package:driverapp/uitl/utils.dart';
|
|
import 'package:driverapp/widgets/progress_indicator/app_loader_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:gradient_app_bar/gradient_app_bar.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;
|
|
final bool isShowHomeIcon;
|
|
|
|
AppScaffold(
|
|
{@required this.body,
|
|
this.appBarTitle = '',
|
|
this.isLoading = false,
|
|
this.isShowAppBar = false,
|
|
this.baseViewModel,
|
|
this.bottomSheet,
|
|
this.titleColor,
|
|
this.arrowColor,
|
|
this.appBarColor,
|
|
this.isAppBarGradient = false,
|
|
this.isShowHomeIcon = false});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
AppGlobal.context = context;
|
|
return SafeArea(
|
|
top: false,
|
|
bottom: false,
|
|
child: Scaffold(
|
|
backgroundColor:
|
|
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)),
|
|
automaticallyImplyLeading: false,
|
|
|
|
// leading: Builder(
|
|
// builder: (BuildContext context) {
|
|
// return ArrowBack(
|
|
// arrowColor: arrowColor,
|
|
// );
|
|
// },
|
|
// ),
|
|
centerTitle: true,
|
|
actions: <Widget>[
|
|
if (isShowHomeIcon)
|
|
IconButton(
|
|
icon: Icon(FontAwesomeIcons.home),
|
|
color: Colors.white,
|
|
onPressed: () {
|
|
|
|
|
|
},
|
|
),
|
|
],
|
|
)
|
|
: isShowAppBar && isAppBarGradient
|
|
? GradientAppBar(
|
|
gradient: LINEAR_GRADIENT,
|
|
title: Text(
|
|
Utils.formatStringToPascalCase(appBarTitle),
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
automaticallyImplyLeading: false,
|
|
centerTitle: true,
|
|
actions: <Widget>[
|
|
if (isShowHomeIcon)
|
|
IconButton(
|
|
icon: Icon(FontAwesomeIcons.home),
|
|
color: Colors.white,
|
|
onPressed: () {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) =>
|
|
DashboardScreen()
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
)
|
|
: null,
|
|
body: baseViewModel != null
|
|
? NetworkBaseView(
|
|
child: buildBodyWidget(),
|
|
baseViewModel: baseViewModel,
|
|
)
|
|
: buildBodyWidget(),
|
|
bottomSheet: bottomSheet,
|
|
),
|
|
);
|
|
}
|
|
|
|
buildAppLoaderWidget(bool isLoading) {
|
|
return isLoading ? AppLoaderWidget() : Container();
|
|
}
|
|
|
|
buildBodyWidget() {
|
|
return body;
|
|
}
|
|
}
|