16 April, 2025

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

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

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

@ -155,6 +155,7 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
),
8.height,
ChipsPickerItem(
isNeedLabelOnTop: true,
hint: LocaleKeys.select_Services.tr(),
itemsList: [...scheduleVM.selectedServicesItems],
onClick: () {
@ -248,6 +249,7 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
),
8.height,
ChipsPickerItem(
isNeedLabelOnTop: true,
hint: LocaleKeys.offDays.tr(),
itemsList: [...scheduleVM.selectedDaysItems],
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/utils/date_helper.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/utils.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!);
Utils.hideLoading(context);
if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_deleted.tr());
Utils.showToast(LocaleKeys.scheduleDeletedSuccessfully.tr());
} else {
Utils.showToast(res.message ?? "");
}
@ -94,62 +95,67 @@ class _SchedulesListPageState extends State<SchedulesListPage> {
? EmptyWidget(
text: LocaleKeys.noSchedulesFound.tr(),
).paddingAll(21)
: ListView.separated(
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;
: RefreshIndicator(
onRefresh: () async {
await scheduleVM.getSchedules(widget.branchId ?? "");
},
padding: const EdgeInsets.all(20),
itemCount: scheduleVM.schedule!.data!.length,
child: ListView.separated(
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: () {
navigateWithName(context, AppRoutes.addSchedule, arguments: ScheduleData(branchId: widget.branchId ?? ""));
},
),
),
],
),
),

@ -15,54 +15,74 @@ class PickerItem {
}
class ChipsPickerItem extends StatelessWidget {
final bool isNeedLabelOnTop;
final String hint;
final List<PickerItem> itemsList;
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
Widget build(BuildContext context) {
return Row(
return Column(
children: [
if (itemsList.isEmpty)
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,
],
),
if (isNeedLabelOnTop && hint.isNotEmpty) ...[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
(hint).toText(
color: borderColor,
fontSize: 13,
fontWeight: MyFonts.Medium,
),
],
),
const Icon(
Icons.arrow_forward_ios_rounded,
size: 16,
color: MyColors.lightIconColor,
),
4.height,
],
Row(
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}) {

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

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

Loading…
Cancel
Save