diff --git a/lib/views/requests/request_detail_page.dart b/lib/views/requests/request_detail_page.dart index 5ac2e76..b8a9c81 100644 --- a/lib/views/requests/request_detail_page.dart +++ b/lib/views/requests/request_detail_page.dart @@ -1,8 +1,5 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/app_state.dart'; -import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; @@ -12,12 +9,11 @@ import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/chat_view_model.dart'; -import 'package:mc_common_app/view_models/requests_view_model.dart'; +import 'package:mc_common_app/views/advertisement/components/ads_images_corousel_widget.dart'; +import 'package:mc_common_app/views/requests/request_bottomsheets.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/common_widgets/app_bar.dart'; -import 'package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; -import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -26,101 +22,6 @@ class RequestDetailPage extends StatelessWidget { const RequestDetailPage({Key? key, required this.requestDetailPageArguments}) : super(key: key); - Future buildSendOfferBottomSheet(BuildContext context) { - final requestDetail = requestDetailPageArguments.requestModel; - return showModalBottomSheet( - context: context, - isScrollControlled: true, - enableDrag: true, - builder: (BuildContext context) { - return Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) { - return InfoBottomSheet( - title: LocaleKeys.makeAnOffer.tr().toText(fontSize: 28, isBold: true, letterSpacing: -1.44), - description: Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 12.height, - TxtField( - value: requestsVM.offerPrice, - errorValue: requestsVM.offerPriceError, - keyboardType: TextInputType.number, - hint: LocaleKeys.enterAmount.tr(), - numbersOnly: true, - onChanged: (v) => requestsVM.updateOfferPrice(v), - ), - if (requestDetail.requestType == RequestsTypeEnum.serviceRequest.getIdFromRequestTypeStatusEnum()) ...[ - 12.height, - TxtField( - value: requestsVM.serviceItem, - errorValue: requestsVM.offerPriceError, - keyboardType: TextInputType.number, - hint: "Service Item", - onChanged: (v) => requestsVM.updateServiceItem(v), - ), - 12.height, - TxtField( - value: requestsVM.itemManufacturer, - errorValue: requestsVM.offerPriceError, - keyboardType: TextInputType.number, - hint: "Manufacturer", - onChanged: (v) => requestsVM.updateItemManufacturer(v), - ), - 12.height, - TxtField( - errorValue: "", - hint: "Manufactured On", - value: requestsVM.serviceItemCreatedOn, - isNeedClickAll: true, - postfixData: Icons.calendar_month_rounded, - postFixDataColor: MyColors.darkTextColor, - onTap: () async { - final formattedDate = await Utils.pickDateFromDatePicker(context); - requestsVM.updateServiceItemCreatedOn(formattedDate); - }, - ), - ], - 12.height, - TxtField( - maxLines: 5, - value: requestsVM.offerDescription, - errorValue: requestsVM.offerDescriptionError, - keyboardType: TextInputType.text, - hint: LocaleKeys.description.tr(), - onChanged: (v) => requestsVM.updateOfferDescription(v), - ), - ], - ), - 25.height, - ShowFillButton( - title: LocaleKeys.submit.tr(), - onPressed: () { - requestsVM.onSendOfferPressed( - context: context, - receiverId: requestDetail.customerID, - message: requestsVM.offerDescription, - requestId: requestDetail.id, - offerPrice: requestsVM.offerPrice, - requestModel: requestDetail, - requestIndex: requestDetailPageArguments.requestIndex, - isFromChatScreen: false, - ); - }, - maxWidth: double.infinity, - ), - 19.height, - ], - ), - )); - }); - }, - ); - } - Widget buildBottomButton({ required RequestStatus requestStatus, required String statusText, @@ -175,18 +76,14 @@ class RequestDetailPage extends StatelessWidget { children: [ Column( children: [ - Image.asset(MyAssets.bnCar), + ImagesCorouselWidget(imagesList: requestDetailPageArguments.requestModel.requestImages ?? []), 24.height, buildRequestContainer(context), ], ).toWhiteContainer( width: double.infinity, allPading: 12, - margin: const EdgeInsets.only( - top: 21, - right: 21, - left: 21, - ), + margin: const EdgeInsets.only(top: 21, right: 21, left: 21), ), if (!requestDetailPageArguments.requestModel.isChatted) ...[ ShowFillButton( @@ -196,7 +93,7 @@ class RequestDetailPage extends StatelessWidget { title: LocaleKeys.sendOffer.tr(), isBold: false, fontSize: 18, - onPressed: () => buildSendOfferBottomSheet(context), + onPressed: () => buildSendOfferBottomSheet(context, requestDetailPageArguments), ), ] else ...[ buildBottomButton( @@ -275,8 +172,8 @@ class RequestDetailPage extends StatelessWidget { ), ], ), - showItem("Customer Name", requestDetail.customerName), - showItem("Description ", requestDetail.description), + showItem("Customer Name: ", requestDetail.customerName), + showItem("Description: ", requestDetail.description), showItem("Price Range:", ""), Row( children: [ @@ -290,13 +187,17 @@ class RequestDetailPage extends StatelessWidget { children: [ "${requestDetail.price.toInt()}".toText(fontSize: 25, isBold: true), 2.width, - LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, height: 2.3), + LocaleKeys.sar.tr().toText( + color: MyColors.lightTextColor, + fontSize: 16, + height: 2.3, + ), ], ), Row( children: [ Utils.statusContainerChip( - text: ("${LocaleKeys.offer.tr()} ${requestDetail.requestStatusName}"), + text: (requestDetail.requestStatusName), chipColor: MyColors.grey98Color.withOpacity(0.3), textColor: MyColors.lightTextColor, ), diff --git a/lib/views/requests/send_offer_page.dart b/lib/views/requests/send_offer_page.dart index 25e66c5..40eb6ce 100644 --- a/lib/views/requests/send_offer_page.dart +++ b/lib/views/requests/send_offer_page.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; diff --git a/lib/views/settings/branch/branch_list_page.dart b/lib/views/settings/branch/branch_list_page.dart index d2c34fe..656a793 100644 --- a/lib/views/settings/branch/branch_list_page.dart +++ b/lib/views/settings/branch/branch_list_page.dart @@ -80,9 +80,23 @@ class BranchListPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Utils.statusContainerChip( - text: branchModel.branchStatusLabel ?? "", - chipColor: Utils.getChipColorByBranchStatus(branchModel.branchStatus!), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Utils.statusContainerChip( + text: branchModel.branchStatusLabel ?? "", + chipColor: Utils.getChipColorByBranchStatus(branchModel.branchStatus!), + ), + InkWell( + onTap: () async { + await serviceVM.onDeleteBranchPressed(context: context, branchID: branchModel.id ?? -1); + }, + child: const Icon( + Icons.delete, + color: MyColors.grey70Color, + ), + ), + ], ), 5.height, Text( @@ -102,26 +116,12 @@ class BranchListPage extends StatelessWidget { color: MyColors.grey70Color, maxLines: 2, )), - const Icon(Icons.arrow_forward_rounded, size: 18), + const Icon(Icons.arrow_forward_rounded, size: 18, color: MyColors.grey70Color), ], ) ], ), ), - // 12.width, - // Column( - // crossAxisAlignment: CrossAxisAlignment.end, - // mainAxisAlignment: MainAxisAlignment.end, - // - // children: [ - // IconButton( - // onPressed: () async {}, - // icon: const Icon(Icons.delete), - // color: Colors.red, - // ), - // const Icon(Icons.arrow_forward_rounded, size: 16), - // ], - // ), ], ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12)).onPress(() async { branchModel.countryID = serviceVM.branches!.data!.countryID; diff --git a/lib/views/settings/branch/create_branch_view.dart b/lib/views/settings/branch/create_branch_view.dart index 7ad5286..07eb21a 100644 --- a/lib/views/settings/branch/create_branch_view.dart +++ b/lib/views/settings/branch/create_branch_view.dart @@ -1,8 +1,8 @@ import 'dart:async'; - import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/generated/locale_keys.g.dart'; +import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/service_view_model.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -31,14 +31,14 @@ class CreateBranchView extends StatefulWidget { } class _CreateBranchViewState extends State { - late ServiceVM branchVM; + late ServiceVM serviceVM; @override void initState() { super.initState(); scheduleMicrotask(() { - branchVM = context.read(); - branchVM.getAllCountriesList(widget.branchData, EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA"); + serviceVM = context.read(); + serviceVM.getAllCountriesList(widget.branchData, EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA"); }); } @@ -65,7 +65,7 @@ class _CreateBranchViewState extends State { serviceVM.countryId = value.id; serviceVM.getAllCities(widget.branchData, EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA"); }, - isSelectAble: widget.branchData == null ? true : false, + isSelectAble: widget.branchData == null, list: serviceVM.countryDropList, dropdownValue: serviceVM.countryValue, hint: "${LocaleKeys.chooseCountry.tr()}*", @@ -108,6 +108,44 @@ class _CreateBranchViewState extends State { }, ), 12.height, + Row( + children: [ + Expanded( + child: TxtField( + errorValue: '', + hint: 'Opening Time*', + value: serviceVM.openTime, + isNeedClickAll: true, + postfixData: Icons.access_time, + postFixDataColor: MyColors.lightTextColor, + onTap: () async { + TimeOfDay startTime = TimeOfDay.now(); + String endTime = await Utils.pickTime(context, initialTime: startTime); + FocusManager.instance.primaryFocus?.unfocus(); + serviceVM.updateSelectionOpenTime(endTime); + }, + ), + ), + 12.width, + Expanded( + child: TxtField( + errorValue: '', + hint: 'Closing Time*', + value: serviceVM.closedTime, + isNeedClickAll: true, + postfixData: Icons.access_time, + postFixDataColor: MyColors.lightTextColor, + onTap: () async { + TimeOfDay startTime = TimeOfDay.now(); + String endTime = await Utils.pickTime(context, initialTime: startTime); + FocusManager.instance.primaryFocus?.unfocus(); + serviceVM.updateSelectionCloseTime(endTime); + }, + ), + ), + ], + ), + 12.height, TxtField( hint: LocaleKeys.address.tr(), isNeedClickAll: false, @@ -191,6 +229,9 @@ class _CreateBranchViewState extends State { ).horPaddingMain(), ), ), + if (serviceVM.branchErrorScreen.isNotEmpty) ...[ + serviceVM.branchErrorScreen.toText(fontSize: 14, color: Colors.red).paddingAll(21), + ], if (widget.branchData == null || widget.branchData!.id == null) ...[ SizedBox( width: double.infinity, @@ -204,6 +245,8 @@ class _CreateBranchViewState extends State { context: context, branchName: serviceVM.branchName, branchDesc: serviceVM.branchDescription, + openTime: serviceVM.openTime, + closeTime: serviceVM.closedTime, cityID: serviceVM.cityId, address: serviceVM.address, latitude: serviceVM.latitude, @@ -225,6 +268,8 @@ class _CreateBranchViewState extends State { branchID: widget.branchData!.id ?? 0, branchName: widget.branchData!.branchName ?? "", branchDesc: widget.branchData!.branchDescription ?? "", + openTime: widget.branchData!.openTime ?? "", + closedTime: widget.branchData!.closeTime ?? "", cityID: widget.branchData!.cityId ?? 0, address: widget.branchData!.address ?? "", latitude: widget.branchData!.latitude ?? "0",