From 2839af658a225a01a40c056714e152f10b0d238f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 18:03:06 +0300 Subject: [PATCH] fix issues --- .../product-details/availability_info.dart | 167 ++++++++---------- .../product-details/product-detail.dart | 164 ++++++++++++++--- .../screens/product-details/reviews_info.dart | 140 ++++++++------- 3 files changed, 281 insertions(+), 190 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 34a1d454..0c00d22a 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -2,112 +2,83 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; class AvailabilityInfo extends StatelessWidget { - @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => model - .productLocationService - .length == - 0 - ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context) - .noLocationAvailable, - ), -// Text('No location Available'), - ) - : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService - .length, - itemBuilder: - (BuildContext context, - int index) { - return Padding( - padding: - EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - convertCityName( - model - .productLocationService[ - 0] - .cityName - .toString(), + onModelReady: (model) => model.getProductLocationData(), + + builder: (_, model, wi) => NetworkBaseView( + baseViewModel: model, + child: model.productLocationService.length == 0 + ? Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) + : ListView.builder( + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.productLocationService.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Image.network(model + .productLocationService[index].projectImageUrl), ), - style: TextStyle( - fontSize: - 12), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons - .location_on), - color: - Colors.red, - onPressed: - () {}, - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons - .phone), - color: - Colors.red, - onPressed: - () {}, - ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + model.productLocationService[index] + .locationDescription + + "\n" + + convertCityName( + model.productLocationService[0].cityName + .toString(), + ), + style: TextStyle(fontSize: 12), + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.location_on), + color: Colors.red, + onPressed: () {}, + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.phone), + color: Colors.red, + onPressed: () {}, + ), + ), + ], + ), + Divider(height: 1.2, color: Colors.grey) + ], ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, + ); + }, + ), ), ); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 5f596e3a..d677b9b8 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; @@ -14,6 +15,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -46,13 +48,16 @@ class ProductDetailPage extends StatefulWidget { __ProductDetailPageState createState() => __ProductDetailPageState(); } -class __ProductDetailPageState extends State { +class __ProductDetailPageState extends State + with SingleTickerProviderStateMixin { + TabController _tabController; AppSharedPreferences sharedPref = AppSharedPreferences(); bool isTrue = true; bool isDetails = true; bool isReviews = false; bool isAvailability = false; + int _activeTab = 0; checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); @@ -74,10 +79,18 @@ class __ProductDetailPageState extends State { void initState() { price = 1; specificationData = widget.product; + _tabController = TabController(length: 3, vsync: this); + userInfo(); super.initState(); } + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + void userInfo() async { print(specificationData); customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -90,6 +103,7 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery.of(context).size; return customerId != null ? DetailPageScafold( @@ -153,15 +167,87 @@ class __ProductDetailPageState extends State { SizedBox( height: 6, ), + // Container( + // height: 500, + // color: Colors.white, + // child: Scaffold( + // backgroundColor: Colors.white, + // extendBodyBehindAppBar: false, + // appBar: PreferredSize( + // preferredSize: Size.fromHeight( + // MediaQuery.of(context).size.height * 0.070), + // child: Container( + // height: MediaQuery.of(context).size.height * 0.070, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Theme.of(context).dividerColor, + // width: 0.5), //width: 0.7 + // ), + // color: Colors.white), + // child: Center( + // child: TabBar( + // isScrollable: false, + // controller: _tabController, + // // indicatorColor: Colors.transparent, + // indicatorWeight: 1.0, + // indicatorSize: TabBarIndicatorSize.tab, + // indicatorColor:Colors.green, + // labelColor: Theme.of(context).primaryColor, + // labelPadding: EdgeInsets.only( + // top: 0, left: 0, right: 0, bottom: 0), + // unselectedLabelColor: Colors.grey[800], + // tabs: [ + // tabWidget(screenSize, _activeTab == 0, + // TranslationBase.of(context).details, + // ), + // tabWidget(screenSize, _activeTab == 1, + // TranslationBase.of(context).review, + // ), + // tabWidget(screenSize, _activeTab == 2, + // TranslationBase.of(context).availability), + // ], + // ), + // ), + // ), + // ), + // body: Column( + // children: [ + // Expanded( + // child: TabBarView( + // physics: BouncingScrollPhysics(), + // controller: _tabController, + // children: [ + // DetailsInfo( + // product: widget.product, + // ), + // ReviewsInfo( + // product: widget.product, + // ), + // AvailabilityInfo() + // ], + // ), + // ), + // + // ], + // ), + // ), + // ), + + SizedBox( + height: 6, + ), + + //TODO Elham* Remove this Container( - width: 500, + // width: 500, margin: EdgeInsets.only(bottom: 6), color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ @@ -181,13 +267,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() + CustomDivider( + color: isDetails ? Colors.green : Colors.transparent, + ) ], ), SizedBox( @@ -211,13 +293,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), + CustomDivider( + color: isReviews ? Colors.green : Colors.transparent, + ), ], ), SizedBox( @@ -241,13 +319,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isAvailability - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), + CustomDivider( + color: isAvailability ? Colors.green : Colors.transparent, + ), ], ), ], @@ -795,6 +869,24 @@ class __ProductDetailPageState extends State { } } +class CustomDivider extends StatelessWidget { + const CustomDivider({ + Key key, + this.color, + }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + height: 2, + color: color, + ); + } +} + convertCityName(txt) { String stringTxt; String newTxt; @@ -828,3 +920,27 @@ deleteFromWishlistFunction(itemID) async { isInWishList = false; await x.deletWishlistData(itemID); } + +//TODO Elham* move to file +Widget tabWidget( + Size screenSize, + bool isActive, + String title, +) { + return Center( + child: Container( + height: screenSize.height * 0.070, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + title, + fontSize: SizeConfig.textMultiplier * 1.5, + // color: Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + ], + ), + ), + ); +} diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index a133fce3..ed1970cd 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -14,79 +15,82 @@ class ReviewsInfo extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getProductReviewsData(product.id), - builder: (_, model, wi) => model.productDetailService.length != 0 && - model.productDetailService[0].reviews.length != 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model.productDetailService[0].reviews[index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + builder: (_, model, wi) => NetworkBaseView( + baseViewModel:model , + child: model.productDetailService.length != 0 && + model.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model.productDetailService[0].reviews[index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), ), - ), - Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: model.productDetailService[0] - .reviews[index].rating - .toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: model.productDetailService[0] + .reviews[index].rating + .toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), ), - ), - ], + ], + ), ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index] - .reviewText, - style: TextStyle(fontSize: 20), + SizedBox( + height: 10, ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noReviewsAvailable, - ), + Container( + child: Text( + model.productDetailService[0].reviews[index] + .reviewText, + style: TextStyle(fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, + ), // Text('No Reviews Available'), - ), + ), + ), ); } }