From 1789eb8c5b43a7cf72ff3d6b1c977f9559e93f60 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 24 Jan 2022 13:07:40 +0200 Subject: [PATCH] first step form redesign pharmacy page --- .../medicine/pharmacies_list_screen.dart | 367 ++++++++++-------- 1 file changed, 210 insertions(+), 157 deletions(-) diff --git a/lib/screens/medicine/pharmacies_list_screen.dart b/lib/screens/medicine/pharmacies_list_screen.dart index a9e21274..4c0c27ea 100644 --- a/lib/screens/medicine/pharmacies_list_screen.dart +++ b/lib/screens/medicine/pharmacies_list_screen.dart @@ -1,21 +1,28 @@ import 'dart:convert'; import 'dart:typed_data'; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../locator.dart'; + DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); class PharmaciesListScreen extends StatefulWidget { @@ -42,158 +49,98 @@ class _PharmaciesListState extends State { builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: TranslationBase.of(context).pharmaciesList, - body: Container( - height: SizeConfig.screenHeight, - child: ListView( - shrinkWrap: true, - scrollDirection: Axis.vertical, - physics: const AlwaysScrollableScrollPhysics(), - children: [ - model.pharmaciesList.length > 0 - ? RoundedContainer( - child: Row( - children: [ - Expanded( - flex: 1, - child: ClipRRect( - borderRadius: - BorderRadius.all(Radius.circular(7)), - child: widget.url != null - ? Image.network( - widget.url, - height: - SizeConfig.imageSizeMultiplier * 21, - width: - SizeConfig.imageSizeMultiplier * 20, - fit: BoxFit.cover, - ) - : Container(), - ), - ), - Expanded( - flex: 3, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - AppText( - TranslationBase.of(context).description, - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 2, - fontWeight: FontWeight.bold, - ), - AppText( - model.pharmaciesList[0]["ItemDescription"], - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - AppText( - TranslationBase.of(context).price, - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 2, - fontWeight: FontWeight.bold, - ), - AppText( - model.pharmaciesList[0]["SellingPrice"] - .toString(), - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - ], - ), + body: Center( + child: FractionallySizedBox( + widthFactor: 0.95, + child: Container( + height: SizeConfig.screenHeight, + child: ListView( + shrinkWrap: true, + scrollDirection: Axis.vertical, + physics: const AlwaysScrollableScrollPhysics(), + children: [ + model.pharmaciesList.length > 0 + ? MedicineItemWidget( + label: model.pharmaciesList[0]["ItemDescription"], + url: widget.url, + showArrow: false, + showPrice: true, + price: model.pharmaciesList[0]["SellingPrice"] + .toString(), ) - ], - )) - : Container(), - Container( - margin: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 2, - bottom: SizeConfig.widthMultiplier * 2, - right: SizeConfig.widthMultiplier * 4, - left: SizeConfig.widthMultiplier * 4, - ), - child: Align( - alignment: Alignment.centerLeft, - child: AppText( - TranslationBase.of(context).youCanFindItIn, - fontWeight: FontWeight.bold, + : Container(), + Container( + margin: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 2, + bottom: SizeConfig.widthMultiplier * 2, + right: SizeConfig.widthMultiplier * 4, + left: SizeConfig.widthMultiplier * 4, + ), + child: Align( + alignment: Alignment.centerLeft, + child: AppText( + TranslationBase.of(context).youCanFindItIn, + fontWeight: FontWeight.bold, + ), + ), + alignment: projectsProvider.isArabic + ? Alignment.topRight + : Alignment.topLeft, ), - ), - alignment: projectsProvider.isArabic - ? Alignment.topRight - : Alignment.topLeft, - ), - Container( - width: SizeConfig.screenWidth * 0.99, - margin: EdgeInsets.only(left: 10, right: 10), - child: ListView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: model.pharmaciesList == null - ? 0 - : model.pharmaciesList.length, - itemBuilder: (BuildContext context, int index) { - return RoundedContainer( - margin: EdgeInsets.only(top: 5), - child: Row( - children: [ - Expanded( - flex: 1, - child: ClipRRect( - borderRadius: - BorderRadius.all(Radius.circular(7)), - child: Image.network( - model.pharmaciesList[index] - ["ProjectImageURL"], - height: SizeConfig.imageSizeMultiplier * 15, - width: SizeConfig.imageSizeMultiplier * 15, - fit: BoxFit.cover, - ), - ), - ), - Expanded( - flex: 4, - child: AppText( - model.pharmaciesList[index] - ["LocationDescription"], - margin: 10, - ), - ), - Expanded( - flex: 2, - child: Wrap( - direction: Axis.horizontal, - alignment: WrapAlignment.end, - crossAxisAlignment: WrapCrossAlignment.end, - children: [ - Padding( - padding: EdgeInsets.all(5), - child: InkWell( - child: Icon( - Icons.call, - color: Colors.red, - ), - onTap: () => launch("tel://" + - model.pharmaciesList[index] - ["PhoneNumber"]), + Container( + width: SizeConfig.screenWidth * 0.99, + margin: EdgeInsets.only(left: 10, right: 10), + child: ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: model.pharmaciesList == null + ? 0 + : model.pharmaciesList.length, + itemBuilder: (BuildContext context, int index) { + return CardWithBgWidget( + bgColor: Colors.transparent, + hasBorder: false, + widget: Row( + children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: + BorderRadius.all(Radius.circular(7)), + child: Image.network( + model.pharmaciesList[index] + ["ProjectImageURL"], + height: + SizeConfig.imageSizeMultiplier * 15, + width: + SizeConfig.imageSizeMultiplier * 15, + fit: BoxFit.cover, ), ), - Padding( - padding: EdgeInsets.all(5), - child: InkWell( - child: Icon( - Icons.pin_drop, - color: Colors.red, - ), - onTap: () { + ), + Expanded( + flex: 4, + child: AppText( + Helpers.convertToTitleCase( + model.pharmaciesList[index] + ["LocationDescription"] ?? + ''), + margin: 10, + fontHeight: 1.4, + color: AppGlobal.appTextColor, + textAlign: TextAlign.start, + fontWeight: FontWeight.w600, + letterSpacing: -0.33, + ), + ), + + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + onTap: () async { MapsLauncher.launchCoordinates( double.parse( model.pharmaciesList[index] @@ -204,17 +151,123 @@ class _PharmaciesListState extends State { model.pharmaciesList[index] ["LocationDescription"]); }, + child: Container( + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: + BorderRadius.circular(10), + ), + // color:Colors.red[600], + + child: Row( + children: [ + Icon( + Icons.pin_drop, + size: 15, + color: Colors.white, + ), + SizedBox( + width: 2, + ), + AppText( + "location", + fontSize: 8, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), + ), ), - ), - ], - ), + SizedBox( + height: 10, + ), + InkWell( + onTap: () { + launch("tel://" + + model.pharmaciesList[index] + ["PhoneNumber"]); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: + BorderRadius.circular(10), + ), + // color:Colors.red[600], + + child: Row( + children: [ + Icon( + DoctorApp.call, + size: 12, + color: Colors.white, + ), + SizedBox( + width: 2, + ), + AppText( + "Call Now", + fontSize: 8, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), + ), + ), + ], + ), + // Expanded( + // flex: 2, + // child: Wrap( + // direction: Axis.horizontal, + // alignment: WrapAlignment.end, + // crossAxisAlignment: WrapCrossAlignment.end, + // children: [ + // Padding( + // padding: EdgeInsets.all(5), + // child: InkWell( + // child: Icon( + // Icons.call, + // color: Colors.red, + // ), + // onTap: () => launch("tel://" + + // model.pharmaciesList[index] + // ["PhoneNumber"]), + // ), + // ), + // Padding( + // padding: EdgeInsets.all(5), + // child: InkWell( + // child: Icon( + // Icons.pin_drop, + // color: Colors.red, + // ), + // onTap: () { + // MapsLauncher.launchCoordinates( + // double.parse( + // model.pharmaciesList[index] + // ["Latitude"]), + // double.parse( + // model.pharmaciesList[index] + // ["Longitude"]), + // model.pharmaciesList[index] + // ["LocationDescription"]); + // }, + // ), + // ), + // ], + // ), + // ), + ], ), - ], - ), - ); - }), - ) - ]), + ); + }), + ) + ]), + ), + ), ), ), );