16 April, 2025

master
Faiz Hashmi 7 months ago
parent 29567119e6
commit 32e168b14a

@ -115,10 +115,15 @@ class ScheduleVM extends BaseVM {
return response; return response;
} }
getSchedules(String branchId) async { Future<void> getSchedules(String branchId) async {
schedule = null; try {
schedule = await scheduleRepo.getSchedules(branchId); setState(ViewState.busy);
setState(ViewState.idle); schedule = null;
schedule = await scheduleRepo.getSchedules(branchId);
setState(ViewState.idle);
} catch (e) {
setState(ViewState.idle);
}
} }
Future<GenericRespModel> updateSchedule(Map map) async { Future<GenericRespModel> updateSchedule(Map map) async {

@ -217,6 +217,7 @@ class _AddNewServiceAppointmentPageState extends State<AddNewServiceAppointmentP
12.height, 12.height,
(service != null && pickedItems != null && pickedItems!.isNotEmpty) (service != null && pickedItems != null && pickedItems!.isNotEmpty)
? ChipsPickerItem( ? ChipsPickerItem(
isNeedLabelOnTop: true,
hint: LocaleKeys.selectItems.tr(), hint: LocaleKeys.selectItems.tr(),
itemsList: [...pickedItems ?? []], itemsList: [...pickedItems ?? []],
onClick: () { onClick: () {

@ -155,6 +155,7 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
), ),
8.height, 8.height,
ChipsPickerItem( ChipsPickerItem(
isNeedLabelOnTop: true,
hint: LocaleKeys.select_Services.tr(), hint: LocaleKeys.select_Services.tr(),
itemsList: [...scheduleVM.selectedServicesItems], itemsList: [...scheduleVM.selectedServicesItems],
onClick: () { onClick: () {
@ -248,6 +249,7 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
), ),
8.height, 8.height,
ChipsPickerItem( ChipsPickerItem(
isNeedLabelOnTop: true,
hint: LocaleKeys.offDays.tr(), hint: LocaleKeys.offDays.tr(),
itemsList: [...scheduleVM.selectedDaysItems], itemsList: [...scheduleVM.selectedDaysItems],
onClick: () { onClick: () {

@ -10,6 +10,7 @@ import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/date_helper.dart'; import 'package:mc_common_app/utils/date_helper.dart';
import 'package:mc_common_app/utils/dialogs_and_bottomsheets.dart'; import 'package:mc_common_app/utils/dialogs_and_bottomsheets.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/navigator.dart';
import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/button/show_fill_button.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart';
@ -52,7 +53,7 @@ class _SchedulesListPageState extends State<SchedulesListPage> {
GenericRespModel res = await serviceVM.setScheduleInactive(serviceVM.schedule!.data![index].id!, serviceVM.schedule!.data![index].serviceProviderBranchId!); GenericRespModel res = await serviceVM.setScheduleInactive(serviceVM.schedule!.data![index].id!, serviceVM.schedule!.data![index].serviceProviderBranchId!);
Utils.hideLoading(context); Utils.hideLoading(context);
if (res.messageStatus == 1) { if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_deleted.tr()); Utils.showToast(LocaleKeys.scheduleDeletedSuccessfully.tr());
} else { } else {
Utils.showToast(res.message ?? ""); Utils.showToast(res.message ?? "");
} }
@ -94,62 +95,67 @@ class _SchedulesListPageState extends State<SchedulesListPage> {
? EmptyWidget( ? EmptyWidget(
text: LocaleKeys.noSchedulesFound.tr(), text: LocaleKeys.noSchedulesFound.tr(),
).paddingAll(21) ).paddingAll(21)
: ListView.separated( : RefreshIndicator(
itemBuilder: (BuildContext context, int index) { onRefresh: () async {
return Column( await scheduleVM.getSchedules(widget.branchId ?? "");
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: scheduleVM.schedule!.data![index].scheduleName.toString().toText(fontSize: 16)),
Padding(
padding: const EdgeInsets.all(4.0),
child: SvgPicture.asset(
MyAssets.icEdit,
width: 18,
height: 18,
),
).onPress(() {
scheduleVM.schedule!.data![index].branchId = widget.branchId ?? "";
navigateWithName(context, AppRoutes.addSchedule, arguments: scheduleVM.schedule!.data![index]);
}),
MyAssets.closeWithOrangeBg
.buildSvg(height: 28, width: 28)
.onPress(() => deleteScheduleConfirmationSheet(index, scheduleVM, context))
.paddingOnly(top: 3, left: 4),
],
),
8.height,
showItem("${LocaleKeys.startDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].fromDate)),
showItem("${LocaleKeys.endDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].toDate)),
showItem("${LocaleKeys.shiftStartTime.tr()}:", scheduleVM.schedule!.data![index].startTime ?? ""),
showItem("${LocaleKeys.shiftEndTime.tr()}:", scheduleVM.schedule!.data![index].endTime ?? ""),
showItem("${LocaleKeys.slotsTime.tr()}:", "${scheduleVM.schedule!.data![index].slotDurationMinute} Mins"),
showItem("${LocaleKeys.appointmentPerSlot.tr()}:", scheduleVM.schedule!.data![index].perSlotAppointment.toString()),
showItem(
LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()),
showItem("${LocaleKeys.offDays.tr()}:", offDays(scheduleVM.schedule!.data![index])),
12.height,
"${LocaleKeys.services.tr()}:".toText(fontSize: 12, color: MyColors.lightTextColor),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: scheduleVM.schedule!.data![index].scheduleServices!
.map(
(element) => Container(
child: element.serviceDescription.toString().toText(fontSize: 12),
),
)
.toList(),
)
],
).toWhiteContainer(width: double.infinity, allPading: 12);
},
separatorBuilder: (BuildContext context, int index) {
return 12.height;
}, },
padding: const EdgeInsets.all(20), child: ListView.separated(
itemCount: scheduleVM.schedule!.data!.length, itemBuilder: (BuildContext context, int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: scheduleVM.schedule!.data![index].scheduleName.toString().toText(fontSize: 16)),
Padding(
padding: const EdgeInsets.all(4.0),
child: SvgPicture.asset(
MyAssets.icEdit,
width: 18,
height: 18,
),
).onPress(() {
scheduleVM.schedule!.data![index].branchId = widget.branchId ?? "";
navigateWithName(context, AppRoutes.addSchedule, arguments: scheduleVM.schedule!.data![index]);
}),
MyAssets.closeWithOrangeBg
.buildSvg(height: 28, width: 28)
.onPress(() => deleteScheduleConfirmationSheet(index, scheduleVM, context))
.paddingOnly(top: 3, left: 4),
],
),
8.height,
showItem("${LocaleKeys.startDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].fromDate)),
showItem("${LocaleKeys.endDate.tr()}:", DateHelper.formatAsDayMonthYear(scheduleVM.schedule!.data![index].toDate)),
showItem("${LocaleKeys.shiftStartTime.tr()}:", scheduleVM.schedule!.data![index].startTime ?? ""),
showItem("${LocaleKeys.shiftEndTime.tr()}:", scheduleVM.schedule!.data![index].endTime ?? ""),
showItem("${LocaleKeys.slotsTime.tr()}:", "${scheduleVM.schedule!.data![index].slotDurationMinute} Mins"),
showItem("${LocaleKeys.appointmentPerSlot.tr()}:", scheduleVM.schedule!.data![index].perSlotAppointment.toString()),
showItem(
LocaleKeys.serviceLocation.tr(), scheduleVM.schedule!.data![index].appointmentType == 1 ? LocaleKeys.companyLocation.tr() : LocaleKeys.customerLocation.tr()),
showItem("${LocaleKeys.offDays.tr()}:", offDays(scheduleVM.schedule!.data![index])),
12.height,
"${LocaleKeys.services.tr()}:".toText(fontSize: 12, color: MyColors.lightTextColor),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: scheduleVM.schedule!.data![index].scheduleServices!
.map(
(element) => Container(
child: element.serviceDescription.toString().toText(fontSize: 12),
),
)
.toList(),
)
],
).toWhiteContainer(width: double.infinity, allPading: 12);
},
separatorBuilder: (BuildContext context, int index) {
return 12.height;
},
padding: const EdgeInsets.all(20),
itemCount: scheduleVM.schedule!.data!.length,
),
); );
}, },
), ),
@ -161,7 +167,7 @@ class _SchedulesListPageState extends State<SchedulesListPage> {
onPressed: () { onPressed: () {
navigateWithName(context, AppRoutes.addSchedule, arguments: ScheduleData(branchId: widget.branchId ?? "")); navigateWithName(context, AppRoutes.addSchedule, arguments: ScheduleData(branchId: widget.branchId ?? ""));
}, },
), ),
], ],
), ),
), ),

@ -15,54 +15,74 @@ class PickerItem {
} }
class ChipsPickerItem extends StatelessWidget { class ChipsPickerItem extends StatelessWidget {
final bool isNeedLabelOnTop;
final String hint; final String hint;
final List<PickerItem> itemsList; final List<PickerItem> itemsList;
final Function onClick; final Function onClick;
const ChipsPickerItem({super.key, required this.hint, required this.itemsList, required this.onClick}); const ChipsPickerItem({super.key, required this.isNeedLabelOnTop, required this.hint, required this.itemsList, required this.onClick});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Column(
children: [ children: [
if (itemsList.isEmpty) if (isNeedLabelOnTop && hint.isNotEmpty) ...[
Expanded( Row(
child: Text( mainAxisAlignment: MainAxisAlignment.start,
hint, children: [
style: const TextStyle(color: borderColor, fontSize: 15, fontWeight: MyFonts.Medium), (hint).toText(
)), color: borderColor,
if (itemsList.isNotEmpty) fontSize: 13,
Expanded( fontWeight: MyFonts.Medium,
child: ListView( ),
scrollDirection: Axis.horizontal, ],
children: [
showItem(itemsList[0].title),
6.width,
if (itemsList.length > 1) showItem(itemsList[1].title),
6.width,
if (itemsList.length > 2) showItem("${itemsList.length - 2}+ more", isNeedToShowIcon: false),
6.width,
],
),
), ),
const Icon( 4.height,
Icons.arrow_forward_ios_rounded, ],
size: 16, Row(
color: MyColors.lightIconColor, mainAxisAlignment: MainAxisAlignment.end,
), children: [
if (itemsList.isEmpty && !isNeedLabelOnTop)
Expanded(
child: Text(
hint,
style: const TextStyle(color: borderColor, fontSize: 15, fontWeight: MyFonts.Medium),
),
),
if (itemsList.isNotEmpty)
Expanded(
child: ListView(
scrollDirection: Axis.horizontal,
children: [
showItem(itemsList[0].title),
6.width,
if (itemsList.length > 1) showItem(itemsList[1].title),
6.width,
if (itemsList.length > 2) showItem("${itemsList.length - 2}+ more", isNeedToShowIcon: false),
6.width,
],
),
),
const Icon(
Icons.arrow_forward_ios_rounded,
size: 16,
color: MyColors.lightIconColor,
),
],
)
.toContainer(
width: double.infinity,
height: 45,
isEnabledBorder: true,
borderWidget: 2,
borderRadius: 0,
borderColor: MyColors.darkPrimaryColor,
)
.onPress(() {
onClick();
}),
], ],
) );
.toContainer(
width: double.infinity,
height: 45,
isEnabledBorder: true,
borderWidget: 2,
borderRadius: 0,
borderColor: MyColors.darkPrimaryColor,
)
.onPress(() {
onClick();
});
} }
Widget showItem(String title, {bool isNeedToShowIcon = true}) { Widget showItem(String title, {bool isNeedToShowIcon = true}) {

@ -86,14 +86,6 @@ class _CreateItemPageState extends State<CreateItemPage> {
}, },
), ),
12.height, 12.height,
TxtField(
hint: LocaleKeys.itemDescription.tr(),
value: description,
onChanged: (v) {
description = v;
},
),
12.height,
TxtField( TxtField(
hint: LocaleKeys.itemPrice.tr(), hint: LocaleKeys.itemPrice.tr(),
value: price, value: price,
@ -121,6 +113,15 @@ class _CreateItemPageState extends State<CreateItemPage> {
}, },
), ),
12.height, 12.height,
TxtField(
hint: LocaleKeys.itemDescription.tr(),
value: description,
maxLines: 3,
onChanged: (v) {
description = v;
},
),
12.height,
if (pickedImage.isNotEmpty) ...[ if (pickedImage.isNotEmpty) ...[
PickedFilesContainer( PickedFilesContainer(
pickedFiles: pickedImage, pickedFiles: pickedImage,

@ -105,6 +105,7 @@ class HomeFragment extends StatelessWidget {
}, },
).horPaddingMain(), ).horPaddingMain(),
AdsListWidget( AdsListWidget(
isDraftAds: false,
shouldShowAdStatus: true, shouldShowAdStatus: true,
isAdsFragment: false, isAdsFragment: false,
adsList: adVM.myActiveAdsForHome, adsList: adVM.myActiveAdsForHome,
@ -128,6 +129,7 @@ class HomeFragment extends StatelessWidget {
}, },
).horPaddingMain(), ).horPaddingMain(),
AdsListWidget( AdsListWidget(
isDraftAds: false,
shouldShowAdStatus: false, shouldShowAdStatus: false,
adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds, adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds,
isAdsFragment: false, isAdsFragment: false,

Loading…
Cancel
Save