From d47e1c2a43fa085337f78ed908937152e58cf227 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 9 Sep 2020 11:08:51 +0300 Subject: [PATCH 1/2] add splash_screen_page --- lib/main.dart | 7 +- lib/pages/dashboard/dashboard_screen.dart | 278 ++++++++++++--------- lib/pages/orders/deliverd_orders_page.dart | 6 +- lib/pages/orders/pending_orders_page.dart | 9 +- lib/pages/splash_screen_page.dart | 150 +++++++++++ lib/widgets/others/rounded_container.dart | 60 +++-- pubspec.yaml | 2 + 7 files changed, 359 insertions(+), 153 deletions(-) create mode 100644 lib/pages/splash_screen_page.dart diff --git a/lib/main.dart b/lib/main.dart index 2036786..8449b2e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,4 @@ -import 'package:driverapp/root_page.dart'; +import 'package:driverapp/pages/splash_screen_page.dart'; import 'package:driverapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -81,8 +81,9 @@ class MyApp extends StatelessWidget { ), ), ), - initialRoute: '/', - routes: {'/': (context) => RootPage()}, + home: SplashScreenPage(), +// initialRoute: '/', +// routes: {'/': (context) => RootPage()}, debugShowCheckedModeBanner: false, ), ), diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 867ddaa..6952710 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -5,6 +5,7 @@ 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/deliverd_orders_page.dart'; import 'package:driverapp/pages/orders/pending_orders_page.dart'; import 'package:driverapp/pages/setting/setting.dart'; import 'package:driverapp/uitl/app_toast.dart'; @@ -18,7 +19,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; -import 'package:driverapp/pages/orders/deliverd_orders_page.dart'; import '../base/base_view.dart'; @@ -355,12 +355,26 @@ class _DashboardScreenState extends State { children: [ Expanded( child: InkWell( + onTap: () { + _scanQrAndGetPatient(context, model); + }, child: Container( - 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, + 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, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15.0), gradient: LinearGradient( @@ -381,50 +395,50 @@ class _DashboardScreenState extends State { width: MediaQuery.of(context).size.width * 0.26, height: MediaQuery.of(context) - .orientation == - Orientation.portrait + .orientation == + Orientation.portrait ? MediaQuery.of(context).size.height * - 0.14 + 0.14 : MediaQuery.of(context).size.height * - 0.28, + 0.28, fit: BoxFit.contain, ) ], ), Column( mainAxisAlignment: - MainAxisAlignment.spaceEvenly, + MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ - InkWell( - onTap: () { - _scanQrAndGetPatient(context, model); - }, - child: Padding( - padding: EdgeInsets.only(top: 8.0), - child: Text( - TranslationBase.of(context).scan, - style: TextStyle( - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape - ? SizeConfig.textMultiplier * 6.0 - : SizeConfig.textMultiplier * 4.0, - color: Colors.white, - fontWeight: FontWeight.w400, - ), + Padding( + padding: EdgeInsets.only(top: 8.0), + child: Text( + TranslationBase + .of(context) + .scan, + style: TextStyle( + fontSize: MediaQuery + .of(context) + .orientation == + Orientation.landscape + ? SizeConfig.textMultiplier * 6.0 + : SizeConfig.textMultiplier * 4.0, + color: Colors.white, + fontWeight: FontWeight.w400, ), ), ), Padding( padding: EdgeInsets.only(top: 0.0), child: Text( - TranslationBase.of(context) + TranslationBase + .of(context) .toAddPackageToQue, style: TextStyle( - fontSize: MediaQuery.of(context) - .orientation == - Orientation.landscape + fontSize: MediaQuery + .of(context) + .orientation == + Orientation.landscape ? SizeConfig.textMultiplier * 3.0 : SizeConfig.textMultiplier * 2.0, color: Colors.white, @@ -505,107 +519,129 @@ class _DashboardScreenState extends State { return Padding( padding: EdgeInsets.symmetric(horizontal: 12.2), child: InkWell( - child: RoundedContainer( - raduis: 25.0, - height: MediaQuery.of(context).orientation == - Orientation.portrait - ? MediaQuery.of(context).size.height * 0.120 - : MediaQuery.of(context).size.height * 0.209, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - left: 15.0, top: 14.0), - child: Image.asset( - 'assets/images/location.png', - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .height * - 0.06 - : MediaQuery.of(context) - .size - .height * - 0.11, - width: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .width * - 0.05 - : MediaQuery.of(context) - .size - .width * - 0.09, - ), - ) - ], - ), - ), - if (model.orders.length != 0) + child: Container( + child: RoundedContainer( + showShadow: true, + raduis: 25.0, + height: MediaQuery + .of(context) + .orientation == + Orientation.portrait + ? MediaQuery + .of(context) + .size + .height * 0.120 + : MediaQuery + .of(context) + .size + .height * 0.209, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ Expanded( - flex: 5, + flex: 1, child: Column( + mainAxisAlignment: + MainAxisAlignment.start, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only(top: 20.0), - child: Text( - model.orders[index].firstName + - ' ' + - model.orders[index].lastName, - style: TextStyle(fontSize: 18.0), + padding: EdgeInsets.only( + left: 15.0, top: 14.0), + child: Image.asset( + 'assets/images/location.png', + height: MediaQuery + .of(context) + .orientation == + Orientation.portrait + ? MediaQuery + .of(context) + .size + .height * + 0.06 + : MediaQuery + .of(context) + .size + .height * + 0.11, + width: MediaQuery + .of(context) + .orientation == + Orientation.portrait + ? MediaQuery + .of(context) + .size + .width * + 0.05 + : MediaQuery + .of(context) + .size + .width * + 0.09, ), - ), - Text( - model.orders[index].mobileNumber, - style: TextStyle( - color: Color(0xff30B7B9), - fontWeight: FontWeight.w600, - fontSize: 15.0, + ) + ], + ), + ), + if (model.orders.length != 0) + Expanded( + flex: 5, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(top: 20.0), + child: Text( + model.orders[index].firstName + + ' ' + + model.orders[index].lastName, + style: TextStyle( + fontSize: 18.0, + color: Hexcolor("#343333"), + fontWeight: FontWeight.bold), + ), ), - ), - Expanded( - child: Text( - model.orders[index].orderID - .toString(), + Text( + model.orders[index].mobileNumber, style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.w400, - letterSpacing: 8.0), + color: Color(0xff30B7B9), + fontWeight: FontWeight.w600, + fontSize: 15.0, + ), ), - ), - ], + Expanded( + child: Text( + model.orders[index].orderID + .toString(), + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.w400, + letterSpacing: 8.0), + ), + ), + ], + ), ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: CircleContainer( - borderWidth: 0.9, - child: Text( - model.orders[index].distanceInKilometers - .toString() + - '\nK.m\naway', - style: TextStyle( - color: Color(0xff42B6AD), - fontWeight: FontWeight.w800, - fontStyle: FontStyle.normal), + Padding( + padding: EdgeInsets.all(8.0), + child: CircleContainer( + borderWidth: 0.9, + child: Text( + model.orders[index].distanceInKilometers + .toString() + + '\nK.m\naway', + style: TextStyle( + color: Color(0xff42B6AD), + fontWeight: FontWeight.w800, + fontStyle: FontStyle.normal), + ), ), ), - ), - ], + ], + ), ), ), onTap: () { diff --git a/lib/pages/orders/deliverd_orders_page.dart b/lib/pages/orders/deliverd_orders_page.dart index db4119f..7ea5dd3 100644 --- a/lib/pages/orders/deliverd_orders_page.dart +++ b/lib/pages/orders/deliverd_orders_page.dart @@ -6,6 +6,7 @@ import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:driverapp/widgets/others/rounded_container.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; import '../base/base_view.dart'; @@ -86,7 +87,10 @@ class _DeliverdOrdersPageState extends State { model.orders[index].firstName + ' ' + model.orders[index].lastName, - style: TextStyle(fontSize: 18.0), + style: TextStyle( + fontSize: 18.0, + color: Hexcolor("#343333"), + fontWeight: FontWeight.bold), ), ), Text( diff --git a/lib/pages/orders/pending_orders_page.dart b/lib/pages/orders/pending_orders_page.dart index 50eb090..423a543 100644 --- a/lib/pages/orders/pending_orders_page.dart +++ b/lib/pages/orders/pending_orders_page.dart @@ -1,11 +1,13 @@ import 'package:driverapp/core/viewModels/orders_view_model.dart'; import 'package:driverapp/pages/delivery/information_page.dart'; +import 'package:driverapp/uitl/translations_delegate_base.dart'; import 'package:driverapp/widgets/data_display/circle-container.dart'; import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:driverapp/widgets/others/rounded_container.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:driverapp/uitl/translations_delegate_base.dart'; +import 'package:hexcolor/hexcolor.dart'; + import '../base/base_view.dart'; class OrdersListScreen extends StatefulWidget { @@ -85,7 +87,10 @@ class _OrdersListScreenState extends State { model.orders[index].firstName + ' ' + model.orders[index].lastName, - style: TextStyle(fontSize: 18.0), + style: TextStyle( + fontSize: 18.0, + color: Hexcolor("#343333"), + fontWeight: FontWeight.bold), ), ), Text( diff --git a/lib/pages/splash_screen_page.dart b/lib/pages/splash_screen_page.dart new file mode 100644 index 0000000..68f766d --- /dev/null +++ b/lib/pages/splash_screen_page.dart @@ -0,0 +1,150 @@ +import 'dart:async'; + +import 'package:driverapp/app-icons/driver_app_icons.dart'; +import 'package:driverapp/core/viewModels/project_view_model.dart'; +import 'package:driverapp/root_page.dart'; +import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SplashScreenPage extends StatefulWidget { + @override + _SplashScreenPageState createState() => _SplashScreenPageState(); +} + +class _SplashScreenPageState extends State { + startTime() async { + var _duration = new Duration(seconds: 2); + return new Timer(_duration, navigationPage); + } + + @override + void initState() { + super.initState(); + startTime(); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return AppScaffold( + isShowAppBar: false, + appBarColor: Color(0xff30B7B9), + body: SingleChildScrollView( + child: Center( + child: Column( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + FractionallySizedBox( + widthFactor: 0.80, + child: Column( + children: [ + SizedBox( + height: 200, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Icon( + DriverApp.logo, + size: 110, + color: Colors.white, + ), + margin: EdgeInsets.only( + right: projectViewModel.isArabic + ? 0 + : MediaQuery.of(context).size.width * 0.15, + left: !projectViewModel.isArabic + ? 0 + : MediaQuery.of(context).size.width * 0.15), + ), + ], + ), + SizedBox( + height: 20, + ), + Column( + children: [ + Text( + "Driver", + style: TextStyle( + fontSize: 70, + fontWeight: FontWeight.bold, + color: Colors.white), + ), + Text( + "Delivery", + style: TextStyle( + fontSize: 50, + letterSpacing: 1, + color: Colors.white), + ), + Text( + "APP", + style: TextStyle( + fontSize: 53, + letterSpacing: 53, + color: Colors.white, + fontWeight: FontWeight.w400), + ), + ], + ), + SizedBox( + height: 280, + ) + ], + ), + ), + Center( + child: FractionallySizedBox( + widthFactor: 0.80, + child: Column( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Expanded( + child: Center( + child: Text( + "Powered by Cloud Solutions", + style: TextStyle( + fontSize: 13, color: Colors.white), + ), + ), + ), + SizedBox( + height: 10, + ) + ], + ), + ), + ], + ), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } + + void navigationPage() { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => RootPage(), + ), + ); + } +} diff --git a/lib/widgets/others/rounded_container.dart b/lib/widgets/others/rounded_container.dart index 93dc6cc..3bdcab9 100644 --- a/lib/widgets/others/rounded_container.dart +++ b/lib/widgets/others/rounded_container.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; class RoundedContainer extends StatefulWidget { final double width; @@ -16,6 +17,7 @@ class RoundedContainer extends StatefulWidget { final double bottomLeft; final Widget child; final double borderWidth; + final bool showShadow; RoundedContainer( {@required this.child, @@ -32,12 +34,14 @@ class RoundedContainer extends StatefulWidget { this.topRight = 0, this.bottomRight = 0, this.bottomLeft = 0, - this.borderWidth = 1}); + this.borderWidth = 1, + this.showShadow = true}); @override _RoundedContainerState createState() => _RoundedContainerState(); } + class _RoundedContainerState extends State { @override Widget build(BuildContext context) { @@ -45,36 +49,40 @@ class _RoundedContainerState extends State { width: widget.width, height: widget.height, margin: EdgeInsets.all(widget.margin), - decoration: widget.showBorder == true - ? BoxDecoration( - color: Theme.of(context).primaryColor, - border: Border.all( - color: widget.borderColor, width: widget.borderWidth), - borderRadius: widget.customCornerRaduis - ? BorderRadius.only( - topLeft: Radius.circular(widget.topLeft), - topRight: Radius.circular(widget.topRight), - bottomRight: Radius.circular(widget.bottomRight), - bottomLeft: Radius.circular(widget.bottomLeft)) - : BorderRadius.circular(widget.raduis), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.1), - spreadRadius: 10, - blurRadius: 5, - offset: Offset(0, 5), // changes position of shadow - ), - ]) - : null, + decoration: + BoxDecoration( + color: Theme + .of(context) + .primaryColor, + + border: widget.showBorder == true ? Border.all( + color: widget.borderColor, width: widget.borderWidth) : null, + borderRadius: widget.customCornerRaduis + ? BorderRadius.only( + topLeft: Radius.circular(widget.topLeft), + topRight: Radius.circular(widget.topRight), + bottomRight: Radius.circular(widget.bottomRight), + bottomLeft: Radius.circular(widget.bottomLeft)) + : BorderRadius.circular(widget.raduis), + + boxShadow: widget.showShadow ? [ + BoxShadow( + color: Hexcolor("#DBE5E6"), + spreadRadius: 15, + blurRadius: 15, + offset: Offset(0, 7), // changes position of shadow + ), + ] : []) + , child: Card( margin: EdgeInsets.all(0), shape: RoundedRectangleBorder( borderRadius: widget.customCornerRaduis ? BorderRadius.only( - topLeft: Radius.circular(widget.topLeft), - topRight: Radius.circular(widget.topRight), - bottomRight: Radius.circular(widget.bottomRight), - bottomLeft: Radius.circular(widget.bottomLeft)) + topLeft: Radius.circular(widget.topLeft), + topRight: Radius.circular(widget.topRight), + bottomRight: Radius.circular(widget.bottomRight), + bottomLeft: Radius.circular(widget.bottomLeft)) : BorderRadius.circular(widget.raduis), ), color: widget.backgroundColor, diff --git a/pubspec.yaml b/pubspec.yaml index 778cf11..193eabc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -78,6 +78,8 @@ dependencies: + + dev_dependencies: flutter_test: sdk: flutter From ae8af0ab434a9065e8a5a172f5ff7a754c016a18 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 9 Sep 2020 11:38:57 +0300 Subject: [PATCH 2/2] Fix 2 loader inside the dashboard_screen --- lib/pages/dashboard/dashboard_screen.dart | 48 +++++++++++------------ lib/pages/splash_screen_page.dart | 2 +- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/lib/pages/dashboard/dashboard_screen.dart b/lib/pages/dashboard/dashboard_screen.dart index 6952710..19d4ef3 100644 --- a/lib/pages/dashboard/dashboard_screen.dart +++ b/lib/pages/dashboard/dashboard_screen.dart @@ -457,25 +457,23 @@ class _DashboardScreenState extends State { ], ), ), - NetworkBaseView( - baseViewModel: model, - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - children: [ - Text( - TranslationBase.of(context).nearestDropOffs, - style: TextStyle( - fontSize: 21.0, - fontWeight: FontWeight.w400, - ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Text( + TranslationBase.of(context).nearestDropOffs, + style: TextStyle( + fontSize: 21.0, + fontWeight: FontWeight.w400, ), - ], - ), + ), + ], + ), + if (model.state == ViewState.Idle) Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -494,16 +492,16 @@ class _DashboardScreenState extends State { ), ], ), - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => OrdersListScreen()), - ), + onTap: () => + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OrdersListScreen()), + ), ), ], ), - ], - ), + ], ), ), NetworkBaseView( diff --git a/lib/pages/splash_screen_page.dart b/lib/pages/splash_screen_page.dart index 68f766d..038b982 100644 --- a/lib/pages/splash_screen_page.dart +++ b/lib/pages/splash_screen_page.dart @@ -14,7 +14,7 @@ class SplashScreenPage extends StatefulWidget { class _SplashScreenPageState extends State { startTime() async { - var _duration = new Duration(seconds: 2); + var _duration = new Duration(seconds: 1); return new Timer(_duration, navigationPage); }