diff --git a/lib/models/provider_branches_models/branch_detail_model.dart b/lib/models/provider_branches_models/branch_detail_model.dart index 6ed2ed9..2ffa413 100644 --- a/lib/models/provider_branches_models/branch_detail_model.dart +++ b/lib/models/provider_branches_models/branch_detail_model.dart @@ -10,6 +10,7 @@ class BranchDetailModel { final String? branchName; final String? branchDescription; final int? cityId; + final String? cityName; final String? address; final String? latitude; final String? longitude; @@ -32,6 +33,7 @@ class BranchDetailModel { this.branchName, this.branchDescription, this.cityId, + this.cityName, this.address, this.latitude, this.longitude, @@ -48,13 +50,15 @@ class BranchDetailModel { required this.isExpanded, }); - factory BranchDetailModel.fromJson(Map json) => BranchDetailModel( + factory BranchDetailModel.fromJson(Map json) => + BranchDetailModel( id: json["id"], serviceProviderId: json["serviceProviderID"], serviceProviderName: json["serviceProviderName"], branchName: json["branchName"], branchDescription: json["branchDescription"], cityId: json["cityID"], + cityName: json["cityName"], address: json["address"], latitude: json["latitude"], longitude: json["longitude"], @@ -64,12 +68,15 @@ class BranchDetailModel { branchStatus: (json['branchStatus'] as int).toBranchStatusEnum(), statusId: json["branchStatus"], statusText: json["statusText"], - branchServices: json["serviceProviderServices"] == null ? [] : List.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x))), + branchServices: json["serviceProviderServices"] == null ? [] : List< + ServiceModel>.from(json["serviceProviderServices"]!.map((x) => + ServiceModel.fromJson(x))), categories: [], isExpanded: false, ); - Map toJson() => { + Map toJson() => + { "id": id, "serviceProviderID": serviceProviderId, "serviceProviderName": serviceProviderName, @@ -84,6 +91,7 @@ class BranchDetailModel { "closeTime": closeTime, "status": statusId, "statusText": statusText, - "serviceProviderServices": branchServices == null ? [] : List.from(branchServices!.map((x) => x.toJson())), + "serviceProviderServices": branchServices == null ? [] : List< + dynamic>.from(branchServices!.map((x) => x.toJson())), }; } diff --git a/lib/services/common_services.dart b/lib/services/common_services.dart index 14a52cd..e75d97f 100644 --- a/lib/services/common_services.dart +++ b/lib/services/common_services.dart @@ -1,12 +1,9 @@ -import 'dart:developer'; import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:mc_common_app/utils/app_permission_handler.dart'; -import 'package:mc_common_app/utils/utils.dart'; -import 'package:permission_handler/permission_handler.dart'; abstract class CommonAppServices { Future> pickMultipleImages(); @@ -14,6 +11,9 @@ abstract class CommonAppServices { Future pickImageFromPhone(int sourceFlag); Future?> pickMultipleFiles(BuildContext context); + + Future pickFile(BuildContext context, + {required FileType fileType, List? allowedExtensions}); } class CommonServicesImp implements CommonAppServices { @@ -64,4 +64,28 @@ class CommonServicesImp implements CommonAppServices { } return pickedImages; } + + @override + Future pickFile(BuildContext context, + {required FileType fileType, List? allowedExtensions}) async { + FilePickerResult? result; + + final status = await AppPermissions.checkStoragePermissions(context); + if (status) { + result = await FilePicker.platform.pickFiles( + allowMultiple: true, + type: fileType, + allowedExtensions: allowedExtensions); + } + + List pickedFiles = []; + if (result != null) { + for (var element in result.files) { + if (element.path != null) { + pickedFiles.add(File(element.path!)); + } + } + } + return pickedFiles.length > 0 ? pickedFiles.first : null; + } } diff --git a/lib/widgets/dropdown/dropdow_field.dart b/lib/widgets/dropdown/dropdow_field.dart index 4445317..e94aa47 100644 --- a/lib/widgets/dropdown/dropdow_field.dart +++ b/lib/widgets/dropdown/dropdow_field.dart @@ -28,8 +28,11 @@ class DropdownField extends StatefulWidget { final Function(DropValue) onSelect; final bool showAppointmentPickerVariant; final TextStyle? textStyle; + final bool isSelectAble; - const DropdownField(this.onSelect, {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle}) : super(key: key); + const DropdownField(this.onSelect, + {Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle, this.isSelectAble = true}) + : super(key: key); @override State createState() => _DropdownFieldState(); @@ -53,7 +56,9 @@ class _DropdownFieldState extends State { return Column( children: [ Container( - decoration: widget.showAppointmentPickerVariant ? null : Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2), + decoration: widget.showAppointmentPickerVariant ? null : Utils + .containerColorRadiusBorderWidth( + MyColors.white, 0, MyColors.darkPrimaryColor, 2), margin: const EdgeInsets.all(0), padding: const EdgeInsets.only(left: 8, right: 8), width: widget.showAppointmentPickerVariant ? 170 : null, @@ -65,8 +70,15 @@ class _DropdownFieldState extends State { iconEnabledColor: borderColor, iconDisabledColor: borderColor, isExpanded: true, - style: widget.showAppointmentPickerVariant ? widget.textStyle : const TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15), - hint: (widget.hint ?? "").toText(color: widget.showAppointmentPickerVariant ? Colors.black : borderColor, fontSize: widget.showAppointmentPickerVariant ? 18 : 15), + style: widget.showAppointmentPickerVariant + ? widget.textStyle + : const TextStyle( + color: Colors.black, fontWeight: FontWeight.w600, fontSize: 15), + hint: (widget.hint ?? "").toText( + color: widget.showAppointmentPickerVariant + ? Colors.black + : borderColor, + fontSize: widget.showAppointmentPickerVariant ? 18 : 15), underline: Container(height: 0), onChanged: (DropValue? newValue) { setState(() { @@ -75,11 +87,12 @@ class _DropdownFieldState extends State { }); }, items: (widget.list ?? defaultV).map>( - (DropValue value) { + (DropValue value) { return DropdownMenuItem( value: value, enabled: value.isEnabled ?? true, - child: value.value.toText(fontSize: 15, color: value.isEnabled == false ? Colors.black38 : null), + child: value.value.toText(fontSize: 15, + color: value.isEnabled == false ? Colors.black38 : null), ); }, ).toList(), diff --git a/pubspec.lock b/pubspec.lock index 36a0e9b..8bc6900 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -137,6 +137,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.6" + device_info_plus: + dependency: "direct main" + description: + name: device_info_plus + sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" + url: "https://pub.dev" + source: hosted + version: "9.1.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + url: "https://pub.dev" + source: hosted + version: "7.0.0" dropdown_button2: dependency: "direct main" description: @@ -181,10 +197,10 @@ packages: dependency: transitive description: name: ffi - sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18" + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "2.1.0" file: dependency: transitive description: @@ -197,10 +213,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "704259669b5e9cb24e15c11cfcf02caf5f20d30901b3916d60b6d1c2d647035f" + sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" url: "https://pub.dev" source: hosted - version: "4.6.1" + version: "6.1.1" file_selector_linux: dependency: transitive description: @@ -745,10 +761,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: a34ecd7fb548f8e57321fd8e50d865d266941b54e6c3b7758cf8f37c24116905 + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.2.1" percent_indicator: dependency: "direct main" description: @@ -1158,10 +1174,18 @@ packages: dependency: transitive description: name: win32 - sha256: c0e3a4f7be7dae51d8f152230b86627e3397c1ba8c3fa58e63d44a9f3edc9cef + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "5.2.0" + win32_registry: + dependency: transitive + description: + name: win32_registry + sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a" + url: "https://pub.dev" + source: hosted + version: "1.1.2" xdg_directories: dependency: transitive description: @@ -1179,5 +1203,5 @@ packages: source: hosted version: "6.3.0" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" + dart: ">=3.2.0 <4.0.0" flutter: ">=3.10.0"