Added Services Widget on HomeScreen

aamir_dev
faizatflutter 1 year ago
parent 27c964fc1c
commit 803e81dbc9

@ -753,8 +753,9 @@
"done": "تم", "done": "تم",
"notice": "إشعار", "notice": "إشعار",
"serviceDeactivated": "تم تعطيل الخدمة", "serviceDeactivated": "تم تعطيل الخدمة",
"totalNumberOfServices": "إجمالي عدد الخدمات:", "totalNumberOfServices": "عدد الخدمات:",
"noAvailableOfficesInCity": "لا توجد مكاتب متاحة في مدينتك لخدمتك.", "noAvailableOfficesInCity": "لا توجد مكاتب متاحة في مدينتك لخدمتك.",
"searchByItem": "البحث حسب العنصر" "searchByItem": "البحث حسب العنصر",
"selectBranchToCopyServices": "حدد الفرع لنسخ العناصر الخاصة بهم إلى هذا الفرع. يمكنك تعديل الاختيار في أي وقت.",
"tapToSelect": "Tap to select"
} }

@ -751,7 +751,9 @@
"done": "Done", "done": "Done",
"notice": "Notice", "notice": "Notice",
"serviceDeactivated": "Service Deactivated", "serviceDeactivated": "Service Deactivated",
"totalNumberOfServices": "Total number of services:", "totalNumberOfServices": "Number of services:",
"noAvailableOfficesInCity": "There are no available offices in your city for your service.", "noAvailableOfficesInCity": "There are no available offices in your city for your service.",
"searchByItem": "Search By Item" "searchByItem": "Search By Item",
"selectBranchToCopyServices": "Select the branch to copy their items to this branch. You can modify the selection at any time.",
"tapToSelect": "Tap to select"
} }

@ -769,10 +769,11 @@ class CodegenLoader extends AssetLoader{
"done": "تم", "done": "تم",
"notice": "إشعار", "notice": "إشعار",
"serviceDeactivated": "تم تعطيل الخدمة", "serviceDeactivated": "تم تعطيل الخدمة",
"totalNumberOfServices": "إجمالي عدد الخدمات:", "totalNumberOfServices": "عدد الخدمات:",
"noAvailableOfficesInCity": "لا توجد مكاتب متاحة في مدينتك لخدمتك." "noAvailableOfficesInCity": "لا توجد مكاتب متاحة في مدينتك لخدمتك.",
"you": "أنتم", "searchByItem": "البحث حسب العنصر",
"searchByItem": "البحث حسب العنصر" "selectBranchToCopyServices": "حدد الفرع لنسخ العناصر الخاصة بهم إلى هذا الفرع. يمكنك تعديل الاختيار في أي وقت.",
"tapToSelect": "Tap to select"
}; };
static const Map<String,dynamic> en_US = { static const Map<String,dynamic> en_US = {
"firstTimeLogIn": "First Time Log In", "firstTimeLogIn": "First Time Log In",
@ -1527,10 +1528,11 @@ static const Map<String,dynamic> en_US = {
"done": "Done", "done": "Done",
"notice": "Notice", "notice": "Notice",
"serviceDeactivated": "Service Deactivated", "serviceDeactivated": "Service Deactivated",
"totalNumberOfServices": "Total number of services:", "totalNumberOfServices": "Number of services:",
"noAvailableOfficesInCity": "There are no available offices in your city for your service." "noAvailableOfficesInCity": "There are no available offices in your city for your service.",
"you": "You", "searchByItem": "Search By Item",
"searchByItem": "Search By Item" "selectBranchToCopyServices": "Select the branch to copy their items to this branch. You can modify the selection at any time.",
"tapToSelect": "Tap to select"
}; };
static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; static const Map<String, Map<String,dynamic>> mapLocales = {"ar_SA": ar_SA, "en_US": en_US};
} }

@ -735,5 +735,7 @@ abstract class LocaleKeys {
static const totalNumberOfServices = 'totalNumberOfServices'; static const totalNumberOfServices = 'totalNumberOfServices';
static const noAvailableOfficesInCity = 'noAvailableOfficesInCity'; static const noAvailableOfficesInCity = 'noAvailableOfficesInCity';
static const searchByItem = 'searchByItem'; static const searchByItem = 'searchByItem';
static const selectBranchToCopyServices = 'selectBranchToCopyServices';
static const tapToSelect = 'tapToSelect';
} }

@ -1,9 +1,10 @@
class FilterListModel { class FilterListModel {
String title; String title;
String iconUrl;
int id; int id;
bool isSelected; bool isSelected;
FilterListModel({required this.id, required this.isSelected, required this.title}); FilterListModel({required this.id, required this.isSelected, this.iconUrl = "", required this.title});
} }
class SelectionModel { class SelectionModel {

@ -259,7 +259,7 @@ class AppointmentsVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
List<FilterListModel> branchesFilterOptions = []; List<FilterListModel> branchesCategoriesFilterOptions = [];
List<ServiceModel> servicesInCurrentAppointment = []; List<ServiceModel> servicesInCurrentAppointment = [];
ServiceModel? currentServiceSelection; ServiceModel? currentServiceSelection;
@ -478,6 +478,7 @@ class AppointmentsVM extends BaseVM {
(element.appointmentStatusEnum == AppointmentStatusEnum.confirmed || element.appointmentStatusEnum == AppointmentStatusEnum.booked) && (element.appointmentStatusEnum == AppointmentStatusEnum.confirmed || element.appointmentStatusEnum == AppointmentStatusEnum.booked) &&
(DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now()))) (DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now())))
.toList(); .toList();
notifyListeners();
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true); applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true);
setState(ViewState.idle); setState(ViewState.idle);
} }
@ -626,13 +627,13 @@ class AppointmentsVM extends BaseVM {
} }
Future<void> applyFilterOnBranches({required int index}) async { Future<void> applyFilterOnBranches({required int index}) async {
if (branchesFilterOptions.isEmpty) return; if (branchesCategoriesFilterOptions.isEmpty) return;
for (var value in branchesFilterOptions) { for (var value in branchesCategoriesFilterOptions) {
value.isSelected = false; value.isSelected = false;
} }
branchesFilterOptions[index].isSelected = true; branchesCategoriesFilterOptions[index].isSelected = true;
await getBranchesBasedOnCategoryFilters(categoryId: branchesFilterOptions[index].id); await getBranchesBasedOnCategoryFilters(categoryId: branchesCategoriesFilterOptions[index].id);
notifyListeners(); notifyListeners();
} }
@ -1019,14 +1020,14 @@ class AppointmentsVM extends BaseVM {
List<ServiceModel> branchServices = []; List<ServiceModel> branchServices = [];
Future<void> populateBranchesFilterList() async { Future<void> populateBranchesFilterList() async {
if (branchesFilterOptions.isNotEmpty) return; if (branchesCategoriesFilterOptions.isNotEmpty) return;
branchesFilterOptions.clear(); branchesCategoriesFilterOptions.clear();
setOnlyState(ViewState.busy); setOnlyState(ViewState.busy);
Category category = await branchRepo.fetchBranchCategory(); Category category = await branchRepo.fetchBranchCategory();
category.data?.forEach((element) { category.data?.forEach((element) {
branchesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, title: element.categoryName ?? "N/A")); branchesCategoriesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, iconUrl: element.serviceCategoryIconUrl ?? "", title: element.categoryName ?? "N/A"));
}); });
branchesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches")); branchesCategoriesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches"));
notifyListeners(); notifyListeners();
setState(ViewState.idle); setState(ViewState.idle);
} }
@ -1036,7 +1037,7 @@ class AppointmentsVM extends BaseVM {
if (isNeedToRebuild) setState(ViewState.busy); if (isNeedToRebuild) setState(ViewState.busy);
if (isFromRefresh) { if (isFromRefresh) {
var selectedFilter = branchesFilterOptions.firstWhere((element) => element.isSelected); var selectedFilter = branchesCategoriesFilterOptions.firstWhere((element) => element.isSelected);
log("selectedFilter: ${selectedFilter.id}"); log("selectedFilter: ${selectedFilter.id}");
if (selectedFilter.id == 0) { if (selectedFilter.id == 0) {

@ -21,12 +21,14 @@ class AdsListWidget extends StatelessWidget {
final ScrollPhysics? scrollPhysics; final ScrollPhysics? scrollPhysics;
final bool isAdsFragment; final bool isAdsFragment;
final bool shouldShowAdStatus; final bool shouldShowAdStatus;
final Function() onFetchMoreAds;
const AdsListWidget({ const AdsListWidget({
super.key, super.key,
required this.adsList, required this.adsList,
this.scrollPhysics,
required this.shouldShowAdStatus, required this.shouldShowAdStatus,
required this.onFetchMoreAds,
this.scrollPhysics,
this.isAdsFragment = false, this.isAdsFragment = false,
}); });

@ -26,7 +26,7 @@ import 'package:sizer/sizer.dart';
class CommonAppointmentSliderWidget extends StatelessWidget { class CommonAppointmentSliderWidget extends StatelessWidget {
final Function(AppointmentListModel)? onAppointmentClick; final Function(AppointmentListModel)? onAppointmentClick;
const CommonAppointmentSliderWidget({Key? key, this.onAppointmentClick}) : super(key: key); const CommonAppointmentSliderWidget({super.key, this.onAppointmentClick});
Widget getCarouselSliderWidget(AppType appType, AppointmentsVM appointmentsVM) { Widget getCarouselSliderWidget(AppType appType, AppointmentsVM appointmentsVM) {
return CarouselSlider.builder( return CarouselSlider.builder(
@ -95,7 +95,7 @@ class AppointmentHomeTileWidget extends StatelessWidget {
final AppointmentListModel? appointmentListModel; final AppointmentListModel? appointmentListModel;
final Function()? onTapped; final Function()? onTapped;
const AppointmentHomeTileWidget({Key? key, this.isForProvider = false, this.onTapped, required this.appointmentListModel, this.isForCustomerHome = false}) : super(key: key); const AppointmentHomeTileWidget({super.key, this.isForProvider = false, this.onTapped, required this.appointmentListModel, this.isForCustomerHome = false});
Widget showServices(String title, String icon, {bool isMoreText = false}) { Widget showServices(String title, String icon, {bool isMoreText = false}) {
return Row( return Row(
@ -227,7 +227,7 @@ class AppointmentFragmentTileWidget extends StatelessWidget {
final AppointmentListModel? appointmentListModel; final AppointmentListModel? appointmentListModel;
final Function()? onTapped; final Function()? onTapped;
const AppointmentFragmentTileWidget({Key? key, this.onTapped, required this.appointmentListModel}) : super(key: key); const AppointmentFragmentTileWidget({super.key, this.onTapped, required this.appointmentListModel});
Widget showServices(String title, String icon, {bool isMoreText = false}) { Widget showServices(String title, String icon, {bool isMoreText = false}) {
return Row( return Row(

@ -135,7 +135,12 @@ class AdsFragment extends StatelessWidget {
}, },
child: adVM.state == ViewState.busy child: adVM.state == ViewState.busy
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: AdsListWidget(isAdsFragment: true, shouldShowAdStatus: !adVM.isExploreAdsTapped, adsList: getAdsList(adVM)), : AdsListWidget(
isAdsFragment: true,
shouldShowAdStatus: !adVM.isExploreAdsTapped,
adsList: getAdsList(adVM),
onFetchMoreAds: () {},
),
), ),
) )
], ],

@ -1,14 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
class DropDownText extends StatelessWidget { class DropDownText extends StatelessWidget {
String title; final String title;
final bool showDropDownIcon;
DropDownText(this.title, {super.key}); DropDownText({required this.title, required this.showDropDownIcon, super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -20,7 +19,8 @@ class DropDownText extends StatelessWidget {
fontSize: 16, fontSize: 16,
letterSpacing: -0.64, letterSpacing: -0.64,
), ),
const Icon(Icons.keyboard_arrow_down_outlined), if (showDropDownIcon)
const Icon(Icons.keyboard_arrow_down_outlined),
], ],
).toContainer( ).toContainer(
isEnabledBorder: true, isEnabledBorder: true,

Loading…
Cancel
Save