aamir_dev
Faiz Hashmi 1 year ago
parent 71de9c5c8e
commit 8cdbaf3007

@ -372,14 +372,6 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
}
Future<bool> updateServiceStatus(BuildContext context, bool value) async {
List<Map<String, dynamic>> map = [
{
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
"isActive": true,
//TODO: ZAHOOR WILL ADD SERVICE STATUS HERE TO UPDATE
}
];
try {
final serviceVM = context.read<ServiceVM>();
List<AppointmentBasicDetailsModel> list = await serviceVM.getAppointmentsByServiceID(

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:car_provider_app/views/branch_management/services/duplication/sheet/approved_branches_list_sheet.dart';
import 'package:car_provider_app/views/branch_management/services/duplication/sheet/items_selection_sheet.dart';
import 'package:easy_localization/easy_localization.dart';
@ -40,9 +42,9 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
getMatchedServices() {
serviceVM.getAllMatchedServices(
widget.matchServicesArguments!.oldBranch,
widget.matchServicesArguments!.newBranch,
widget.matchServicesArguments!.categoryId,
oldBranchId: widget.matchServicesArguments!.oldBranch,
newBranchId: widget.matchServicesArguments!.newBranch,
categoryId: widget.matchServicesArguments!.categoryId,
);
}
@ -65,7 +67,6 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
12.height,
GestureDetector(
onTap: () {
// Toggle the checkbox value when the row is tapped
bool newValue = !context.read<ServiceVM>().isAllSelected;
serviceVM.selectAllServices(newValue);
},
@ -118,15 +119,11 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
children: [
serviceVM.matchedServices![index].serviceDescription.toString().toText(fontSize: 16, isBold: true),
"${serviceVM.matchedServices![index].serviceItems!.where((c) => c.isUpdateOrSelected == true).length} items selected out of ${serviceVM.matchedServices![index].serviceItems!.length}"
.toText(color: MyColors.lightTextColor)
.toText(color: MyColors.lightTextColor),
LocaleKeys.tapToSeeItems.toText(color: MyColors.lightTextColor),
],
),
),
SvgPicture.asset(
MyAssets.icEdit,
width: 16,
height: 16,
),
],
).toWhiteContainer(width: double.infinity, allPading: 8).onPress(
() {
@ -145,7 +142,7 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
separatorBuilder: (context, index) {
return 8.height;
},
padding: const EdgeInsets.symmetric(horizontal: 14),
// padding: const EdgeInsets.symmetric(horizontal: 14),
itemCount: serviceVM.matchedServices!.length,
);
}),

@ -34,7 +34,7 @@ class ApprovedBranchesListSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.selectBranch.tr().toText(fontSize: 20, isBold: true),
LocaleKeys.selectBranchToCopyServices.tr().toText(fontSize: 12),
LocaleKeys.noteCopyItemsExplanation.tr().toText(fontSize: 12),
12.height,
Expanded(
child: Consumer<ServiceVM>(
@ -87,9 +87,9 @@ class ApprovedBranchesListSheet extends StatelessWidget {
context,
AppRoutes.matchServices,
arguments: MatchServicesArguments(
oldBranch: branches[index].id ?? 0,
oldBranchName: branches[index].branchName ?? "",
newBranch: branchId,
oldBranch: branches[index].id ?? 0,
categoryId: categoryId,
),
);

@ -1,18 +1,21 @@
import 'package:flutter/material.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/services_models/item_model.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/checkbox_with_title_desc.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:easy_localization/easy_localization.dart';
class ItemsSelectionSheet extends StatefulWidget {
final List<ItemData> serviceItems;
final Function(List<ItemData>) onItemCopied;
const ItemsSelectionSheet(this.serviceItems, {required this.onItemCopied, Key? key}) : super(key: key);
const ItemsSelectionSheet(this.serviceItems, {required this.onItemCopied, super.key});
@override
State<ItemsSelectionSheet> createState() => _ItemsSelectionSheetState();
@ -21,34 +24,39 @@ class ItemsSelectionSheet extends StatefulWidget {
class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
bool isAllItemsSelected = false;
List<ItemData>? tempItems;
List<ItemData>? filteredItems; // To store filtered items based on search query
String searchQuery = ""; // To store the search query
@override
void initState() {
super.initState();
//tempItems=List.from(widget.serviceItems);
// tempItems=[...widget.serviceItems];
//tempItems.addAll(widget.serviceItems);
tempItems = widget.serviceItems
.map(
(item) => ItemData.fromJson(item.toJson())
tempItems = widget.serviceItems.map((item) => ItemData.fromJson(item.toJson())).toList();
filteredItems = List.from(tempItems!); // Initially show all items
}
// Method to filter items based on search query
void filterItems(String query) {
setState(() {
searchQuery = query;
filteredItems = tempItems!.where((item) {
return item.name!.toLowerCase().contains(query.toLowerCase()) ||
item.description!.toLowerCase().contains(
query.toLowerCase(),
);
}).toList();
});
}
selectAllTempItems(bool value) {
for (var element in filteredItems ?? []) {
element.isUpdateOrSelected = value;
}
setState(() {});
}
// ItemData(
// id: item.id,
// name: item.name,
// price: item.price,
// manufactureDate: item.manufactureDate,
// description: item.description,
// pictureUrl: item.pictureUrl,
// companyId: item.companyId,
// serviceProviderServiceId: item.serviceProviderServiceId,
// isActive: item.isActive,
// isAllowAppointment: item.isAllowAppointment,
// isAppointmentCompanyLoc: item.isAppointmentCompanyLoc,
// isAppointmentCustomerLoc: item.isAppointmentCompanyLoc,
// isUpdateOrSelected: item.isUpdateOrSelected,
// ),
)
.toList();
updateTempItem(int index, bool value) {
filteredItems![index].isUpdateOrSelected = value;
setState(() {});
}
@override
@ -60,69 +68,58 @@ class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Select Items To Copy".toText(fontSize: 16, isBold: true),
LocaleKeys.pleaseSelectItems.tr().toText(fontSize: 18, isBold: true),
12.height,
TxtField(
hint: "Search Items",
onChanged: (v) {},
value: searchQuery,
hint: LocaleKeys.searchItems.tr(),
onChanged: (v) {
filterItems(v); // Filter items when the user types in the text field
},
),
6.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Checkbox(
// value: context.watch<ServiceVM>().isAllSelected,
GestureDetector(
onTap: () {
isAllItemsSelected = false;
selectAllTempItems(false);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: 30,
width: 30,
child: Checkbox(
value: isAllItemsSelected,
onChanged: (v) {
isAllItemsSelected = v ?? false;
selectAllTempItems(v ?? false);
if (v == null) return;
isAllItemsSelected = v;
selectAllTempItems(v);
},
),
"Select All".toText(
isBold: true,
)
],
),
Container(
alignment: Alignment.centerRight,
child: "Unselect All".toText(
color: MyColors.primaryColor,
isUnderLine: true,
isBold: true,
),
margin: const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
).onPress(() {
isAllItemsSelected = false;
selectAllTempItems(false);
}),
],
LocaleKeys.selectAll.tr().toText(fontSize: 14),
],
),
),
Flexible(
child: ListView.separated(
itemBuilder: (context, index) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
return CheckBoxWithTitleDescription(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Checkbox(
value: tempItems![index].isUpdateOrSelected,
onChanged: (v) {
isAllItemsSelected = false;
updateTempItem(index, v ?? false);
},
),
Expanded(
child: tempItems![index].name.toString().toText(fontSize: 16, isBold: true),
),
],
isSelected: filteredItems![index].isUpdateOrSelected ?? false,
title: filteredItems![index].name.toString(),
description: filteredItems![index].description.toString(),
onSelection: (bool v) {
isAllItemsSelected = false;
updateTempItem(index, v);
},
);
},
separatorBuilder: (context, index) {
return const Divider();
},
itemCount: tempItems!.length,
itemCount: filteredItems!.length, // Use filtered items list
).toWhiteContainer(width: double.infinity),
),
12.height,
@ -130,7 +127,7 @@ class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
title: "Copy Selected Item",
maxWidth: double.infinity,
onPressed: () {
widget.onItemCopied(tempItems ?? []);
widget.onItemCopied(filteredItems ?? []);
pop(context);
},
),
@ -138,16 +135,4 @@ class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
),
);
}
selectAllTempItems(bool value) {
for (var element in tempItems ?? []) {
element.isUpdateOrSelected = value;
}
setState(() {});
}
updateTempItem(int index, bool value) {
tempItems![index].isUpdateOrSelected = value;
setState(() {});
}
}

@ -111,24 +111,24 @@ class _ServicesListPageState extends State<ServicesListPage> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
categoryData.categoryName.toString().toText(fontSize: 16),
Flexible(child: categoryData.categoryName.toString().toText(fontSize: 16)),
],
),
// 5.height,
Container(
child: ("${LocaleKeys.branchName.tr()}: ${categoryData.branchName}").toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
),
if (categoryData.services != null) ...[
Container(
child: ("${LocaleKeys.totalNumberOfServices.tr()}: ${categoryData.services!.length}").toText(
child: ("${LocaleKeys.totalNumberOfServices.tr()} ${categoryData.services!.length}").toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
),
],
Container(
child: ("${LocaleKeys.branchName.tr()}: ${categoryData.branchName}").toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
),
],
),
),

@ -42,8 +42,8 @@ dependencies:
mc_common_app:
# path: D:\Development\car_common_app
# path: /Users/amir/StudioProjects/car_common_app
# path: /Volumes/Data/Projects/Flutter/car_common_app
path: /Users/faizhashmi/Development/Projects/MyProjects/CloudSolutions/car_common_app
path: /Volumes/Data/Projects/Flutter/car_common_app
# path: /Users/faizhashmi/Development/Projects/MyProjects/CloudSolutions/car_common_app

Loading…
Cancel
Save