Merge branch 'refs/heads/faiz_development_common' into aamir_dev

master_new_changes
Aamir.Muhammad 1 year ago
commit 27f670917a

@ -324,3 +324,31 @@ String toString() {
return 'VehiclePostingDamageParts{id: $id, comment: $comment, vehicleImageBase64: $vehicleImageBase64, vehicleDamagePartID: $vehicleDamagePartID, vehiclePostingID: $vehiclePostingID, isActive: $isActive}';
}
}
class BranchPostingImages {
int? id;
String? imageName;
String? imageUrl;
String? imageStr;
BranchPostingImages(
{this.id, this.imageName, this.imageUrl, this.imageStr});
BranchPostingImages.fromJson(Map<String, dynamic> json) {
id = json['id'];
imageName = json['imageName'];
imageUrl = json['imageUrl'];
imageStr = json['imageStr'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['imageName'] = this.imageName;
data['imageUrl'] = this.imageUrl;
data['imageStr'] = this.imageStr;
return data;
}
}

@ -27,11 +27,27 @@ class BranchDetailModel {
double? branchRateAvg;
List<ServiceModel>? branchServices;
List<CategoryData>? categories;
List<BranchAuditTrial>? branchAuditTrial;
int? countryID;
String? countryName;
bool isExpanded = false;
bool? isFavorite;
//I/flutter (23146): "id": 1021,
// I/flutter (23146): "serviceProviderID": 10,
// I/flutter (23146): "serviceProviderName": "string",
// I/flutter (23146): "cityID": 1,
// I/flutter (23146): "cityName": "Riyadh",
// I/flutter (23146): "branchName": "Al Arouba Cars",
// I/flutter (23146): "branchDescription": "des",
// I/flutter (23146): "address": "3289 Hilal Bin Omayah St - حي العليا, حي العليا, الرياض, RHOD3289, Saudi Arabia",
// I/flutter (23146): "latitude": "24.708521303151027",
// I/flutter (23146): "longitude": "46.666924171149724",
// I/flutter (23146): "distanceKM": 0.0,
// I/flutter (23146): "openTime": "09:00",
// I/flutter (23146): "closeTime": "18:00",
// I/flutter (23146): "branchStatus": 3,
// I/flutter (23146): "branchStatusText": "ApprovedOrActive",
BranchDetailModel({
this.id,
this.serviceProviderId,
@ -55,6 +71,7 @@ class BranchDetailModel {
this.branchStatusLabel,
this.branchServices,
this.categories,
this.branchAuditTrial,
this.countryID,
this.countryName,
this.isFavorite,
@ -95,7 +112,24 @@ class BranchDetailModel {
branchRateAvg = json["branchRateAvg"];
branchServices = json["serviceProviderServices"] == null ? [] : List<ServiceModel>.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x)));
categories = [];
branchAuditTrial = json["branchAuditTrial"] == null ? [] : List<BranchAuditTrial>.from(json["branchAuditTrial"]!.map((x) => BranchAuditTrial.fromJson(x)));
isExpanded = false;
isFavorite = false;
}
}
class BranchAuditTrial {
int? status;
String? comment;
int? createdBy;
String? createdOn;
BranchAuditTrial({this.status, this.comment, this.createdBy, this.createdOn});
BranchAuditTrial.fromJson(Map<String, dynamic> json) {
status = json['status'];
comment = json['comment'];
createdBy = json['createdBy'];
createdOn = json['createdOn'];
}
}

@ -17,9 +17,27 @@ import 'package:mc_common_app/models/provider_branches_models/provider_profile_m
import 'package:mc_common_app/models/services_models/item_model.dart';
abstract class BranchRepo {
Future<GenericRespModel> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude);
Future<GenericRespModel> createBranch({
required String branchName,
required String branchDescription,
required int cityId,
required String address,
required double latitude,
required double longitude,
required List<BranchPostingImages> imagesList,
});
Future<GenericRespModel> updateBranch(int id, String branchName, String branchDescription, String cityId, String address, String latitude, String longitude, {bool isNeedToDelete = true});
Future<GenericRespModel> updateBranch({
required int branchId,
required String branchName,
required String branchDescription,
required int cityId,
required String address,
required String latitude,
required String longitude,
required List<BranchPostingImages> imagesList,
bool isNeedToDelete = true,
});
Future<Branch> fetchAllBranches();
@ -91,16 +109,36 @@ class BranchRepoImp implements BranchRepo {
AppState appState = injector.get<AppState>();
@override
Future<GenericRespModel> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
Future<GenericRespModel> createBranch({
required String branchName,
required String branchDescription,
required int cityId,
required String address,
required double latitude,
required double longitude,
required List<BranchPostingImages> imagesList,
}) async {
List serviceProviderBranchImages = [];
for (var element in imagesList) {
var imageMap = {
"id": element.id ?? 0,
"imageName": element.imageName,
"imageUrl": element.imageUrl,
"imageStr": element.imageStr,
};
serviceProviderBranchImages.add(imageMap);
}
var postParams = {
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
"branchName": branchName,
"branchDescription": branchDescription,
"cityID": cityId,
"cityID": cityId.toString(),
"address": address,
"latitude": latitude,
"longitude": longitude,
"isActive": true
"isActive": true,
"serviceProviderBranchImages": serviceProviderBranchImages,
};
String t = AppState().getUser.data!.accessToken ?? "";
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
@ -177,14 +215,24 @@ class BranchRepoImp implements BranchRepo {
}
@override
Future<GenericRespModel> updateBranch(int id, String branchName, String branchDescription, String cityId, String address, String latitude, String longitude, {bool isNeedToDelete = true}) async {
Future<GenericRespModel> updateBranch({
required int branchId,
required String branchName,
required String branchDescription,
required int cityId,
required String address,
required String latitude,
required String longitude,
required List<BranchPostingImages> imagesList,
bool isNeedToDelete = true,
}) async {
String lat = "0", long = "0";
try {
lat = latitude.substring(0, 9);
long = longitude.substring(0, 9);
lat = latitude.toString().substring(0, 9);
long = longitude.toString().substring(0, 9);
} catch (e) {}
var postParams = {
"id": id,
"id": branchId,
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
"branchName": branchName,
"branchDescription": branchDescription,

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/app_state.dart';
@ -50,6 +51,8 @@ class ServiceVM extends BaseVM {
List<DropValue> citiesDropList = [];
double latitude = 0;
double longitude = 0;
String openTime = "";
String closedTime = "";
int role = -1;
int countryId = -1;
int cityId = -1;
@ -183,6 +186,8 @@ class ServiceVM extends BaseVM {
branchDescription = branchData.branchDescription!;
latitude = double.parse(branchData.latitude ?? "");
longitude = double.parse(branchData.longitude ?? "");
openTime = branchData.openTime ?? "";
closedTime = branchData.closeTime ?? "";
countryId = branchData.countryID!;
cityId = branchData.cityId!;
cityValue = DropValue(
@ -203,27 +208,6 @@ class ServiceVM extends BaseVM {
setState(ViewState.idle);
}
Future<GenericRespModel> updateBranch(
int id,
String branchName,
String branchDescription,
String cityId,
String address,
String latitude,
String longitude, {
bool isNeedToDelete = true,
}) async {
return await branchRepo.updateBranch(
id,
branchName,
branchDescription,
cityId.toString(),
address,
latitude.toString(),
longitude.toString(),
);
}
void resetValues() {
countryCode = "";
address = "";
@ -398,25 +382,56 @@ class ServiceVM extends BaseVM {
return response;
}
Future<void> onCreateBranchPressed({
required BuildContext context,
required String branchName,
required String branchDesc,
required int cityID,
required String address,
required double latitude,
required double longitude,
}) async {
Utils.showLoading(context);
GenericRespModel res = await branchRepo.createBranch(branchName, branchDesc, cityID.toString(), address, latitude.toString(), longitude.toString());
Utils.hideLoading(context);
if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_created.tr());
updateSelectedBranchType(1);
pop(context);
getBranchAndServices();
Future<BranchPostingImages> convertFileToBranchPostingImages({required ImageModel imageModel}) async {
BranchPostingImages branchPostingImages;
if (imageModel.isFromNetwork ?? false) {
branchPostingImages = BranchPostingImages(id: imageModel.id, imageUrl: imageModel.filePath);
} else {
Utils.showToast(res.message ?? "");
File file = File(imageModel.filePath!);
List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes);
String fileName = file.path.split('/').last;
branchPostingImages = BranchPostingImages(
imageName: fileName,
imageStr: image,
imageUrl: file.path,
// id: isAdEditEnabled ? previousAdDetails!.vehiclePostingID : null, // TODO NEED TO PASS ID HERE IN CASE OF EDIT BRANCH
);
}
return branchPostingImages;
}
Future<void> onCreateBranchPressed({required BuildContext context, required String branchName, required String branchDesc, required int cityID, required String address, required double latitude, required double longitude}) async {
try {
Utils.showLoading(context);
List<BranchPostingImages> branchImages = [];
for (var image in pickedBranchImages) {
branchImages.add(await convertFileToBranchPostingImages(imageModel: image));
}
GenericRespModel res = await branchRepo.createBranch(
branchName: branchName,
branchDescription: branchDesc,
cityId: cityID,
address: address,
latitude: latitude,
longitude: longitude,
imagesList: branchImages,
);
Utils.hideLoading(context);
if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_created.tr());
updateSelectedBranchType(1);
pop(context);
getBranchAndServices();
} else {
Utils.showToast(res.message ?? "");
}
} catch (e) {
Utils.hideLoading(context);
Utils.showToast(e.toString());
}
}
@ -427,27 +442,40 @@ class ServiceVM extends BaseVM {
required String branchDesc,
required int cityID,
required String address,
required double latitude,
required String latitude,
required String longitude,
}) async {
Utils.showLoading(context);
GenericRespModel res = await updateBranch(
branchID ?? 0,
branchName,
branchDescription,
cityId.toString(),
address,
latitude.toString(),
longitude.toString(),
);
Utils.hideLoading(context);
if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_updated.tr());
pop(context);
pop(context);
getBranchAndServices();
} else {
Utils.showToast(res.message ?? "");
try {
Utils.showLoading(context);
List<BranchPostingImages> branchImages = [];
for (var image in pickedBranchImages) {
branchImages.add(await convertFileToBranchPostingImages(imageModel: image));
}
GenericRespModel res = await branchRepo.updateBranch(
branchId: branchID,
branchName: branchName,
branchDescription: branchDesc,
cityId: cityID,
address: address,
latitude: latitude,
longitude: longitude,
imagesList: branchImages,
);
Utils.hideLoading(context);
if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_updated.tr());
pop(context);
pop(context);
getBranchAndServices();
} else {
Utils.showToast(res.message ?? "");
}
} catch (e) {
Utils.hideLoading(context);
Utils.showToast(e.toString());
}
}
}

@ -36,7 +36,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
child: Container(
// width: double.infinity,
// height: double.infinity,
padding: EdgeInsets.all(20),
padding: const EdgeInsets.all(20),
child: Column(
children: [
LocaleKeys.enterNewPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),

@ -3,6 +3,7 @@ import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:sizer/sizer.dart';
class DropValue {
int id;
@ -30,9 +31,7 @@ class DropdownField extends StatefulWidget {
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, this.isSelectAble = true})
: 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<DropdownField> createState() => _DropdownFieldState();
@ -56,9 +55,7 @@ class _DropdownFieldState extends State<DropdownField> {
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,
@ -70,15 +67,8 @@ class _DropdownFieldState extends State<DropdownField> {
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: TextStyle(color: borderColor, fontFamily: 'Poppins', fontSize: 13.sp),
hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 13.sp),
underline: Container(height: 0),
onChanged: (DropValue? newValue) {
setState(() {
@ -87,12 +77,11 @@ class _DropdownFieldState extends State<DropdownField> {
});
},
items: (widget.list ?? defaultV).map<DropdownMenuItem<DropValue>>(
(DropValue value) {
(DropValue value) {
return DropdownMenuItem<DropValue>(
value: value,
enabled: value.isEnabled ?? true,
child: value.value.toText(fontSize: 15,
color: value.isEnabled == false ? Colors.black38 : null),
child: value.value.toText(fontSize: 13.sp, color: value.isEnabled == false ? Colors.black38 : null),
);
},
).toList(),

Loading…
Cancel
Save