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.
mohemm-flutter-app/lib/core/base/app_scaffold_widget.dart

116 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:queuing_system/core/base/project_view_model.dart';
import 'package:queuing_system/widget/app_loader_widget.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
import 'base_view_model.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 backgroundColor;
final Widget appBar;
final Widget drawer;
final Widget bottomNavigationBar;
final String subtitle;
final bool isHomeIcon;
final bool extendBody;
AppScaffold(
{this.appBarTitle = '',
this.body,
this.isLoading = false,
this.isShowAppBar = true,
this.baseViewModel,
this.bottomSheet,
this.backgroundColor,
this.isHomeIcon = true,
this.appBar,
this.subtitle,
this.drawer,
this.extendBody = false,
this.bottomNavigationBar});
@override
Widget build(BuildContext context) {
ProjectViewModel projectProvider = Provider.of(context);
return GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: Scaffold(
backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor
,
drawer: drawer,
extendBody: extendBody,
bottomNavigationBar: bottomNavigationBar,
appBar: isShowAppBar
? appBar ??
AppBar(
elevation: 0,
backgroundColor: Colors.white,
//HexColor('#515B5D'),
textTheme: TextTheme(
headline6: TextStyle(
color: Colors.black87,
fontSize: 16.8,
)),
title: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(appBarTitle.toUpperCase()),
if (subtitle != null)
Text(
subtitle,
style: TextStyle(fontSize: 12, color: Colors.red),
),
],
),
leading: Builder(builder: (BuildContext context) {
return IconButton(
icon: Icon(Icons.arrow_back_ios),
color: Colors.black, //Colors.black,
onPressed: () => Navigator.pop(context),
);
}),
centerTitle: true,
actions: <Widget>[
],
)
: null,
bottomSheet: bottomSheet,
body: projectProvider.isInternetConnection
? baseViewModel != null
? NetworkBaseView(
baseViewModel: baseViewModel,
child: body,
)
: Stack(
children: <Widget>[body, buildAppLoaderWidget(isLoading)])
: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/images/undraw_connected_world_wuay.png",
height: 250,
),
AppText('No Internet Connection')
],
),
),
),
);
}
Widget buildAppLoaderWidget(bool isLoading) {
return isLoading ? AppLoaderWidget() : Container();
}
}