Merge pull request 'Ad Module Completion' (#3) from faiz_development into master
Reviewed-on: http://34.17.52.79/Haroon6138/car_customer_app/pulls/3mirza_development
commit
1c78b0e134
@ -1,10 +1,12 @@
|
|||||||
import 'package:car_customer_app/repositories/provider_repo.dart';
|
import 'package:car_customer_app/repositories/provider_repo.dart';
|
||||||
|
import 'package:car_customer_app/repositories/schedule_repo.dart';
|
||||||
import 'package:mc_common_app/config/dependencies.dart';
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
|
||||||
class CustomerDependencies {
|
class CustomerDependencies {
|
||||||
static void addDependencies() {
|
static void addDependencies() {
|
||||||
AppDependencies.addDependencies();
|
AppDependencies.addDependencies();
|
||||||
injector.registerSingleton<ProviderRepo>(() => ProviderRepoImp());
|
injector.registerSingleton<ProviderRepo>(() => ProviderRepoImp());
|
||||||
|
injector.registerSingleton<ScheduleRepo>(() => ScheduleRepoImp());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,51 +1,55 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:mc_common_app/models/model/provider_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services/item_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services/near_branch_model.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
import 'package:mc_common_app/api/api_client.dart';
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
import 'package:mc_common_app/classes/app_state.dart';
|
||||||
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
import 'package:mc_common_app/config/dependencies.dart';
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
import 'package:mc_common_app/models/generic_resp_model.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
||||||
|
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart';
|
||||||
|
import 'package:mc_common_app/models/services/item_model.dart';
|
||||||
|
|
||||||
abstract class ProviderRepo {
|
abstract class ProviderRepo {
|
||||||
Future<NearBrancheModel> getAllNearBranchAndServices();
|
Future<List<BranchDetailModel>> getAllNearBranchAndServices();
|
||||||
|
|
||||||
Future<ItemModel> getServiceItems(int serviceId);
|
Future<List<ItemData>> getServiceItems(int serviceId);
|
||||||
|
|
||||||
Future<ProviderModel> getBranchAndServices(int providerId);
|
Future<ProviderProfileModel> getBranchAndServices(int providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProviderRepoImp implements ProviderRepo {
|
class ProviderRepoImp implements ProviderRepo {
|
||||||
|
ApiClient apiClient = injector.get<ApiClient>();
|
||||||
|
AppState appState = injector.get<AppState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<NearBrancheModel> getAllNearBranchAndServices() async {
|
Future<List<BranchDetailModel>> getAllNearBranchAndServices() async {
|
||||||
// var postParams = {"serviceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
GenericRespModel adsGenericModel = await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.GetAllNearBranches, token: appState.getUser.data!.accessToken);
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
List<BranchDetailModel> nearBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
||||||
return await injector.get<ApiClient>().getJsonForObject((json) => NearBrancheModel.fromJson(json), ApiConsts.GetAllNearBranches, token: t);
|
return nearBranches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ItemModel> getServiceItems(int serviceId) async {
|
Future<List<ItemData>> getServiceItems(int serviceId) async {
|
||||||
var queryParameters = {
|
var queryParameters = {
|
||||||
"ServiceProviderServiceID": serviceId.toString(),
|
"ServiceProviderServiceID": serviceId.toString(),
|
||||||
};
|
};
|
||||||
String? token = AppState().getUser.data?.accessToken;
|
|
||||||
debugPrint(token);
|
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
||||||
return await injector
|
(json) => GenericRespModel.fromJson(json),
|
||||||
.get<ApiClient>()
|
ApiConsts.getServiceItems,
|
||||||
.getJsonForObject((json) => ItemModel.fromJson(json), ApiConsts.getServiceItems, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
token: appState.getUser.data!.accessToken,
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
);
|
||||||
|
List<ItemData> serviceItems = List.generate(adsGenericModel.data.length, (index) => ItemData.fromJson(adsGenericModel.data[index]));
|
||||||
|
return serviceItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ProviderModel> getBranchAndServices(int providerId) async {
|
Future<ProviderProfileModel> getBranchAndServices(int providerId) async {
|
||||||
var postParams = {"serviceProviderID": providerId.toString()};
|
var postParams = {"serviceProviderID": providerId.toString()};
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
GenericRespModel adsGenericModel =
|
||||||
return await injector.get<ApiClient>().getJsonForObject((json) => ProviderModel.fromJson(json), ApiConsts.BranchesAndServices, queryParameters: postParams, token: t);
|
await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.BranchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams);
|
||||||
|
|
||||||
|
return ProviderProfileModel.fromJson(adsGenericModel.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,88 @@
|
|||||||
|
import 'package:mc_common_app/api/api_client.dart';
|
||||||
|
import 'package:mc_common_app/classes/app_state.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
import 'package:mc_common_app/models/generic_resp_model.dart';
|
||||||
|
import 'package:mc_common_app/models/m_response.dart';
|
||||||
|
import 'package:mc_common_app/models/provider_branches_models/profile/services.dart';
|
||||||
|
import 'package:mc_common_app/models/schedule_model.dart';
|
||||||
|
import 'package:mc_common_app/models/service_schedule_model.dart';
|
||||||
|
|
||||||
|
abstract class ScheduleRepo {
|
||||||
|
Future<Services> getAllServices(String branchId);
|
||||||
|
|
||||||
|
Future<MResponse> createSchedule(Map map);
|
||||||
|
|
||||||
|
Future<MResponse> addServicesInSchedule(Map map);
|
||||||
|
|
||||||
|
Future<MResponse> updateSchedule(Map map);
|
||||||
|
|
||||||
|
Future<List<ScheduleData>> getSchedules(String branchId);
|
||||||
|
|
||||||
|
Future<MResponse> updateServicesInSchedule(Map map);
|
||||||
|
|
||||||
|
Future<List<ServiceAppointmentScheduleModel>> mergeServiceIntoAvailableSchedules({required List<String> serviceItemIds});
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScheduleRepoImp implements ScheduleRepo {
|
||||||
|
@override
|
||||||
|
Future<Services> getAllServices(String branchId) async {
|
||||||
|
Map<String, dynamic> map = {"ProviderBranchID": branchId};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.getServicesOfBranch, token: t, queryParameters: map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> createSchedule(Map map) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createSchedule, map, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> addServicesInSchedule(Map map) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createGroup, map, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<ScheduleData>> getSchedules(String branchId) async {
|
||||||
|
Map<String, dynamic> map = {"ServiceProviderBranchID": branchId};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
|
||||||
|
GenericRespModel adsGenericModel = await injector.get<ApiClient>().getJsonForObject(
|
||||||
|
(json) => GenericRespModel.fromJson(json),
|
||||||
|
ApiConsts.getSchedule,
|
||||||
|
token: t,
|
||||||
|
queryParameters: map,
|
||||||
|
);
|
||||||
|
|
||||||
|
return List.generate(adsGenericModel.data.length, (index) => ScheduleData.fromJson(adsGenericModel.data[index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> updateSchedule(Map map) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateSchedule, map, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MResponse> updateServicesInSchedule(Map map) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.updateGroup, map, token: t);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ServiceAppointmentScheduleModel>> mergeServiceIntoAvailableSchedules({required List<String> serviceItemIds}) async {
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
var dummyServiceIds = ["3", "2"];
|
||||||
|
var queryParameters = {"ServiceItemIDs": dummyServiceIds};
|
||||||
|
GenericRespModel adsGenericModel = await injector.get<ApiClient>().getJsonForObject(
|
||||||
|
(json) => GenericRespModel.fromJson(json),
|
||||||
|
ApiConsts.GetServiceItemAppointmentScheduleSlots,
|
||||||
|
token: t,
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
);
|
||||||
|
List<ServiceAppointmentScheduleModel> serviceAppointmentScheduleModel =
|
||||||
|
List.generate(adsGenericModel.data.length, (index) => ServiceAppointmentScheduleModel.fromJson(adsGenericModel.data[index]));
|
||||||
|
return serviceAppointmentScheduleModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,67 +0,0 @@
|
|||||||
import 'package:mc_common_app/models/model/provider_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services/item_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services/near_branch_model.dart';
|
|
||||||
import 'package:car_customer_app/repositories/provider_repo.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:mc_common_app/models/widgets_models.dart';
|
|
||||||
import 'package:mc_common_app/repositories/common_repo.dart';
|
|
||||||
import 'package:mc_common_app/services/common_services.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
import 'package:mc_common_app/view_models/base_view_model.dart';
|
|
||||||
|
|
||||||
class ProvidersVM extends BaseVM {
|
|
||||||
final CommonRepo commonRepo;
|
|
||||||
final CommonAppServices commonServices;
|
|
||||||
final ProviderRepo providerRepo;
|
|
||||||
|
|
||||||
ProvidersVM({required this.commonServices, required this.commonRepo, required this.providerRepo});
|
|
||||||
|
|
||||||
List<FilterListModel> providersFilterOptions = [];
|
|
||||||
NearBrancheModel? branches;
|
|
||||||
ItemModel? serviceItems;
|
|
||||||
ProviderModel? providerModel;
|
|
||||||
|
|
||||||
populateProvidersFilterList() {
|
|
||||||
providersFilterOptions.clear();
|
|
||||||
providersFilterOptions = [
|
|
||||||
FilterListModel(title: "All Providers", isSelected: true, id: -1),
|
|
||||||
FilterListModel(title: "Maintenance", isSelected: false, id: 0),
|
|
||||||
FilterListModel(title: "Oil Service", isSelected: false, id: 1),
|
|
||||||
FilterListModel(title: "Accessories", isSelected: false, id: 2),
|
|
||||||
FilterListModel(title: "Tire Service", isSelected: false, id: 3),
|
|
||||||
FilterListModel(title: "Dent and Paint", isSelected: false, id: 4),
|
|
||||||
];
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
applyFilterOnProviders({required int index}) {
|
|
||||||
if (providersFilterOptions.isEmpty) return;
|
|
||||||
for (var value in providersFilterOptions) {
|
|
||||||
value.isSelected = false;
|
|
||||||
}
|
|
||||||
providersFilterOptions[index].isSelected = true;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create new branch
|
|
||||||
getAllNearBranches({bool isNeedToRebuild = false}) async {
|
|
||||||
//TODO: needs to lat,long into API
|
|
||||||
branches = null;
|
|
||||||
if (isNeedToRebuild) setState(ViewState.busy);
|
|
||||||
branches = await providerRepo.getAllNearBranchAndServices();
|
|
||||||
setState(ViewState.idle);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ItemModel?> getServiceItems(int serviceId) async {
|
|
||||||
serviceItems = null;
|
|
||||||
serviceItems = await providerRepo.getServiceItems(serviceId);
|
|
||||||
setState(ViewState.idle);
|
|
||||||
return serviceItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
getBranchAndServices(int providerId) async {
|
|
||||||
providerModel = null;
|
|
||||||
providerModel = await providerRepo.getBranchAndServices(providerId);
|
|
||||||
setState(ViewState.idle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
||||||
|
import 'package:car_customer_app/views/appointments/widgets/service_item_with_price_checkbox.dart';
|
||||||
|
import 'package:flutter/material.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';
|
||||||
|
import 'package:mc_common_app/models/services/item_model.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.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';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class BookAppointmentsItemView extends StatelessWidget {
|
||||||
|
const BookAppointmentsItemView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: "Select Services",
|
||||||
|
isRemoveBackButton: false,
|
||||||
|
isDrawerEnabled: false,
|
||||||
|
actions: [MyAssets.searchIcon.buildSvg().paddingOnly(right: 21)],
|
||||||
|
onBackButtonTapped: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
body: Consumer(
|
||||||
|
builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 40,
|
||||||
|
width: double.infinity,
|
||||||
|
color: MyColors.darkTextColor,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: "${appointmentsVM.selectedSubServicesCounter} Item(s) Selected".toText(fontSize: 16, color: MyColors.white).horPaddingMain(),
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
"Few services are not available on home location. Change the location to workshop to full access the services".toText(fontSize: 12, isItalic: true, color: MyColors.lightTextColor),
|
||||||
|
8.height,
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Change location or service: ".toText(fontSize: 14, isBold: true),
|
||||||
|
"Edit".toText(fontSize: 14, isBold: true, isUnderLine: true, color: MyColors.adPendingStatusColor),
|
||||||
|
5.width,
|
||||||
|
MyAssets.icEdit.buildSvg(width: 17),
|
||||||
|
],
|
||||||
|
).onPress(() {}),
|
||||||
|
16.height,
|
||||||
|
Divider(),
|
||||||
|
],
|
||||||
|
).horPaddingMain(),
|
||||||
|
appointmentsVM.serviceItems.isEmpty
|
||||||
|
? Expanded(child: Center(child: "No Items to show.".toText(fontSize: 16, color: MyColors.lightTextColor)))
|
||||||
|
: ListView.separated(
|
||||||
|
separatorBuilder: (BuildContext context, int index) => Divider(),
|
||||||
|
itemCount: appointmentsVM.serviceItems.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
ItemData itemData = appointmentsVM.serviceItems[index];
|
||||||
|
return ServiceItemWithPriceCheckBox(
|
||||||
|
description: "Some description about the sub-services",
|
||||||
|
title: itemData.name!,
|
||||||
|
isSelected: itemData.isUpdateOrSelected!,
|
||||||
|
onSelection: (bool value) {
|
||||||
|
appointmentsVM.onItemUpdateOrSelected(index, !itemData.isUpdateOrSelected!, itemData.id!);
|
||||||
|
},
|
||||||
|
priceWidget: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// TODO: This Price will be decided according to the service selected
|
||||||
|
itemData.price!.split(".").first.toText(fontSize: 30, isBold: true),
|
||||||
|
" SAR".toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).expand(),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 0.7,
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
if (appointmentsVM.selectSubServicesError != "")
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
appointmentsVM.selectSubServicesError.toText(fontSize: 14, color: Colors.red),
|
||||||
|
],
|
||||||
|
).paddingOnly(right: 10),
|
||||||
|
8.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowFillButton(
|
||||||
|
txtColor: MyColors.black,
|
||||||
|
maxHeight: 55,
|
||||||
|
title: "Cancel",
|
||||||
|
onPressed: () {
|
||||||
|
appointmentsVM.resetCategorySelectionBottomSheet();
|
||||||
|
pop(context);
|
||||||
|
},
|
||||||
|
backgroundColor: MyColors.greyButtonColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
Expanded(
|
||||||
|
child: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ShowFillButton(
|
||||||
|
maxHeight: 55,
|
||||||
|
title: "Next",
|
||||||
|
onPressed: () async {
|
||||||
|
bool resp = appointmentsVM.onSubServicesNextPressed();
|
||||||
|
if (resp) {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
await appointmentsVM.mergeServiceIntoAvailableSchedules();
|
||||||
|
appointmentsVM.resetCategorySelectionBottomSheet();
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.bookAppointmenServicesView, (Route<dynamic> route) => false);
|
||||||
|
|
||||||
|
// appointmentsVM.mergeServiceInAvailableSchedule();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
backgroundColor: !appointmentsVM.isServiceSelectionValidated() ? MyColors.lightTextColor.withOpacity(0.6) : MyColors.primaryColor,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).horPaddingMain(),
|
||||||
|
16.height,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,325 @@
|
|||||||
|
import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.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/models/service_schedule_model.dart';
|
||||||
|
import 'package:mc_common_app/models/services/item_model.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.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/dropdown/dropdow_field.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ReviewAppointment extends StatelessWidget {
|
||||||
|
const ReviewAppointment({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
Widget buildBranchInfoCard({required BuildContext context}) {
|
||||||
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
bottom: 10,
|
||||||
|
left: 21,
|
||||||
|
right: 21,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
MyAssets.bnCar,
|
||||||
|
width: 80,
|
||||||
|
height: 60,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(appointmentsVM.selectedBranchModel!.branchName ?? "").toText(fontSize: 16, isBold: true),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
LocaleKeys.location.tr().toText(color: MyColors.lightTextColor, fontSize: 12),
|
||||||
|
2.width,
|
||||||
|
": ${appointmentsVM.selectedBranchModel!.branchDescription ?? ""}".toText(fontSize: 12),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"4.9".toText(
|
||||||
|
isUnderLine: true,
|
||||||
|
isBold: true,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
2.width,
|
||||||
|
MyAssets.starIcon.buildSvg(width: 12),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).onPress(() {}).toWhiteContainer(width: double.infinity, allPading: 12));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildServicesInfoCard({required BuildContext context}) {
|
||||||
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: appointmentsVM.serviceAppointmentScheduleList.length,
|
||||||
|
itemBuilder: (BuildContext context, int scheduleIndex) {
|
||||||
|
ServiceAppointmentScheduleModel scheduleData = appointmentsVM.serviceAppointmentScheduleList[scheduleIndex];
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: "Schedule: ${scheduleIndex + 1}".toText(fontSize: 20, isBold: true),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ListView.separated(
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: appointmentsVM.servicesInSchedule.length,
|
||||||
|
itemBuilder: (BuildContext context, int serviceIndex) {
|
||||||
|
DropValue selectedService = appointmentsVM.servicesInSchedule[serviceIndex];
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: selectedService.value.toText(fontSize: 15, isBold: true),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (true) ...[
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Service Location: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
("Home").toText(fontSize: 12, isBold: true).expand(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
5.height,
|
||||||
|
Column(
|
||||||
|
children: List.generate(scheduleData.serviceItemList!.length, (itemIndex) {
|
||||||
|
ItemData itemData = scheduleData.serviceItemList![itemIndex];
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"${itemData.name}: ".toText(fontSize: 13, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) => Divider(thickness: 2),
|
||||||
|
).paddingOnly(bottom: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 10));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
||||||
|
// return SizedBox(
|
||||||
|
// width: double.infinity,
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: List.generate(
|
||||||
|
// appointmentsVM.servicesInSchedule.length,
|
||||||
|
// (serviceIndex) => Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// appointmentsVM.servicesInSchedule[serviceIndex].value.toText(fontSize: 16, isBold: true),
|
||||||
|
// Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: List.generate(
|
||||||
|
// appointmentsVM,
|
||||||
|
// (index) => itemList[index].toText(
|
||||||
|
// fontSize: 12,
|
||||||
|
// color: MyColors.lightTextColor,
|
||||||
|
// isBold: true,
|
||||||
|
// )),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ).paddingOnly(bottom: 14),
|
||||||
|
// ),
|
||||||
|
// ).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.symmetric(horizontal: 21)),
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildTimeAndLocationInfoCard() {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Time & Location".toText(fontSize: 16, isBold: true),
|
||||||
|
3.height,
|
||||||
|
Row(children: [
|
||||||
|
"Date & Time: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
"2nd Feb, 2023 at 09:30 AM".toText(fontSize: 12, isBold: true),
|
||||||
|
]),
|
||||||
|
Row(children: [
|
||||||
|
"Location: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
"PM58+F97, Al Olaya, Riyadh 12333".toText(fontSize: 12, isBold: true),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.only(left: 21, right: 21, top: 10)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildChargesBreakDown({required BuildContext context}) {
|
||||||
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
||||||
|
List<ItemData> allSelectedItems = [];
|
||||||
|
double totalServicePrice = 0.0;
|
||||||
|
appointmentsVM.serviceAppointmentScheduleList.forEach((schedule) {
|
||||||
|
schedule.serviceItemList!.forEach((item) {
|
||||||
|
allSelectedItems.add(item);
|
||||||
|
totalServicePrice = totalServicePrice + double.parse(item.price!);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Services".toText(fontSize: 16, isBold: true),
|
||||||
|
Column(
|
||||||
|
children: List.generate(
|
||||||
|
allSelectedItems.length,
|
||||||
|
(index) => Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
"${allSelectedItems[index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
"${allSelectedItems[index].price} SAR".toText(fontSize: 12, isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
"${totalServicePrice.toString()} SAR".toText(fontSize: 16, isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Divider(thickness: 0.7),
|
||||||
|
"Home Location".toText(fontSize: 16, isBold: true),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
"10km ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||||
|
"5 x 10".toText(fontSize: 12, isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
"50 SAR".toText(fontSize: 16, isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Divider(
|
||||||
|
thickness: 0.7,
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
"Total Amount ".toText(fontSize: 16, isBold: true),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
"120".toText(fontSize: 29, isBold: true),
|
||||||
|
2.width,
|
||||||
|
"SAR".toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
],
|
||||||
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.only(left: 21, right: 21, top: 10, bottom: 21));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildNextButtonFooter() {
|
||||||
|
return Container(
|
||||||
|
height: 90,
|
||||||
|
color: MyColors.white,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Divider(thickness: 0.7, height: 3),
|
||||||
|
10.height,
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ShowFillButton(
|
||||||
|
maxHeight: 55,
|
||||||
|
backgroundColor: MyColors.primaryColor,
|
||||||
|
title: "Book Appointment",
|
||||||
|
onPressed: () {},
|
||||||
|
).paddingOnly(bottom: 12, left: 21, right: 21),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: "Review Appointment",
|
||||||
|
isRemoveBackButton: false,
|
||||||
|
isDrawerEnabled: false,
|
||||||
|
actions: [MyAssets.searchIcon.buildSvg().paddingOnly(right: 21)],
|
||||||
|
onBackButtonTapped: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
body: Stack(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
children: [
|
||||||
|
SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
buildBranchInfoCard(context: context),
|
||||||
|
buildServicesInfoCard(context: context),
|
||||||
|
buildTimeAndLocationInfoCard(),
|
||||||
|
buildChargesBreakDown(context: context),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
buildNextButtonFooter(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,194 @@
|
|||||||
|
import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
||||||
|
import 'package:flutter/material.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';
|
||||||
|
import 'package:mc_common_app/models/widgets_models.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/utils/navigator.dart';
|
||||||
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
||||||
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.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';
|
||||||
|
|
||||||
|
class AppointmentServicePickBottomSheet extends StatelessWidget {
|
||||||
|
const AppointmentServicePickBottomSheet({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
AppointmentsVM appointmentsVM = context.watch<AppointmentsVM>();
|
||||||
|
return SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.85,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.all(8),
|
||||||
|
height: 8,
|
||||||
|
width: 60,
|
||||||
|
decoration: const BoxDecoration(color: MyColors.lightTextColor, borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
"Select Category".toText(fontSize: 24, isBold: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
30.height,
|
||||||
|
Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
return DropdownField(
|
||||||
|
(DropValue value) => appointmentsVM.updateProviderCategoryId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)),
|
||||||
|
list: appointmentsVM.branchCategories,
|
||||||
|
hint: "Select Category",
|
||||||
|
dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1
|
||||||
|
? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "")
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (appointmentsVM.isFetchingServices) ...[
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [const CircularProgressIndicator().paddingAll(10)],
|
||||||
|
),
|
||||||
|
] else if (appointmentsVM.branchServices.isNotEmpty) ...[
|
||||||
|
8.height,
|
||||||
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
List<DropValue> serviceCategories = [];
|
||||||
|
for (var element in appointmentsVM.branchServices) {
|
||||||
|
if (element.categoryId == appointmentsVM.branchSelectedCategoryId.selectedId) {
|
||||||
|
serviceCategories.add(DropValue(
|
||||||
|
element.serviceProviderServiceId ?? 0,
|
||||||
|
element.serviceDescription!,
|
||||||
|
"",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DropdownField(
|
||||||
|
(DropValue value) => appointmentsVM.updateBranchServiceId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)),
|
||||||
|
list: serviceCategories,
|
||||||
|
hint: "Select Service",
|
||||||
|
dropdownValue: appointmentsVM.branchSelectedServiceId.selectedId != -1
|
||||||
|
? DropValue(appointmentsVM.branchSelectedServiceId.selectedId, appointmentsVM.branchSelectedServiceId.selectedOption, "")
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (appointmentsVM.branchSelectedServiceId.selectedId != -1 && !appointmentsVM.isFetchingServices) ...[
|
||||||
|
16.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
"Select Service Location".toText(
|
||||||
|
fontSize: 16,
|
||||||
|
isBold: true,
|
||||||
|
color: MyColors.black,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ShowFillButton(
|
||||||
|
isFilled: appointmentsVM.isHomeTapped,
|
||||||
|
maxHeight: 48,
|
||||||
|
title: "Home",
|
||||||
|
txtColor: appointmentsVM.isHomeTapped ? MyColors.white : MyColors.darkTextColor,
|
||||||
|
onPressed: () => appointmentsVM.updateIsHomeTapped(true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
Expanded(
|
||||||
|
child: ShowFillButton(
|
||||||
|
isFilled: !appointmentsVM.isHomeTapped,
|
||||||
|
txtColor: !appointmentsVM.isHomeTapped ? MyColors.white : MyColors.darkTextColor,
|
||||||
|
maxHeight: 48,
|
||||||
|
title: "Workshop",
|
||||||
|
onPressed: () => appointmentsVM.updateIsHomeTapped(false),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (appointmentsVM.isHomeTapped) ...[
|
||||||
|
8.height,
|
||||||
|
TxtField(
|
||||||
|
hint: 'Pick Home Location',
|
||||||
|
errorValue: appointmentsVM.pickHomeLocationError,
|
||||||
|
value: appointmentsVM.pickedHomeLocation,
|
||||||
|
isNeedClickAll: true,
|
||||||
|
postfixData: Icons.location_on,
|
||||||
|
postFixDataColor: MyColors.darkTextColor,
|
||||||
|
onTap: () {
|
||||||
|
//TODO: open the place picked to pick the location and save it in provider.
|
||||||
|
appointmentsVM.updatePickedHomeLocation("PM58+F97, Al Olaya, Riyadh 12333");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
14.height,
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.warning,
|
||||||
|
color: MyColors.adPendingStatusColor,
|
||||||
|
size: 19,
|
||||||
|
).paddingOnly(bottom: 2),
|
||||||
|
3.width,
|
||||||
|
"Some services are not available on home location.".toText(
|
||||||
|
color: MyColors.adPendingStatusColor,
|
||||||
|
fontSize: 12,
|
||||||
|
isItalic: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (appointmentsVM.isHomeTapped && !appointmentsVM.isFetchingServices) ...[
|
||||||
|
const Divider(thickness: 1, height: 1),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// TODO: This Price will be decided according to the service selected
|
||||||
|
150.toString().toText(fontSize: 30, isBold: true),
|
||||||
|
"SAR".toText(fontSize: 15, isBold: true, color: MyColors.lightTextColor).paddingOnly(bottom: 5),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
"These charges are additional to the actual service charges. For heavy items the charges may vary.".toText(fontSize: 12, color: MyColors.lightTextColor),
|
||||||
|
22.height,
|
||||||
|
],
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ShowFillButton(
|
||||||
|
maxHeight: 55,
|
||||||
|
backgroundColor: !appointmentsVM.isServiceSelectionValidated() ? MyColors.lightTextColor.withOpacity(0.6) : MyColors.primaryColor,
|
||||||
|
title: "Next",
|
||||||
|
onPressed: () {
|
||||||
|
bool isValidated = appointmentsVM.isServiceSelectionValidated();
|
||||||
|
if (isValidated) {
|
||||||
|
appointmentsVM.getServiceItems(appointmentsVM.branchSelectedServiceId.selectedId);
|
||||||
|
navigateWithName(context, AppRoutes.bookAppointmentsItemView);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).paddingOnly(bottom: 20)
|
||||||
|
],
|
||||||
|
)).horPaddingMain();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
|
||||||
|
class ServiceItemWithPriceCheckBox extends StatelessWidget {
|
||||||
|
final bool isSelected;
|
||||||
|
final String title, description;
|
||||||
|
final Widget priceWidget;
|
||||||
|
|
||||||
|
final Function(bool) onSelection;
|
||||||
|
|
||||||
|
const ServiceItemWithPriceCheckBox({
|
||||||
|
required this.isSelected,
|
||||||
|
required this.title,
|
||||||
|
required this.description,
|
||||||
|
this.priceWidget = const SizedBox(),
|
||||||
|
required this.onSelection,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: isSelected,
|
||||||
|
onChanged: (bool? v) {
|
||||||
|
onSelection(v ?? false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
title.toText(fontSize: 16, isBold: true).paddingOnly(top: 10),
|
||||||
|
description.toText(fontSize: 12, color: MyColors.lightTextColor),
|
||||||
|
priceWidget,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,61 +1,60 @@
|
|||||||
import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
// import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
||||||
import 'package:car_customer_app/view_models/providers_view_model.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/material.dart';
|
// import 'package:mc_common_app/classes/consts.dart';
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
// import 'package:mc_common_app/config/routes.dart';
|
||||||
import 'package:mc_common_app/config/routes.dart';
|
// import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
import 'package:mc_common_app/extensions/int_extensions.dart';
|
// import 'package:mc_common_app/theme/colors.dart';
|
||||||
import 'package:mc_common_app/theme/colors.dart';
|
// import 'package:mc_common_app/utils/navigator.dart';
|
||||||
import 'package:mc_common_app/utils/navigator.dart';
|
// import 'package:mc_common_app/widgets/common_widgets/categories_list.dart';
|
||||||
import 'package:mc_common_app/widgets/common_widgets/categories_list.dart';
|
// import 'package:mc_common_app/widgets/common_widgets/provider_details_card.dart';
|
||||||
import 'package:mc_common_app/widgets/common_widgets/provider_details_card.dart';
|
// import 'package:provider/provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
//
|
||||||
|
// class ProvidersFragment extends StatelessWidget {
|
||||||
class ProvidersFragment extends StatelessWidget {
|
// const ProvidersFragment({Key? key}) : super(key: key);
|
||||||
const ProvidersFragment({Key? key}) : super(key: key);
|
//
|
||||||
|
// @override
|
||||||
@override
|
// Widget build(BuildContext context) {
|
||||||
Widget build(BuildContext context) {
|
// return Container(
|
||||||
return Container(
|
// color: MyColors.backgroundColor,
|
||||||
color: MyColors.backgroundColor,
|
// width: double.infinity,
|
||||||
width: double.infinity,
|
// height: double.infinity,
|
||||||
height: double.infinity,
|
// child: Consumer(
|
||||||
child: Consumer(
|
// builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
||||||
builder: (BuildContext context, ProvidersVM providersVM, Widget? child) {
|
// return Column(
|
||||||
return Column(
|
// children: [
|
||||||
children: [
|
// 16.height,
|
||||||
16.height,
|
// FiltersList(
|
||||||
FiltersList(
|
// filterList: appointmentsVM.providersFilterOptions,
|
||||||
filterList: providersVM.providersFilterOptions,
|
// onFilterTapped: (index, selectedFilterId) => appointmentsVM.applyFilterOnProviders(index: index),
|
||||||
onFilterTapped: (index, selectedFilterId) => providersVM.applyFilterOnProviders(index: index),
|
// ),
|
||||||
),
|
// 16.height,
|
||||||
16.height,
|
// Expanded(
|
||||||
Expanded(
|
// child: Container(
|
||||||
child: Container(
|
// child: ListView.builder(
|
||||||
child: ListView.builder(
|
// shrinkWrap: true,
|
||||||
shrinkWrap: true,
|
// itemCount: 30,
|
||||||
itemCount: 30,
|
// itemBuilder: (BuildContext context, int index) {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
// return ProviderDetailsCard(
|
||||||
return ProviderDetailsCard(
|
// onCardTapped: () {
|
||||||
onCardTapped: () {
|
// if (context.read<AppointmentsVM>().branchCategories.isEmpty) {
|
||||||
if (context.read<AppointmentsVM>().providerCategories.isEmpty) {
|
// context.read<AppointmentsVM>().getBranchCategories();
|
||||||
context.read<AppointmentsVM>().getProviderCategories();
|
// }
|
||||||
}
|
// navigateWithName(context, AppRoutes.bookAppointmenServicesView);
|
||||||
navigateWithName(context, AppRoutes.bookAppointmenServicesView);
|
// },
|
||||||
},
|
// providerImageUrl: MyAssets.bnCar,
|
||||||
providerImageUrl: MyAssets.bnCar,
|
// title: "",
|
||||||
title:"",
|
// providerLocation: " 3km",
|
||||||
providerLocation: " 3km",
|
// providerName: "Al Ahmed Maintenance",
|
||||||
providerName: "Al Ahmed Maintenance",
|
// providerRatings: "4.9",
|
||||||
providerRatings: "4.9",
|
// );
|
||||||
);
|
// },
|
||||||
},
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ],
|
||||||
],
|
// );
|
||||||
);
|
// },
|
||||||
},
|
// ),
|
||||||
),
|
// );
|
||||||
);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue