Skip to content

Instantly share code, notes, and snippets.

@freelance-github
Created July 17, 2019 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freelance-github/cba2ee0a626a605b9dab03d49447687c to your computer and use it in GitHub Desktop.
Save freelance-github/cba2ee0a626a605b9dab03d49447687c to your computer and use it in GitHub Desktop.
orders management
import 'package:flutter/material.dart';
import '../packages/CIcons.dart';
import '../components/dashboard/CarouselCards.dart';
import 'package:scoped_model/scoped_model.dart';
import '../scopedModels/base.dart';
class DashboardPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => _DashboardPageState();
}
class _DashboardPageState extends State<DashboardPage> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return ScopedModelDescendant(builder: (BuildContext context, Widget child, BaseModel model) =>
Scaffold(
appBar: AppBar(
textTheme: TextTheme(title: TextStyle(color: Colors.black87)),
title: Text(model.authUser.name, style: TextStyle(fontSize: 20),),
centerTitle: true,
leading: Icon(CIcons.home, color: Colors.black,),
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0.5,
actionsIconTheme: IconThemeData(color: Colors.black87),
actions: <Widget>[
IconButton(
icon: Icon(CIcons.power_swtich),
onPressed: (){
model.logout();
},
)
],
),
body: Container(
color: Colors.white,
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Text("Statistic", style: TextStyle(color: Colors.black54,fontSize: 20)),
margin: EdgeInsets.only(top: 10, left: 10),
),
Container(
child: CarouselCards(),
),
],
),
)
)
);
}
}
/*MaterialApp(
debugShowMaterialGrid: true,
theme: ThemeData(
primarySwatch: Colors.deepOrange,
brightness: Brightness.light
),
home: Scaffold(
appBar: AppBar(
title: Text("Dashboard"),
),
body: OrdersManager(_orders)
),
)*/
/*
return CupertinoApp(
theme: CupertinoThemeData(
// primaryColor: CupertinoColors.white
),
home: CupertinoTabScaffold(tabBar: CupertinoTabBar(items: [
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.shopping_cart),
title: Text("Orders"),
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.mic_off),
title: Text("Expenses")
)
],), tabBuilder: (context, i) => CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
trailing: Icon(CupertinoIcons.search),
middle: i == 0 ? Text("Orders"): Text("Expenses"),
leading: Icon(i == 0 ? CupertinoIcons.mail: CupertinoIcons.reply_thick_solid),
),
child: Center(child: i == 0 ? Text("Orders"): Text("Expenses")),
)
),
);
*/
import 'package:flutter/material.dart';
import '../../packages/CIcons.dart';
import 'package:scoped_model/scoped_model.dart';
import '../../scopedModels/base.dart';
// child pages
import 'progress.dart';
class OrdersPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => _OrdersPage();
}
class _OrdersPage extends State<OrdersPage> with TickerProviderStateMixin {
final List<Widget> _listPages = [
ProgressPage(), // first page => 0
Text("Not Found"),
];
Widget getPage(index) {
if(_listPages.length > index) {
return _listPages[index];
}
return _listPages.last;
}
@override
Widget build(BuildContext context) {
return ScopedModelDescendant(builder: (BuildContext context, Widget child, BaseModel model) {
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: true,
snap: true,
floating: true,
automaticallyImplyLeading: false,
textTheme: TextTheme(title: TextStyle(color: Colors.black87)),
title: Text("Orders", style: TextStyle(fontSize: 20),),
centerTitle: true,
// forceElevated: innerBoxIsScrolled,
leading: Icon(CIcons.store, color: Colors.black,),
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 2,
actionsIconTheme: IconThemeData(color: Colors.black87),
actions: <Widget>[
IconButton(
icon: Icon(CIcons.search_1),
onPressed: () {
model.logout();
},
)
],
bottom: PreferredSize(
child: BottomNavigationBar(
items: _buildNavigationBarItems(),
unselectedItemColor: Colors.grey,
iconSize: 20,
selectedFontSize: 10,
unselectedFontSize: 10,
selectedItemColor: Theme
.of(context)
.primaryColor,
elevation: 1,
onTap: (int index) {
model.selectOrderPage(index);
},
currentIndex: model.selectedOrderPage,
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
showUnselectedLabels: false,
showSelectedLabels: false,
),
preferredSize: Size.fromHeight(kToolbarHeight),
),
),
];
},
body: getPage(model.selectedOrderPage)
),
// body: CustomScrollView(slivers: <Widget>[
// SliverAppBar(
// pinned: true,
// snap: true,
// floating: true,
//
// textTheme: TextTheme(title: TextStyle(color: Colors.black87)),
// title: Text("Orders", style: TextStyle(fontSize: 20),),
// centerTitle: true,
// leading: Icon(CIcons.store, color: Colors.black,),
// brightness: Brightness.light,
// backgroundColor: Colors.white,
// elevation: 2,
// actionsIconTheme: IconThemeData(color: Colors.black87),
// actions: <Widget>[
// IconButton(
// icon: Icon(CIcons.search_1),
// onPressed: (){
// model.logout();
// },
// )
// ],
//
// bottom: PreferredSize(
// child: BottomNavigationBar(
// items: _buildNavigationBarItems(),
// unselectedItemColor: Colors.grey,
// iconSize: 20,
// selectedFontSize: 10,
// unselectedFontSize: 10,
// selectedItemColor: Theme.of(context).primaryColor,
// elevation: 1,
// onTap: (int index) {
// model.selectOrderPage(index);
// },
// currentIndex: model.selectedOrderPage,
// type: BottomNavigationBarType.fixed,
// backgroundColor: Colors.white,
// showUnselectedLabels: false,
// showSelectedLabels: false,
// ),
// preferredSize: Size.fromHeight(kToolbarHeight),
// ),
// ),
// getPage(model.selectedOrderPage)
// ],
// )
);
});
}
List<BottomNavigationBarItem> _buildNavigationBarItems() {
return [
BottomNavigationBarItem(
icon: Icon(CIcons.list),
title: Text("Progress")
),
BottomNavigationBarItem(
icon: Icon(CIcons.phone),
title: Text("No replay"),
),
BottomNavigationBarItem(
icon: Icon(CIcons.undo),
title: Text("Refuased"),
),
BottomNavigationBarItem(
icon: Icon(CIcons.map_marker),
title: Text("Out Of Range"),
),
BottomNavigationBarItem(
icon: Icon(CIcons.paper_plane),
title: Text("Approved"),
),
];
}
}
/*
bottom: TabBar(
controller: _tabController,
tabs: <Tab>[
Tab(icon: Icon(CIcons.list),),
Tab(icon: Icon(CIcons.phone_handset),),
],
labelColor: Theme.of(context).primaryColor,
isScrollable: false,
indicator: BoxDecoration(
color: Colors.grey[100]
),
unselectedLabelColor: Colors.black45,
onTap: (int currentPage) {
setState(() {
_currentPage = currentPage;
});
},
),
TabBarView(
physics: ScrollPhysics(parent: ScrollPhysics()),
children: childPages,
controller: _tabController,
)
*/
/*
new Scaffold(
body: new NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverAppBar(
title: new Text(widget.title),
pinned: true,
floating: true,
forceElevated: innerBoxIsScrolled,
bottom: new TabBar(
tabs: <Tab>[
new Tab(text: "STATISTICS"),
new Tab(text: "HISTORY"),
],
controller: _tabController,
),
),
];
},
body: new TabBarView(
children: <Widget>[
new StatisticsPage(),
new HistoryPage(),
],
controller: _tabController,
),
),
);
ScopedModelDescendant(builder: (BuildContext context, Widget child, BaseModel model) =>Scaffold(
appBar: AppBar(
textTheme: TextTheme(title: TextStyle(color: Colors.black87)),
title: Text("Orders", style: TextStyle(fontSize: 20),),
centerTitle: true,
leading: Icon(CIcons.store, color: Colors.black,),
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0.5,
actionsIconTheme: IconThemeData(color: Colors.black87),
actions: <Widget>[
IconButton(
icon: Icon(CIcons.search_1),
onPressed: (){
model.logout();
},
)
],
bottom: PreferredSize(
child: BottomNavigationBar(
items: _buildNavigationBarItems(),
unselectedItemColor: Colors.grey,
iconSize: 20,
selectedFontSize: 10,
unselectedFontSize: 10,
selectedItemColor: Theme.of(context).primaryColor,
elevation: 1,
onTap: (int index) {
model.selectOrderPage(index);
},
currentIndex: model.selectedOrderPage,
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
showUnselectedLabels: false,
showSelectedLabels: false,
),
preferredSize: Size.fromHeight(kToolbarHeight),
),
),
body: getPage(model.selectedOrderPage)
)
)
*/
import 'package:flutter/material.dart';
import '../../packages/CIcons.dart';
import 'dart:async';
import 'package:scoped_model/scoped_model.dart';
import '../../scopedModels/base.dart';
class ProgressPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => _ProgressPageState();
}
class _ProgressPageState extends State<ProgressPage> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return _orderDetailCard();
},
itemCount: 10,
padding: EdgeInsets.all(8),
);
}
Widget _orderDetailCard() {
return Container(
// padding: EdgeInsets.only(bottom: 4,),
child: Card(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Abderrazzak oxa", style: TextStyle(fontSize: 18, fontFamily: 'Poppins-Medium')),
Row(children: <Widget>[
SizedBox(width: 5,),
Icon(CIcons.map_marker, size: 12,),
SizedBox(width: 5,),
Text("Hay Takadoum El Koalea Ait Melloul", style: TextStyle(color: Theme.of(context).textTheme.headline.color, fontSize: 12,),)
],)
]),
),
InkWell(
child: Container(
child: Icon(CIcons.phone_handset, size: 18,),
padding: EdgeInsets.all(5),
),
onTap: (){
final snackBar = SnackBar(content: Text("Tap"), action: SnackBarAction(label: "Okay", onPressed: (){}),);
Scaffold.of(context).showSnackBar(snackBar);
},
)
],
),
SizedBox(height: 10,),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text("3.", style: TextStyle(color: Colors.black, fontSize: 12),),
SizedBox(width: 2,),
Text("Notebook 1442", style: TextStyle(color: Colors.black87, fontSize: 12),),
SizedBox(width: 5,),
Text("200 DH", style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 12),),
],
),
SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
InkWell(
onTap: (){},
child: Text("View more", style: TextStyle(fontSize: 12),),
),
Row(
children: <Widget>[
Icon(CIcons.calendar, size: 9, color: Colors.black45,),
SizedBox(width: 3,),
Text("Des, 25 19", style: TextStyle(color: Colors.black45, fontSize: 12),)
],
)
],
)
],
)
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment