From 7eadd97869b2d74d9ff009a10492e28790a15e03 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 5 Sep 2022 11:49:20 +0300 Subject: [PATCH] item for sale ui improvements & translation added. --- assets/langs/ar-SA.json | 14 + assets/langs/en-US.json | 14 + lib/generated/codegen_loader.g.dart | 28 ++ lib/generated/locale_keys.g.dart | 14 + lib/ui/landing/dashboard_screen.dart | 2 +- lib/ui/landing/widget/services_widget.dart | 125 ++++--- .../items_for_sale/add_new_item_for_sale.dart | 199 ++++------ .../fragments/add_details_fragment.dart | 344 +++++++++--------- .../fragments/select_category_fragment.dart | 65 ++-- .../items_for_sale/items_for_sale_home.dart | 2 +- lib/widgets/radio/show_radio.dart | 3 +- 11 files changed, 407 insertions(+), 403 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 082270f..3f122fd 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -370,6 +370,20 @@ "offerAndDiscounts": "العروض والخصومات", "offerValid": "العرض صالح", "offerExpired": "انتهى العرض", + "whatAreYouOffering": "ما الذي تعرضه؟", + "selectCategory": "اختر الفئة", + "inProgress": "في تَقَدم", + "locked": "مقفل", + "addDetails": "أضف التفاصيل", + "reviewAndSell": "مراجعة وبيع", + "itemTitle": "عنوان البند", + "itemCondition": "حالة السلعة", + "used": "تستخدم", + "region": "منطقة", + "selectRegion": "اختر المنطقة", + "itemPrice": "سعر السلعة", + "itemPhotos": "صور البند", + "itemInfo": "معلومات العنصر", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 1bf8cc7..faccbe7 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -370,6 +370,20 @@ "offerAndDiscounts": "Offer & Discounts", "offerValid": "Offer Valid", "offerExpired": "Offer Expired", + "whatAreYouOffering": "What are you offering?", + "selectCategory": "Select Category", + "inProgress": "InProgress", + "locked": "Locked", + "addDetails": "Add Details", + "reviewAndSell": "Review & Sell", + "itemTitle": "Item Title", + "itemCondition": "Item Condition", + "used": "Used", + "region": "Region", + "selectRegion": "Select Region", + "itemPrice": "Item Price", + "itemPhotos": "Item Photos", + "itemInfo": "Item Info", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 0dfa765..c4a10d4 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -386,6 +386,20 @@ class CodegenLoader extends AssetLoader{ "offerAndDiscounts": "العروض والخصومات", "offerValid": "العرض صالح", "offerExpired": "انتهى العرض", + "whatAreYouOffering": "ما الذي تعرضه؟", + "selectCategory": "اختر الفئة", + "inProgress": "في تَقَدم", + "locked": "مقفل", + "addDetails": "أضف التفاصيل", + "reviewAndSell": "مراجعة وبيع", + "itemTitle": "عنوان البند", + "itemCondition": "حالة السلعة", + "used": "تستخدم", + "region": "منطقة", + "selectRegion": "اختر المنطقة", + "itemPrice": "سعر السلعة", + "itemPhotos": "صور البند", + "itemInfo": "معلومات العنصر", "profile": { "reset_password": { "label": "Reset Password", @@ -792,6 +806,20 @@ static const Map en_US = { "offerAndDiscounts": "Offer & Discounts", "offerValid": "Offer Valid", "offerExpired": "Offer Expired", + "whatAreYouOffering": "What are you offering?", + "selectCategory": "Select Category", + "inProgress": "InProgress", + "locked": "Locked", + "addDetails": "Add Details", + "reviewAndSell": "Review & Sell", + "itemTitle": "Item Title", + "itemCondition": "Item Condition", + "used": "Used", + "region": "Region", + "selectRegion": "Select Region", + "itemPrice": "Item Price", + "itemPhotos": "Item Photos", + "itemInfo": "Item Info", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 7214616..5cf6ba7 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -371,6 +371,20 @@ abstract class LocaleKeys { static const offerAndDiscounts = 'offerAndDiscounts'; static const offerValid = 'offerValid'; static const offerExpired = 'offerExpired'; + static const whatAreYouOffering = 'whatAreYouOffering'; + static const selectCategory = 'selectCategory'; + static const inProgress = 'inProgress'; + static const locked = 'locked'; + static const addDetails = 'addDetails'; + static const reviewAndSell = 'reviewAndSell'; + static const itemTitle = 'itemTitle'; + static const itemCondition = 'itemCondition'; + static const used = 'used'; + static const region = 'region'; + static const selectRegion = 'selectRegion'; + static const itemPrice = 'itemPrice'; + static const itemPhotos = 'itemPhotos'; + static const itemInfo = 'itemInfo'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 907072e..3f4e5f2 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -240,7 +240,7 @@ class _DashboardScreenState extends State { ], ).paddingOnly(left: 21, right: 21, top: 7), ServicesWidget(), - 8.height, + // 8.height, Container( width: double.infinity, padding: const EdgeInsets.only(top: 31), diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index 868ca5e..719155c 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -33,69 +33,68 @@ class ServicesWidget extends StatelessWidget { return data.isServicesMenusLoading ? whileLoading() : ListView.separated( + padding: const EdgeInsets.only(top: 21), itemBuilder: (context, parentIndex) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().expanded, - LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), - ], - ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 105 + 26, - child: ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return AspectRatio( - aspectRatio: 105 / 105, - child: data.isServicesMenusLoading - ? ServicesMenuShimmer() - : Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset(iconT[index]), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), - ), - SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) - ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ).onPress(() { - handleOnPress(context, data.homeMenus![parentIndex].menuEntiesList[index]); - }), - ); - }, - separatorBuilder: (cxt, index) => 9.width, - itemCount: data.homeMenus![parentIndex].menuEntiesList.length), - ), - ], - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().expanded, + LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), + ], + ).paddingOnly(left: 21, right: 21), + SizedBox( + height: 105 + 26, + child: ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return AspectRatio( + aspectRatio: 105 / 105, + child: data.isServicesMenusLoading + ? ServicesMenuShimmer() + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset(iconT[index]), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), + ), + SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) + ], + ) + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ).onPress(() { + handleOnPress(context, data.homeMenus![parentIndex].menuEntiesList[index]); + }), + ); + }, + separatorBuilder: (cxt, index) => 9.width, + itemCount: data.homeMenus![parentIndex].menuEntiesList.length), + ), + ], ); }, separatorBuilder: (context, index) { @@ -149,7 +148,7 @@ class ServicesWidget extends StatelessWidget { Widget whileLoading() { return Column( children: [ - ServicesHeaderShimmer().paddingOnly(left: 21, right: 21), + ServicesHeaderShimmer().paddingOnly(left: 21, right: 21, top: 21), SizedBox( height: 105 + 26, child: ListView.separated( diff --git a/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart index 307a834..aac9d13 100644 --- a/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart +++ b/lib/ui/screens/items_for_sale/add_new_item_for_sale.dart @@ -1,8 +1,11 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/items_for_sale/items_for_sale_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; import 'package:mohem_flutter_app/models/items_for_sale/item_review_model.dart'; import 'package:mohem_flutter_app/ui/screens/items_for_sale/fragments/add_details_fragment.dart'; @@ -43,91 +46,52 @@ class _AddNewItemForSaleState extends State { getRequestID(); return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget( - context, - // title: LocaleKeys.mowadhafhiRequest.tr(), - title: "Items for sale", - showHomeButton: true, - ), + appBar: AppBarWidget(context, title: LocaleKeys.itemsForSale.tr(), showHomeButton: true), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AspectRatio( - aspectRatio: 335 / 118, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + Row( + children: [ + showProgress( + title: LocaleKeys.selectCategory.tr(), + status: _currentIndex == 0 ? LocaleKeys.inProgress.tr() : (_currentIndex > 0 ? LocaleKeys.completed.tr() : LocaleKeys.locked.tr()), + color: _currentIndex == 0 ? MyColors.orange : MyColors.greenColor, + pageIndex: 0, + ).expanded, + showProgress( + title: LocaleKeys.addDetails.tr(), + status: _currentIndex == 1 ? LocaleKeys.inProgress.tr() : (_currentIndex > 1 ? LocaleKeys.completed.tr() : LocaleKeys.locked.tr()), + color: _currentIndex == 1 ? MyColors.orange : (_currentIndex > 1 ? MyColors.greenColor : MyColors.lightGrayColor), + pageIndex: 1, + ).expanded, + showProgress( + title: LocaleKeys.reviewAndSell.tr(), + status: _currentIndex == 2 ? LocaleKeys.inProgress.tr() : LocaleKeys.locked.tr(), + color: _currentIndex == 2 + ? MyColors.orange + : _currentIndex > 3 + ? MyColors.greenColor + : MyColors.lightGrayColor, + isNeedBorder: false, + pageIndex: 2, ), - child: Row( - children: [ - Expanded( - child: showProgress( - title: "Select Category", - status: _currentIndex == 0 - ? "InProgress" - : _currentIndex > 0 - ? "Completed" - : "Locked", - color: _currentIndex == 0 ? MyColors.orange : MyColors.greenColor, - pageIndex: 0, - ), - ), - Expanded( - child: showProgress( - title: "Add Details", - status: _currentIndex == 1 - ? "InProgress" - : _currentIndex > 1 - ? "Completed" - : "Locked", - color: _currentIndex == 1 - ? MyColors.orange - : _currentIndex > 1 - ? MyColors.greenColor - : MyColors.lightGrayColor, - pageIndex: 1, - ), - ), - showProgress( - title: "Review & Sell", - status: _currentIndex == 2 ? "InProgress" : "Locked", - color: _currentIndex == 2 - ? MyColors.orange - : _currentIndex > 3 - ? MyColors.greenColor - : MyColors.lightGrayColor, - isNeedBorder: false, - pageIndex: 2, - ), - ], - ).paddingAll(21), - ).paddingOnly(left: 21, right: 21, top: 21), - ), - Expanded( - child: PageView( - physics: NeverScrollableScrollPhysics(), - controller: _controller, - onPageChanged: (index) { - setState(() { - _currentIndex = index; - }); - }, - scrollDirection: Axis.horizontal, - children: [ - getSaleCategoriesList.isNotEmpty ? SelectCategoryFragment(changePageViewIndex: changePageViewIndex, getSaleCategoriesList: getSaleCategoriesList) : Container(), - getSaleCategoriesList.isNotEmpty ? AddItemDetailsFragment(changePageViewIndex: changePageViewIndex, selectedSaleCategory: getSaleCategoriesList[0]) : Container(), - ItemReviewFragment(changePageViewIndex: changePageViewIndex), - ], - ), - ), + ], + ).paddingAll(21).objectContainerView(disablePadding: true).paddingAll(21), + PageView( + physics: const NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + getSaleCategoriesList.isNotEmpty ? SelectCategoryFragment(changePageViewIndex: changePageViewIndex, getSaleCategoriesList: getSaleCategoriesList) : Container(), + getSaleCategoriesList.isNotEmpty ? AddItemDetailsFragment(changePageViewIndex: changePageViewIndex, selectedSaleCategory: getSaleCategoriesList[0]) : Container(), + ItemReviewFragment(changePageViewIndex: changePageViewIndex), + ], + ).expanded, ], ), ); @@ -141,54 +105,43 @@ class _AddNewItemForSaleState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, + Row( children: [ - Row( - children: [ - Container( - width: 26, - height: 26, - decoration: Utils.containerRadius(color!, 200), - child: const Icon( - Icons.done, - color: Colors.white, - size: 16, - ), - ), - if (isNeedBorder) - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Utils.mDivider(Colors.grey), - )), - ], - ), - Utils.mHeight(8), - Text( - title!, - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - letterSpacing: -0.44, + Container( + width: 26, + height: 26, + decoration: Utils.containerRadius(color!, 200), + child: const Icon( + Icons.done, + color: Colors.white, + size: 16, ), ), - Utils.mHeight(2), - Container( - padding: EdgeInsets.all(5), - decoration: Utils.containerRadius(color.withOpacity(0.2), 4), - child: Text( - status!, - style: TextStyle( - fontSize: 8, - fontWeight: FontWeight.w600, - letterSpacing: -0.32, - color: color, + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Utils.mDivider(Colors.grey), ), ), - ), ], - ) + ), + Utils.mHeight(8), + title!.toText11(), + Utils.mHeight(2), + Container( + padding: const EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), + decoration: Utils.containerRadius(color.withOpacity(0.2), 4), + child: Text( + status!, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, + ), + ), + ), ], ), ); diff --git a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart index 7919c0d..bfb5a5e 100644 --- a/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/add_details_fragment.dart @@ -51,112 +51,116 @@ class _AddItemDetailsFragmentState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "Add details".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DynamicTextFieldWidget( - "Title", - itemTitle.isEmpty ? "Item title" : itemTitle, - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - itemTitle = value; - }, - ).paddingOnly(), - DynamicTextFieldWidget( - "Description", - itemDescription.isEmpty ? "Item description" : itemDescription, - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 4, - isInputTypeNum: false, - isReadOnly: false, - onChange: (String value) { - itemDescription = value; - }, - ).paddingOnly(top: 12), - "Item Condition".toText14(isBold: true).paddingOnly(top: 21), - Row( - children: [ - ShowRadio(title: "New", value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "new"; - setState(() {}); - }), - 12.width, - ShowRadio(title: "Used", value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { - selectedItemCondition = "used"; + return Column( + children: [ + ListView( + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21), + children: [ + LocaleKeys.addDetails.tr().toText20(), + 12.height, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DynamicTextFieldWidget( + LocaleKeys.title.tr(), + itemTitle.isEmpty ? LocaleKeys.itemTitle.tr() : itemTitle, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemTitle = value; + }, + ), + DynamicTextFieldWidget( + LocaleKeys.description.tr(), + itemDescription.isEmpty ? LocaleKeys.itemDescription.tr() : itemDescription, + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 4, + isInputTypeNum: false, + isReadOnly: false, + onChange: (String value) { + itemDescription = value; + }, + ).paddingOnly(top: 12), + LocaleKeys.itemCondition.tr().toText14().paddingOnly(top: 21), + Row( + children: [ + ShowRadio(title: LocaleKeys.newString.tr(), value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "new"; + setState(() {}); + }), + 12.width, + ShowRadio(title: LocaleKeys.used.tr(), value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() { + selectedItemCondition = "used"; + setState(() {}); + }), + ], + ).paddingOnly(top: 12), + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.region.tr(), + selectedRegion.regionName ?? LocaleKeys.selectRegion.tr(), + isEnable: false, + isPopup: true, + isInputTypeNum: true, + isReadOnly: false, + ), + itemBuilder: (_) => >[ + for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem(child: Text(getRegionsList[i].regionName!), value: i), + ], + onSelected: (int popupIndex) { + selectedRegion = getRegionsList![popupIndex]; setState(() {}); - }), - ], - ).paddingOnly(top: 12), - PopupMenuButton( - child: DynamicTextFieldWidget( - "Region", - selectedRegion.regionName ?? "Select Region", - isEnable: false, - isPopup: true, + }, + ).paddingOnly(top: 21), + DynamicTextFieldWidget( + LocaleKeys.itemPrice.tr(), + itemPrice == 0 ? LocaleKeys.price.tr() : itemPrice.toString(), + isEnable: true, + suffixIconData: Icons.search, + isPopup: false, + lines: 1, isInputTypeNum: true, isReadOnly: false, - ), - itemBuilder: (_) => >[ - for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem(child: Text(getRegionsList[i].regionName!), value: i), - ], - onSelected: (int popupIndex) { - selectedRegion = getRegionsList![popupIndex]; - setState(() {}); - }, - ).paddingOnly(top: 21), - DynamicTextFieldWidget( - "Item Price", - itemPrice == 0 ? "Price" : itemPrice.toString(), - isEnable: true, - suffixIconData: Icons.search, - isPopup: false, - lines: 1, - isInputTypeNum: true, - isReadOnly: false, - onChange: (String value) { - itemPrice = num.parse(value); - }, - ).paddingOnly(top: 12), - "Item Photos".toText14(isBold: true).paddingOnly(top: 16), - attachmentView("Attachments").paddingOnly(top: 12), - Row( - children: [ - DefaultButton( - LocaleKeys.cancel.tr(), - () async { - Navigator.of(context).pop(); + onChange: (String value) { + itemPrice = num.parse(value); + }, + ).paddingOnly(top: 12), + LocaleKeys.itemPhotos.tr().toText14().paddingOnly(top: 21), + attachmentView(LocaleKeys.attachments.tr()).paddingOnly(top: 12), + ], + ).objectContainerView(title: LocaleKeys.itemInfo.tr()), + ], + ).expanded, + 1.divider, + Row( + children: [ + DefaultButton( + LocaleKeys.cancel.tr(), + () async { + Navigator.of(context).pop(); + }, + colors: const [Color(0xffD02127), Color(0xffD02127)], + ).expanded, + 8.width, + DefaultButton( + LocaleKeys.next.tr(), + isButtonDisabled() + ? null + : () async { + AddItemDetailsFragment.itemReviewModel = getItemReviewObject(); + widget.changePageViewIndex(2); }, - colors: const [Color(0xffD02127), Color(0xffD02127)], - ).expanded, - 12.width, - DefaultButton( - LocaleKeys.next.tr(), - isButtonDisabled() - ? null - : () async { - AddItemDetailsFragment.itemReviewModel = getItemReviewObject(); - widget.changePageViewIndex(2); - }, - disabledColor: MyColors.lightGrayColor, - ).expanded - ], - ).paddingOnly(top: 21), - ], - ).objectContainerView(title: "Item Info").paddingAll(21), - ], - ), + disabledColor: MyColors.lightGrayColor, + ).expanded + ], + ).insideContainer + ], ); } @@ -174,82 +178,70 @@ class _AddItemDetailsFragmentState extends State { } Widget attachmentView(String title) { - return Container( - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - title.toText16().expanded, - 6.width, - SimpleButton(LocaleKeys.add.tr(), () async { - ImageOptions.showImageOptions(context, (String image, File file) { - setState(() { - images.add(image); - }); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + title.toText16().expanded, + 6.width, + SimpleButton(LocaleKeys.add.tr(), () async { + ImageOptions.showImageOptions(context, (String image, File file) { + setState(() { + images.add(image); }); - }, fontSize: 14), - ], - ), - if (images.isNotEmpty) 12.height, - if (images.isNotEmpty) - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (cxt, index) { - return Container( - margin: const EdgeInsets.all(10), - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon(Icons.attach_file_sharp), - const SizedBox( - width: 8, - ), - 'image ${index + 1}.png'.toText16(), - ], + }); + }, fontSize: 14), + ], + ), + if (images.isNotEmpty) 12.height, + if (images.isNotEmpty) + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) { + return Container( + margin: const EdgeInsets.all(10), + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon(Icons.attach_file_sharp), + const SizedBox( + width: 8, + ), + 'image ${index + 1}.png'.toText16(), + ], + ), + InkWell( + onTap: () { + setState(() { + images.remove(images[index]); + }); + }, + child: Icon( + Icons.delete_sharp, + color: Colors.red[300], ), - InkWell( - onTap: () { - setState(() { - images.remove(images[index]); - }); - }, - child: Icon( - Icons.delete_sharp, - color: Colors.red[300], - )) - ], - ), - ); - }, - separatorBuilder: (cxt, index) => 6.height, - itemCount: images.length), - ], - ), - ); + ) + ], + ), + ); + }, + separatorBuilder: (cxt, index) => 6.height, + itemCount: images.length), + ], + ).objectContainerView(); } - void getAdDetails() async { + Future getAdDetails() async { + // todo need to change this method later , its not a good approach to do it like this. String details = await Utils.getStringFromPrefs(SharedPrefsConsts.editItemForSale); var body = json.decode(details); @@ -274,17 +266,15 @@ class _AddItemDetailsFragmentState extends State { AddItemDetailsFragment.itemReviewModel = itemReviewModel; SelectCategoryFragment.selectedSaleCategory = selectedSaleCategoryAd; - - setState(() {}); } void getRegions() async { try { Utils.showLoading(context); getRegionsList = await ItemsForSaleApiClient().getRegions(); + await getAdDetails(); Utils.hideLoading(context); setState(() {}); - getAdDetails(); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart index 6255302..04d6b2d 100644 --- a/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/select_category_fragment.dart @@ -1,7 +1,9 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/items_for_sale/get_sale_categories_list.dart'; class SelectCategoryFragment extends StatelessWidget { @@ -18,11 +20,11 @@ class SelectCategoryFragment extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - "What are you offering".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21), + LocaleKeys.whatAreYouOffering.tr().toText20().paddingOnly(top: 0, left: 21, right: 21), getSaleCategoriesList.isNotEmpty ? GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 105 / 105, crossAxisSpacing: 12, mainAxisSpacing: 12), - padding: const EdgeInsets.only(top: 15, bottom: 15, left: 21, right: 21), + padding: const EdgeInsets.only(top: 15, bottom: 21, left: 21, right: 21), shrinkWrap: true, primary: false, physics: const ScrollPhysics(), @@ -37,41 +39,32 @@ class SelectCategoryFragment extends StatelessWidget { List getItemsForSaleWidgets() { List itemsList = []; - getSaleCategoriesList.forEach((element) { - itemsList.add(InkWell( - onTap: () { - selectedSaleCategory = element; - changePageViewIndex(1); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), - ), - ], + getSaleCategoriesList.forEach( + (element) { + itemsList.add( + InkWell( + onTap: () { + selectedSaleCategory = element; + changePageViewIndex(1); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.string(element.content!, fit: BoxFit.contain, width: 32, height: 32), + ], + ).expanded, + element.title!.toText12() + ], + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 16).expanded.objectContainerView(disablePadding: true), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.string(element.content!, fit: BoxFit.contain, width: 32, height: 32), - ], - ).expanded, - element.title!.toText12() - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), - ), - )); - }); + ); + }, + ); return itemsList; } diff --git a/lib/ui/screens/items_for_sale/items_for_sale_home.dart b/lib/ui/screens/items_for_sale/items_for_sale_home.dart index 9f3151d..437b400 100644 --- a/lib/ui/screens/items_for_sale/items_for_sale_home.dart +++ b/lib/ui/screens/items_for_sale/items_for_sale_home.dart @@ -46,7 +46,7 @@ class _ItemsForSaleState extends State { ), ), child: Row( - children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab("My posted ads", 1)], + children: [myTab(LocaleKeys.itemsForSale.tr(), 0), myTab(LocaleKeys.myPostedAds.tr(), 1)], ), ), PageView( diff --git a/lib/widgets/radio/show_radio.dart b/lib/widgets/radio/show_radio.dart index 6138fa3..9a5a4b8 100644 --- a/lib/widgets/radio/show_radio.dart +++ b/lib/widgets/radio/show_radio.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; -import 'package:mohem_flutter_app/extensions/int_extensions.dart'; class ShowRadio extends StatelessWidget { String title, value, groupValue; @@ -39,7 +38,7 @@ class ShowRadio extends StatelessWidget { ), ), 12.width, - title.toText12(isBold: true, maxLine: 2) + title.toText12(maxLine: 2) ], ); }