fix issue in dashboard

logut
Elham Rababah 6 years ago
parent 41c66fc8ff
commit ccea6d730f

@ -2,7 +2,6 @@ import 'package:barcode_scan/platform_wrapper.dart';
import 'package:driverapp/config/size_config.dart'; import 'package:driverapp/config/size_config.dart';
import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/enum/viewstate.dart';
import 'package:driverapp/core/model/scan_qr/scan_qr_request_model.dart'; import 'package:driverapp/core/model/scan_qr/scan_qr_request_model.dart';
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/core/viewModels/orders_view_model.dart';
import 'package:driverapp/pages/delivery/information_page.dart'; import 'package:driverapp/pages/delivery/information_page.dart';
import 'package:driverapp/pages/orders/pending_orders_page.dart'; import 'package:driverapp/pages/orders/pending_orders_page.dart';
@ -16,7 +15,6 @@ import 'package:driverapp/widgets/others/rounded_container.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../base/base_view.dart'; import '../base/base_view.dart';
@ -26,29 +24,13 @@ class DashboardScreen extends StatefulWidget {
} }
class _DashboardScreenState extends State<DashboardScreen> { class _DashboardScreenState extends State<DashboardScreen> {
bool isInit = false;
AuthenticationViewModel authenticationViewModel;
@override
void didChangeDependencies() {
if (!isInit) {
authenticationViewModel = Provider.of(context);
setState(() {
isInit = !isInit;
});
}
super.didChangeDependencies();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
int orderId; int orderId;
return BaseView<OrdersViewModel>( return BaseView<OrdersViewModel>(
onModelReady: (model) => model.getPendingOrders(), onModelReady: (model) => model.getPendingOrders(),
builder: (BuildContext context, OrdersViewModel model, Widget child) => builder: (BuildContext context, OrdersViewModel model, Widget child) =>
AppScaffold( AppScaffold(
// baseViewModel: model,
body: Container( body: Container(
height: MediaQuery.of(context).size.height * .95, height: MediaQuery.of(context).size.height * .95,
child: ListView( child: ListView(
@ -66,9 +48,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
TranslationBase TranslationBase.of(context).haveGreatDay,
.of(context)
.haveGreatDay,
style: TextStyle( style: TextStyle(
fontSize: 14.5, fontSize: 14.5,
color: Color(0xff636363), color: Color(0xff636363),
@ -77,8 +57,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
Padding( Padding(
padding: EdgeInsets.only(top: 4.5), padding: EdgeInsets.only(top: 4.5),
child: Text( child: Text(
// 'Drive Name', 'Drive Name',
authenticationViewModel.user.userName, //model.user.userName,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontSize: 25.0), fontSize: 25.0),
@ -121,22 +101,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0), padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Container( child: Container(
height: MediaQuery height: MediaQuery.of(context).orientation ==
.of(context)
.orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context).size.height * 0.16
.of(context) : MediaQuery.of(context).size.height * 0.30,
.size width: MediaQuery.of(context).size.width * 0.44,
.height * 0.16
: MediaQuery
.of(context)
.size
.height * 0.30,
width: MediaQuery
.of(context)
.size
.width * 0.44,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
gradient: LinearGradient(colors: [ gradient: LinearGradient(colors: [
@ -145,8 +114,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
]), ]),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.spaceBetween,
.spaceBetween,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Padding( child: Padding(
@ -156,9 +124,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Text( Text(
TranslationBase TranslationBase.of(context).youHave,
.of(context)
.youHave,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: fontSize:
@ -174,8 +140,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
4.0), 4.0),
), ),
Text( Text(
TranslationBase TranslationBase.of(context)
.of(context)
.undeliveredPackages, .undeliveredPackages,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
@ -201,22 +166,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
children: <Widget>[ children: <Widget>[
Image.asset( Image.asset(
'assets/images/closed_box.png', 'assets/images/closed_box.png',
height: MediaQuery height: MediaQuery.of(context)
.of(context)
.orientation == .orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.10 0.10
: MediaQuery : MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.20, 0.20,
width: MediaQuery width: MediaQuery.of(context)
.of(context)
.size .size
.width * .width *
0.20, 0.20,
@ -240,22 +201,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0), padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Container( child: Container(
height: MediaQuery height: MediaQuery.of(context).orientation ==
.of(context)
.orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context).size.height * 0.16
.of(context) : MediaQuery.of(context).size.height * 0.30,
.size width: MediaQuery.of(context).size.width * 0.45,
.height * 0.16
: MediaQuery
.of(context)
.size
.height * 0.30,
width: MediaQuery
.of(context)
.size
.width * 0.45,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
gradient: LinearGradient(colors: [ gradient: LinearGradient(colors: [
@ -264,8 +214,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
]), ]),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.spaceBetween,
.spaceBetween,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Padding( child: Padding(
@ -275,9 +224,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Text( Text(
TranslationBase TranslationBase.of(context).youHave,
.of(context)
.youHave,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: fontSize:
@ -293,8 +240,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
4.0), 4.0),
), ),
Text( Text(
TranslationBase TranslationBase.of(context)
.of(context)
.deliveredPackages, .deliveredPackages,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
@ -320,22 +266,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
children: <Widget>[ children: <Widget>[
Image.asset( Image.asset(
'assets/images/opend_box.png', 'assets/images/opend_box.png',
height: MediaQuery height: MediaQuery.of(context)
.of(context)
.orientation == .orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.10 0.10
: MediaQuery : MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.20, 0.20,
width: MediaQuery width: MediaQuery.of(context)
.of(context)
.size .size
.width * .width *
0.20, 0.20,
@ -356,29 +298,17 @@ class _DashboardScreenState extends State<DashboardScreen> {
], ],
), ),
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 15.0),
vertical: 16.0, horizontal: 15.0),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: InkWell( child: InkWell(
child: Container( child: Container(
height: MediaQuery height: MediaQuery.of(context).orientation ==
.of(context)
.orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context).size.height * 0.18
.of(context) : MediaQuery.of(context).size.height * 0.30,
.size width: MediaQuery.of(context).size.width * 0.50,
.height * 0.18
: MediaQuery
.of(context)
.size
.height * 0.30,
width: MediaQuery
.of(context)
.size
.width * 0.50,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
gradient: LinearGradient( gradient: LinearGradient(
@ -389,32 +319,21 @@ class _DashboardScreenState extends State<DashboardScreen> {
), ),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.spaceEvenly,
.spaceEvenly,
children: <Widget>[ children: <Widget>[
Column( Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Image.asset( Image.asset(
'assets/images/qr_code.png', 'assets/images/qr_code.png',
width: MediaQuery width: MediaQuery.of(context).size.width *
.of(context)
.size
.width *
0.26, 0.26,
height: MediaQuery height: MediaQuery.of(context)
.of(context)
.orientation == .orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context).size.height *
.of(context)
.size
.height *
0.14 0.14
: MediaQuery : MediaQuery.of(context).size.height *
.of(context)
.size
.height *
0.28, 0.28,
fit: BoxFit.contain, fit: BoxFit.contain,
) )
@ -423,8 +342,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Column( Column(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment crossAxisAlignment: CrossAxisAlignment.start,
.start,
children: <Widget>[ children: <Widget>[
InkWell( InkWell(
onTap: () { onTap: () {
@ -433,9 +351,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 8.0), padding: EdgeInsets.only(top: 8.0),
child: Text( child: Text(
TranslationBase TranslationBase.of(context).scan,
.of(context)
.scan,
style: TextStyle( style: TextStyle(
fontSize: fontSize:
SizeConfig.textMultiplier * 6.0, SizeConfig.textMultiplier * 6.0,
@ -448,8 +364,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Padding( Padding(
padding: EdgeInsets.only(top: 0.0), padding: EdgeInsets.only(top: 0.0),
child: Text( child: Text(
TranslationBase TranslationBase.of(context)
.of(context)
.toAddPackageToQue, .toAddPackageToQue,
style: TextStyle( style: TextStyle(
fontSize: fontSize:
@ -481,9 +396,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Column( Column(
children: <Widget>[ children: <Widget>[
Text( Text(
TranslationBase TranslationBase.of(context).nearestDropOffs,
.of(context)
.nearestDropOffs,
style: TextStyle( style: TextStyle(
fontSize: 21.0, fontSize: 21.0,
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@ -498,12 +411,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text( Text(
TranslationBase TranslationBase.of(context).seeAll,
.of(context)
.seeAll,
style: TextStyle( style: TextStyle(
fontSize: 14.5, fontSize: 14.5, color: Color(0xff42B6AD)),
color: Color(0xff42B6AD)),
), ),
Icon( Icon(
Icons.arrow_forward_ios, Icons.arrow_forward_ios,
@ -512,12 +422,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
), ),
], ],
), ),
onTap: () => onTap: () => Navigator.push(
Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) => OrdersListScreen()),
OrdersListScreen()),
), ),
), ),
], ],
@ -532,35 +440,26 @@ class _DashboardScreenState extends State<DashboardScreen> {
child: ListView.builder( child: ListView.builder(
shrinkWrap: true, shrinkWrap: true,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
itemCount: //model.orders == null ? 0 : model.orders.length, itemCount: model.orders == null
3, ? 0
: model.orders.length < 3 ? model.orders.length : 3,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: EdgeInsets.symmetric(horizontal: 12.2), padding: EdgeInsets.symmetric(horizontal: 12.2),
child: InkWell( child: InkWell(
child: RoundedContainer( child: RoundedContainer(
raduis: 25.0, raduis: 25.0,
height: MediaQuery height: MediaQuery.of(context).orientation ==
.of(context)
.orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context).size.height * 0.109
.of(context) : MediaQuery.of(context).size.height * 0.209,
.size
.height * 0.109
: MediaQuery
.of(context)
.size
.height * 0.209,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.spaceBetween,
.spaceBetween,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
flex: 1, flex: 1,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.start,
.start,
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
@ -569,31 +468,25 @@ class _DashboardScreenState extends State<DashboardScreen> {
left: 15.0, top: 14.0), left: 15.0, top: 14.0),
child: Image.asset( child: Image.asset(
'assets/images/location.png', 'assets/images/location.png',
height: MediaQuery height: MediaQuery.of(context)
.of(context)
.orientation == .orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.06 0.06
: MediaQuery : MediaQuery.of(context)
.of(context)
.size .size
.height * .height *
0.11, 0.11,
width: MediaQuery width: MediaQuery.of(context)
.of(context)
.orientation == .orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery ? MediaQuery.of(context)
.of(context)
.size .size
.width * .width *
0.05 0.05
: MediaQuery : MediaQuery.of(context)
.of(context)
.size .size
.width * .width *
0.09, 0.09,
@ -610,15 +503,12 @@ class _DashboardScreenState extends State<DashboardScreen> {
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(top: 20.0),
top: 20.0),
child: Text( child: Text(
model.orders[index].firstName + model.orders[index].firstName +
' ' + ' ' +
model.orders[index] model.orders[index].lastName,
.lastName, style: TextStyle(fontSize: 18.0),
style: TextStyle(
fontSize: 18.0),
), ),
), ),
Text( Text(
@ -636,8 +526,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
padding: EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: CircleContainer( child: CircleContainer(
child: Text( child: Text(
model.orders[index] model.orders[index].distanceInKilometers
.distanceInKilometers
.toString() + .toString() +
' K.m\naway', ' K.m\naway',
style: TextStyle( style: TextStyle(
@ -655,8 +544,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
InformationPage( InformationPage(model.orders[index])));
model.orders[index])));
}, },
), ),
); );

Loading…
Cancel
Save