aamir_dev
Faiz Hashmi 2 years ago
parent 71de9c5c8e
commit 8cdbaf3007

@ -372,14 +372,6 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
} }
Future<bool> updateServiceStatus(BuildContext context, bool value) async { 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 { try {
final serviceVM = context.read<ServiceVM>(); final serviceVM = context.read<ServiceVM>();
List<AppointmentBasicDetailsModel> list = await serviceVM.getAppointmentsByServiceID( 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/approved_branches_list_sheet.dart';
import 'package:car_provider_app/views/branch_management/services/duplication/sheet/items_selection_sheet.dart'; import 'package:car_provider_app/views/branch_management/services/duplication/sheet/items_selection_sheet.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
@ -40,9 +42,9 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
getMatchedServices() { getMatchedServices() {
serviceVM.getAllMatchedServices( serviceVM.getAllMatchedServices(
widget.matchServicesArguments!.oldBranch, oldBranchId: widget.matchServicesArguments!.oldBranch,
widget.matchServicesArguments!.newBranch, newBranchId: widget.matchServicesArguments!.newBranch,
widget.matchServicesArguments!.categoryId, categoryId: widget.matchServicesArguments!.categoryId,
); );
} }
@ -65,7 +67,6 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
12.height, 12.height,
GestureDetector( GestureDetector(
onTap: () { onTap: () {
// Toggle the checkbox value when the row is tapped
bool newValue = !context.read<ServiceVM>().isAllSelected; bool newValue = !context.read<ServiceVM>().isAllSelected;
serviceVM.selectAllServices(newValue); serviceVM.selectAllServices(newValue);
}, },
@ -118,15 +119,11 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
children: [ children: [
serviceVM.matchedServices![index].serviceDescription.toString().toText(fontSize: 16, isBold: true), 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}" "${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( ).toWhiteContainer(width: double.infinity, allPading: 8).onPress(
() { () {
@ -145,7 +142,7 @@ class _MatchedServicesPageState extends State<MatchedServicesPage> {
separatorBuilder: (context, index) { separatorBuilder: (context, index) {
return 8.height; return 8.height;
}, },
padding: const EdgeInsets.symmetric(horizontal: 14), // padding: const EdgeInsets.symmetric(horizontal: 14),
itemCount: serviceVM.matchedServices!.length, itemCount: serviceVM.matchedServices!.length,
); );
}), }),

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

@ -1,18 +1,21 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.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/generated/locale_keys.g.dart';
import 'package:mc_common_app/models/services_models/item_model.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/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/button/show_fill_button.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/extensions/extensions_widget.dart';
import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:easy_localization/easy_localization.dart';
class ItemsSelectionSheet extends StatefulWidget { class ItemsSelectionSheet extends StatefulWidget {
final List<ItemData> serviceItems; final List<ItemData> serviceItems;
final Function(List<ItemData>) onItemCopied; 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 @override
State<ItemsSelectionSheet> createState() => _ItemsSelectionSheetState(); State<ItemsSelectionSheet> createState() => _ItemsSelectionSheetState();
@ -21,34 +24,39 @@ class ItemsSelectionSheet extends StatefulWidget {
class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> { class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
bool isAllItemsSelected = false; bool isAllItemsSelected = false;
List<ItemData>? tempItems; List<ItemData>? tempItems;
List<ItemData>? filteredItems; // To store filtered items based on search query
String searchQuery = ""; // To store the search query
@override @override
void initState() { void initState() {
super.initState(); super.initState();
//tempItems=List.from(widget.serviceItems); tempItems = widget.serviceItems.map((item) => ItemData.fromJson(item.toJson())).toList();
// tempItems=[...widget.serviceItems]; filteredItems = List.from(tempItems!); // Initially show all items
//tempItems.addAll(widget.serviceItems); }
tempItems = widget.serviceItems
.map( // Method to filter items based on search query
(item) => ItemData.fromJson(item.toJson()) 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( updateTempItem(int index, bool value) {
// id: item.id, filteredItems![index].isUpdateOrSelected = value;
// name: item.name, setState(() {});
// 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();
} }
@override @override
@ -60,69 +68,58 @@ class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
"Select Items To Copy".toText(fontSize: 16, isBold: true), LocaleKeys.pleaseSelectItems.tr().toText(fontSize: 18, isBold: true),
12.height, 12.height,
TxtField( TxtField(
hint: "Search Items", value: searchQuery,
onChanged: (v) {}, hint: LocaleKeys.searchItems.tr(),
onChanged: (v) {
filterItems(v); // Filter items when the user types in the text field
},
), ),
6.height, 6.height,
Row( GestureDetector(
mainAxisAlignment: MainAxisAlignment.spaceBetween, onTap: () {
children: [ isAllItemsSelected = false;
Row( selectAllTempItems(false);
children: [ },
Checkbox( child: Row(
// value: context.watch<ServiceVM>().isAllSelected, mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: 30,
width: 30,
child: Checkbox(
value: isAllItemsSelected, value: isAllItemsSelected,
onChanged: (v) { onChanged: (v) {
isAllItemsSelected = v ?? false; if (v == null) return;
selectAllTempItems(v ?? false); 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), LocaleKeys.selectAll.tr().toText(fontSize: 14),
).onPress(() { ],
isAllItemsSelected = false; ),
selectAllTempItems(false);
}),
],
), ),
Flexible( Flexible(
child: ListView.separated( child: ListView.separated(
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Row( return CheckBoxWithTitleDescription(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ isSelected: filteredItems![index].isUpdateOrSelected ?? false,
Checkbox( title: filteredItems![index].name.toString(),
value: tempItems![index].isUpdateOrSelected, description: filteredItems![index].description.toString(),
onChanged: (v) { onSelection: (bool v) {
isAllItemsSelected = false; isAllItemsSelected = false;
updateTempItem(index, v ?? false); updateTempItem(index, v);
}, },
),
Expanded(
child: tempItems![index].name.toString().toText(fontSize: 16, isBold: true),
),
],
); );
}, },
separatorBuilder: (context, index) { separatorBuilder: (context, index) {
return const Divider(); return const Divider();
}, },
itemCount: tempItems!.length, itemCount: filteredItems!.length, // Use filtered items list
).toWhiteContainer(width: double.infinity), ).toWhiteContainer(width: double.infinity),
), ),
12.height, 12.height,
@ -130,7 +127,7 @@ class _ItemsSelectionSheetState extends State<ItemsSelectionSheet> {
title: "Copy Selected Item", title: "Copy Selected Item",
maxWidth: double.infinity, maxWidth: double.infinity,
onPressed: () { onPressed: () {
widget.onItemCopied(tempItems ?? []); widget.onItemCopied(filteredItems ?? []);
pop(context); 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( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
categoryData.categoryName.toString().toText(fontSize: 16), Flexible(child: categoryData.categoryName.toString().toText(fontSize: 16)),
], ],
), ),
// 5.height, // 5.height,
Container(
child: ("${LocaleKeys.branchName.tr()}: ${categoryData.branchName}").toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
),
if (categoryData.services != null) ...[ if (categoryData.services != null) ...[
Container( Container(
child: ("${LocaleKeys.totalNumberOfServices.tr()}: ${categoryData.services!.length}").toText( child: ("${LocaleKeys.totalNumberOfServices.tr()} ${categoryData.services!.length}").toText(
fontSize: 12, fontSize: 12,
color: MyColors.lightTextColor, color: MyColors.lightTextColor,
), ),
), ),
], ],
Container(
child: ("${LocaleKeys.branchName.tr()}: ${categoryData.branchName}").toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
),
], ],
), ),
), ),

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

Loading…
Cancel
Save