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

Loading…
Cancel
Save