Merge branch 'refs/heads/faiz_development_common' into aamir_dev

master_new_changes
Aamir.Muhammad 2 years ago
commit 27f670917a

@ -324,3 +324,31 @@ String toString() {
return 'VehiclePostingDamageParts{id: $id, comment: $comment, vehicleImageBase64: $vehicleImageBase64, vehicleDamagePartID: $vehicleDamagePartID, vehiclePostingID: $vehiclePostingID, isActive: $isActive}'; 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; double? branchRateAvg;
List<ServiceModel>? branchServices; List<ServiceModel>? branchServices;
List<CategoryData>? categories; List<CategoryData>? categories;
List<BranchAuditTrial>? branchAuditTrial;
int? countryID; int? countryID;
String? countryName; String? countryName;
bool isExpanded = false; bool isExpanded = false;
bool? isFavorite; 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({ BranchDetailModel({
this.id, this.id,
this.serviceProviderId, this.serviceProviderId,
@ -55,6 +71,7 @@ class BranchDetailModel {
this.branchStatusLabel, this.branchStatusLabel,
this.branchServices, this.branchServices,
this.categories, this.categories,
this.branchAuditTrial,
this.countryID, this.countryID,
this.countryName, this.countryName,
this.isFavorite, this.isFavorite,
@ -95,7 +112,24 @@ class BranchDetailModel {
branchRateAvg = json["branchRateAvg"]; branchRateAvg = json["branchRateAvg"];
branchServices = json["serviceProviderServices"] == null ? [] : List<ServiceModel>.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x))); branchServices = json["serviceProviderServices"] == null ? [] : List<ServiceModel>.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x)));
categories = []; categories = [];
branchAuditTrial = json["branchAuditTrial"] == null ? [] : List<BranchAuditTrial>.from(json["branchAuditTrial"]!.map((x) => BranchAuditTrial.fromJson(x)));
isExpanded = false; isExpanded = false;
isFavorite = 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'; import 'package:mc_common_app/models/services_models/item_model.dart';
abstract class BranchRepo { 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(); Future<Branch> fetchAllBranches();
@ -91,16 +109,36 @@ class BranchRepoImp implements BranchRepo {
AppState appState = injector.get<AppState>(); AppState appState = injector.get<AppState>();
@override @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 = { var postParams = {
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "", "serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
"branchName": branchName, "branchName": branchName,
"branchDescription": branchDescription, "branchDescription": branchDescription,
"cityID": cityId, "cityID": cityId.toString(),
"address": address, "address": address,
"latitude": latitude, "latitude": latitude,
"longitude": longitude, "longitude": longitude,
"isActive": true "isActive": true,
"serviceProviderBranchImages": serviceProviderBranchImages,
}; };
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t); return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
@ -177,14 +215,24 @@ class BranchRepoImp implements BranchRepo {
} }
@override @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"; String lat = "0", long = "0";
try { try {
lat = latitude.substring(0, 9); lat = latitude.toString().substring(0, 9);
long = longitude.substring(0, 9); long = longitude.toString().substring(0, 9);
} catch (e) {} } catch (e) {}
var postParams = { var postParams = {
"id": id, "id": branchId,
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "", "serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
"branchName": branchName, "branchName": branchName,
"branchDescription": branchDescription, "branchDescription": branchDescription,

@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/classes/app_state.dart';
@ -50,6 +51,8 @@ class ServiceVM extends BaseVM {
List<DropValue> citiesDropList = []; List<DropValue> citiesDropList = [];
double latitude = 0; double latitude = 0;
double longitude = 0; double longitude = 0;
String openTime = "";
String closedTime = "";
int role = -1; int role = -1;
int countryId = -1; int countryId = -1;
int cityId = -1; int cityId = -1;
@ -183,6 +186,8 @@ class ServiceVM extends BaseVM {
branchDescription = branchData.branchDescription!; branchDescription = branchData.branchDescription!;
latitude = double.parse(branchData.latitude ?? ""); latitude = double.parse(branchData.latitude ?? "");
longitude = double.parse(branchData.longitude ?? ""); longitude = double.parse(branchData.longitude ?? "");
openTime = branchData.openTime ?? "";
closedTime = branchData.closeTime ?? "";
countryId = branchData.countryID!; countryId = branchData.countryID!;
cityId = branchData.cityId!; cityId = branchData.cityId!;
cityValue = DropValue( cityValue = DropValue(
@ -203,27 +208,6 @@ class ServiceVM extends BaseVM {
setState(ViewState.idle); 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() { void resetValues() {
countryCode = ""; countryCode = "";
address = ""; address = "";
@ -398,17 +382,44 @@ class ServiceVM extends BaseVM {
return response; return response;
} }
Future<void> onCreateBranchPressed({ Future<BranchPostingImages> convertFileToBranchPostingImages({required ImageModel imageModel}) async {
required BuildContext context, BranchPostingImages branchPostingImages;
required String branchName, if (imageModel.isFromNetwork ?? false) {
required String branchDesc, branchPostingImages = BranchPostingImages(id: imageModel.id, imageUrl: imageModel.filePath);
required int cityID, } else {
required String address, File file = File(imageModel.filePath!);
required double latitude, List<int> imageBytes = await file.readAsBytes();
required double longitude, String image = base64Encode(imageBytes);
}) async { 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); Utils.showLoading(context);
GenericRespModel res = await branchRepo.createBranch(branchName, branchDesc, cityID.toString(), address, latitude.toString(), longitude.toString());
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); Utils.hideLoading(context);
if (res.messageStatus == 1) { if (res.messageStatus == 1) {
Utils.showToast(LocaleKeys.branch_created.tr()); Utils.showToast(LocaleKeys.branch_created.tr());
@ -418,6 +429,10 @@ class ServiceVM extends BaseVM {
} else { } else {
Utils.showToast(res.message ?? ""); Utils.showToast(res.message ?? "");
} }
} catch (e) {
Utils.hideLoading(context);
Utils.showToast(e.toString());
}
} }
Future<void> onUpdateBranchPressed({ Future<void> onUpdateBranchPressed({
@ -427,18 +442,27 @@ class ServiceVM extends BaseVM {
required String branchDesc, required String branchDesc,
required int cityID, required int cityID,
required String address, required String address,
required double latitude, required String latitude,
required String longitude, required String longitude,
}) async { }) async {
try {
Utils.showLoading(context); Utils.showLoading(context);
GenericRespModel res = await updateBranch(
branchID ?? 0, List<BranchPostingImages> branchImages = [];
branchName,
branchDescription, for (var image in pickedBranchImages) {
cityId.toString(), branchImages.add(await convertFileToBranchPostingImages(imageModel: image));
address, }
latitude.toString(),
longitude.toString(), GenericRespModel res = await branchRepo.updateBranch(
branchId: branchID,
branchName: branchName,
branchDescription: branchDesc,
cityId: cityID,
address: address,
latitude: latitude,
longitude: longitude,
imagesList: branchImages,
); );
Utils.hideLoading(context); Utils.hideLoading(context);
if (res.messageStatus == 1) { if (res.messageStatus == 1) {
@ -449,5 +473,9 @@ class ServiceVM extends BaseVM {
} else { } else {
Utils.showToast(res.message ?? ""); Utils.showToast(res.message ?? "");
} }
} catch (e) {
Utils.hideLoading(context);
Utils.showToast(e.toString());
}
} }
} }

@ -36,7 +36,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
child: Container( child: Container(
// width: double.infinity, // width: double.infinity,
// height: double.infinity, // height: double.infinity,
padding: EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Column( child: Column(
children: [ children: [
LocaleKeys.enterNewPassword.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,), 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/theme/colors.dart';
import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:sizer/sizer.dart';
class DropValue { class DropValue {
int id; int id;
@ -30,9 +31,7 @@ class DropdownField extends StatefulWidget {
final TextStyle? textStyle; final TextStyle? textStyle;
final bool isSelectAble; final bool isSelectAble;
const DropdownField(this.onSelect, 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);
{Key? key, this.hint, this.list, this.dropdownValue, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle, this.isSelectAble = true})
: super(key: key);
@override @override
State<DropdownField> createState() => _DropdownFieldState(); State<DropdownField> createState() => _DropdownFieldState();
@ -56,9 +55,7 @@ class _DropdownFieldState extends State<DropdownField> {
return Column( return Column(
children: [ children: [
Container( Container(
decoration: widget.showAppointmentPickerVariant ? null : Utils decoration: widget.showAppointmentPickerVariant ? null : Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2),
.containerColorRadiusBorderWidth(
MyColors.white, 0, MyColors.darkPrimaryColor, 2),
margin: const EdgeInsets.all(0), margin: const EdgeInsets.all(0),
padding: const EdgeInsets.only(left: 8, right: 8), padding: const EdgeInsets.only(left: 8, right: 8),
width: widget.showAppointmentPickerVariant ? 170 : null, width: widget.showAppointmentPickerVariant ? 170 : null,
@ -70,15 +67,8 @@ class _DropdownFieldState extends State<DropdownField> {
iconEnabledColor: borderColor, iconEnabledColor: borderColor,
iconDisabledColor: borderColor, iconDisabledColor: borderColor,
isExpanded: true, isExpanded: true,
style: widget.showAppointmentPickerVariant style: TextStyle(color: borderColor, fontFamily: 'Poppins', fontSize: 13.sp),
? widget.textStyle hint: (widget.hint ?? "").toText(color: borderColor, fontSize: 13.sp),
: 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), underline: Container(height: 0),
onChanged: (DropValue? newValue) { onChanged: (DropValue? newValue) {
setState(() { setState(() {
@ -91,8 +81,7 @@ class _DropdownFieldState extends State<DropdownField> {
return DropdownMenuItem<DropValue>( return DropdownMenuItem<DropValue>(
value: value, value: value,
enabled: value.isEnabled ?? true, enabled: value.isEnabled ?? true,
child: value.value.toText(fontSize: 15, child: value.value.toText(fontSize: 13.sp, color: value.isEnabled == false ? Colors.black38 : null),
color: value.isEnabled == false ? Colors.black38 : null),
); );
}, },
).toList(), ).toList(),

Loading…
Cancel
Save