optimize Scaffold widget and make options customized
parent
973d40135a
commit
a14e1489fe
@ -1,31 +0,0 @@
|
|||||||
import '../lookups/home_items_lookup.dart';
|
|
||||||
import '../routes.dart';
|
|
||||||
|
|
||||||
import '../widgets/home/home_item.dart';
|
|
||||||
import '../widgets/shared/app.drawer.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text('Home'),
|
|
||||||
),
|
|
||||||
drawer: AppDrawer(),
|
|
||||||
body: GridView(
|
|
||||||
padding: EdgeInsets.all(25),
|
|
||||||
children: DUMMY_CATEGORIES
|
|
||||||
.map((data) =>
|
|
||||||
HomeItem(data.id, data.title, data.image, data.link))
|
|
||||||
.toList(),
|
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
|
||||||
maxCrossAxisExtent: 200,
|
|
||||||
childAspectRatio: 3 / 2,
|
|
||||||
crossAxisSpacing: 20,
|
|
||||||
mainAxisSpacing: 20)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import '../../routes.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import '../../i18n/ar.i18n.dart' as ar;
|
|
||||||
import '../../i18n/en.i18n.dart' as en;
|
|
||||||
|
|
||||||
class AppDrawer extends StatelessWidget {
|
|
||||||
ar.Ar arLang = ar.Ar();
|
|
||||||
en.En enLang = en.En();
|
|
||||||
|
|
||||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
|
||||||
// final SharedPreferences prefs = await _prefs;
|
|
||||||
|
|
||||||
Future<void> getCounter() async {
|
|
||||||
final SharedPreferences prefs = await _prefs;
|
|
||||||
final int counter = (prefs.getInt('counter') ?? 0);
|
|
||||||
print("dddddd" + prefs.getInt('counter').toString());
|
|
||||||
// setState(() {
|
|
||||||
// prefs.setInt("counter", counter).then((bool success) {
|
|
||||||
// print(counter);
|
|
||||||
// return counter;
|
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
print(arLang.button.save);
|
|
||||||
print(enLang.button.save);
|
|
||||||
getCounter();
|
|
||||||
return Drawer(
|
|
||||||
child: Column(
|
|
||||||
children: <Widget>[
|
|
||||||
AppBar(
|
|
||||||
title: Text('Hi form Elham!!'),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text('Home'),
|
|
||||||
leading: Icon(Icons.tab),
|
|
||||||
onTap: () {
|
|
||||||
drawerNavigator(context, HOME);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text('My Schedule'),
|
|
||||||
leading: Icon(Icons.tab),
|
|
||||||
onTap: () {
|
|
||||||
drawerNavigator(context, MY_SCHEDULE);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text('Settings'),
|
|
||||||
leading: Icon(Icons.settings),
|
|
||||||
onTap: () {
|
|
||||||
drawerNavigator(context, SETTINGS);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text('QR Reader'),
|
|
||||||
leading: Icon(Icons.photo),
|
|
||||||
onTap: () {
|
|
||||||
drawerNavigator(context, QR_READER);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Divider(),
|
|
||||||
ListTile(
|
|
||||||
title: Text('Log Out'),
|
|
||||||
leading: Icon(Icons.exit_to_app),
|
|
||||||
onTap: () {
|
|
||||||
drawerNavigator(context, LOGIN);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawerNavigator(context, routeName) {
|
|
||||||
Navigator.of(context).pushNamed(routeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
import '../../presentation/doctor_app_icons.dart';
|
||||||
|
import '../../widgets/shared/app_drawer_widget.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppScaffold extends StatelessWidget {
|
||||||
|
AppScaffold(
|
||||||
|
{this.pageOnly,
|
||||||
|
this.appBarTitle,
|
||||||
|
this.showAppBar,
|
||||||
|
this.showBottomBar,
|
||||||
|
this.showAppDrawer,
|
||||||
|
this.body});
|
||||||
|
bool pageOnly = false;
|
||||||
|
// bool showAll =
|
||||||
|
bool showAppBar = true;
|
||||||
|
bool showAppDrawer = true;
|
||||||
|
bool showBottomBar = true;
|
||||||
|
String appBarTitle;
|
||||||
|
Widget body;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: (pageOnly == true || showAppBar == false)?null:AppBar(
|
||||||
|
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Colors.red[100],
|
||||||
|
textTheme: TextTheme(
|
||||||
|
title: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)),
|
||||||
|
title: Text(appBarTitle),
|
||||||
|
leading: Builder(builder: (BuildContext context) {
|
||||||
|
return new GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Scaffold.of(context).openDrawer();
|
||||||
|
},
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.menu),
|
||||||
|
color: Colors.black,
|
||||||
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
centerTitle: true,
|
||||||
|
actions: <Widget>[
|
||||||
|
IconButton(icon: Icon(Icons.person), onPressed: null)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
drawer: (pageOnly == true || showAppDrawer == false)?null:Theme(
|
||||||
|
data: Theme.of(context).copyWith(
|
||||||
|
canvasColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: SafeArea(child: AppDrawer()),
|
||||||
|
),
|
||||||
|
// ,
|
||||||
|
bottomNavigationBar: (pageOnly == true || showBottomBar == false)?null: BottomNavigationBar(items: [
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(DoctorApp.home_icon),
|
||||||
|
title: Text('Home'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
activeIcon: Icon(Icons.home)),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: new Icon(Icons.mail),
|
||||||
|
title: new Text('Messages'),
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(icon: Icon(Icons.apps), title: Text('Menu'))
|
||||||
|
]),
|
||||||
|
body: body,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue