Compare commits
No commits in common. 'master' and 'mirza_development' have entirely different histories.
master
...
mirza_deve
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="9.688" viewBox="0 0 13 9.688">
|
|
||||||
<g id="Group" transform="translate(6 17.688) rotate(180)">
|
|
||||||
<path id="Vector" d="M13,4.844a.781.781,0,0,1-.781.781H2.674L5.414,8.352a.781.781,0,0,1-1.1,1.108L.23,5.4h0a.782.782,0,0,1,0-1.106h0L4.312.227a.781.781,0,0,1,1.1,1.108L2.674,4.062h9.545A.781.781,0,0,1,13,4.844Z" transform="translate(-7 8)"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 411 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,134 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/theme/app_theme.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:provider/single_child_widget.dart';
|
||||||
|
import 'package:sizer/sizer.dart';
|
||||||
|
|
||||||
|
|
||||||
|
//testing push
|
||||||
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
|
Logger logger = Logger(
|
||||||
|
printer: PrettyPrinter(
|
||||||
|
lineLength: 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Logger logger = Logger(printer: PrettyPrinter(printEmojis: false, colors: true, printTime: false));
|
class MyHttpOverrides extends HttpOverrides {
|
||||||
|
@override
|
||||||
|
HttpClient createHttpClient(SecurityContext? context) {
|
||||||
|
return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool disableThingsForQA = true;
|
Future<void> main() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
// Language Tile in Settings
|
await EasyLocalization.ensureInitialized();
|
||||||
|
// AppState().setPostParamsInitConfig();
|
||||||
|
HttpOverrides.global = MyHttpOverrides();
|
||||||
|
|
||||||
|
runApp(
|
||||||
|
EasyLocalization(
|
||||||
|
supportedLocales: const <Locale>[
|
||||||
|
Locale('en', 'US'),
|
||||||
|
Locale('ar', 'SA'),
|
||||||
|
],
|
||||||
|
path: 'resources',
|
||||||
|
// assetLoader: const CodegenLoader(),
|
||||||
|
child: MultiProvider(
|
||||||
|
providers: const <SingleChildWidget>[
|
||||||
|
// ChangeNotifierProvider<LoginProviderModel>(
|
||||||
|
// create: (_) => LoginProviderModel(),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
child: const MyApp(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// todo terminal command to genertate translation files
|
// todo terminal command to genertate translation files
|
||||||
// flutter pub run easy_localization:generate --source-dir ./assets/langs
|
// flutter pub run easy_localization:generate -S resources -f keys -O lib/generated -o locale_keys.g.dart
|
||||||
// todo terminal command to genertate translation keys
|
|
||||||
// flutter pub run easy_localization:generate --source-dir ./assets/langs -f keys -o locale_keys.g.dart
|
class MyApp extends StatelessWidget {
|
||||||
// command to generate languages data from json
|
const MyApp({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
|
return Sizer(
|
||||||
|
builder: (
|
||||||
|
BuildContext context,
|
||||||
|
Orientation orientation,
|
||||||
|
DeviceType deviceType,
|
||||||
|
) {
|
||||||
|
List<LocalizationsDelegate<dynamic>> delegates = context.localizationDelegates;
|
||||||
|
// AppState().setPostParamsModel(
|
||||||
|
// PostParamsModel(
|
||||||
|
// languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
return MaterialApp(
|
||||||
|
// key: navigatorKey,
|
||||||
|
navigatorKey: navigatorKey,
|
||||||
|
theme: AppTheme.getTheme(
|
||||||
|
isArabic: EasyLocalization.of(context)?.locale.languageCode == "ar",
|
||||||
|
),
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
localizationsDelegates: delegates,
|
||||||
|
supportedLocales: context.supportedLocales,
|
||||||
|
locale: context.locale,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// class MyApp extends StatelessWidget {
|
||||||
|
// MyApp({super.key}) {
|
||||||
|
// AppDependencies.addDependencies();
|
||||||
|
// AppState = Injector.appInstance.get<AppState>();
|
||||||
|
// // AppState.setPostParamsInitConfig();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// return LayoutBuilder(builder: (context, constraints) {
|
||||||
|
// return Sizer(
|
||||||
|
// builder: (
|
||||||
|
// BuildContext context,
|
||||||
|
// Orientation orientation,
|
||||||
|
// DeviceType deviceType,
|
||||||
|
// ) {
|
||||||
|
// SizeConfig().init(constraints, orientation);
|
||||||
|
// List<LocalizationsDelegate<dynamic>> delegates = context.localizationDelegates;
|
||||||
|
// // AppState().setPostParamsModel(
|
||||||
|
// // PostParamsModel(
|
||||||
|
// // languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2,
|
||||||
|
// // ),
|
||||||
|
// // );
|
||||||
|
// return MaterialApp(
|
||||||
|
// // key: navigatorKey,
|
||||||
|
// navigatorKey: navigatorKey,
|
||||||
|
// theme: AppTheme.getTheme(
|
||||||
|
// EasyLocalization.of(context)?.locale.languageCode == "ar",
|
||||||
|
// ),
|
||||||
|
// debugShowCheckedModeBanner: false,
|
||||||
|
// localizationsDelegates: delegates,
|
||||||
|
// supportedLocales: context.supportedLocales,
|
||||||
|
// locale: context.locale,
|
||||||
|
// initialRoute: AppRoutes.initialPage,
|
||||||
|
// routes: AppRoutes.routes,
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
class PdfReceiptModel {
|
|
||||||
int? id;
|
|
||||||
String? pdfName;
|
|
||||||
String? pdfString;
|
|
||||||
|
|
||||||
PdfReceiptModel({this.id, this.pdfName, this.pdfString});
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
class AppointmentBasicDetailsModel {
|
|
||||||
int? serviceSlotID;
|
|
||||||
String? slotDate;
|
|
||||||
String? startTime;
|
|
||||||
String? endTime;
|
|
||||||
int? appointmentStatusID;
|
|
||||||
String? appointmentStatusText;
|
|
||||||
int? serviceProviderID;
|
|
||||||
int? customerID;
|
|
||||||
|
|
||||||
AppointmentBasicDetailsModel({
|
|
||||||
this.serviceSlotID,
|
|
||||||
this.slotDate,
|
|
||||||
this.startTime,
|
|
||||||
this.endTime,
|
|
||||||
this.appointmentStatusID,
|
|
||||||
this.appointmentStatusText,
|
|
||||||
this.serviceProviderID,
|
|
||||||
this.customerID,
|
|
||||||
});
|
|
||||||
|
|
||||||
AppointmentBasicDetailsModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
serviceSlotID = json['serviceSlotID'];
|
|
||||||
slotDate = json['slotDate'];
|
|
||||||
startTime = json['startTime'];
|
|
||||||
endTime = json['endTime'];
|
|
||||||
appointmentStatusID = json['appointmentStatusID'];
|
|
||||||
appointmentStatusText = json['appointmentStatusText'];
|
|
||||||
serviceProviderID = json['serviceProviderID'];
|
|
||||||
customerID = json['customerID'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
|
||||||
data['serviceSlotID'] = serviceSlotID;
|
|
||||||
data['slotDate'] = slotDate;
|
|
||||||
data['startTime'] = startTime;
|
|
||||||
data['endTime'] = endTime;
|
|
||||||
data['appointmentStatusID'] = appointmentStatusID;
|
|
||||||
data['appointmentStatusText'] = appointmentStatusText;
|
|
||||||
data['serviceProviderID'] = serviceProviderID;
|
|
||||||
data['customerID'] = customerID;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
class BuyersChatForAdsModel {
|
|
||||||
int? id;
|
|
||||||
String? buyerUserID;
|
|
||||||
String? buyerName;
|
|
||||||
int? adsID;
|
|
||||||
int? unReadMessagesCount;
|
|
||||||
String? lastMessage;
|
|
||||||
String? lastMessageDateTime;
|
|
||||||
|
|
||||||
BuyersChatForAdsModel({this.id, this.buyerUserID, this.buyerName, this.adsID});
|
|
||||||
|
|
||||||
BuyersChatForAdsModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
buyerUserID = json['buyerUserID'];
|
|
||||||
buyerName = json['buyerName'];
|
|
||||||
adsID = json['adsID'];
|
|
||||||
unReadMessagesCount = json['unReadCount'];
|
|
||||||
lastMessage = json['lastMessage'];
|
|
||||||
lastMessageDateTime = json['lastMessageDateTime'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final mResponse = mResponseFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
MResponse mResponseFromJson(String str) => MResponse.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String mResponseToJson(MResponse data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class MResponse {
|
||||||
|
MResponse({
|
||||||
|
this.totalItemsCount,
|
||||||
|
this.messageStatus,
|
||||||
|
this.message,
|
||||||
|
this.data,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? totalItemsCount;
|
||||||
|
int? messageStatus;
|
||||||
|
String? message;
|
||||||
|
dynamic data;
|
||||||
|
|
||||||
|
factory MResponse.fromJson(Map<String, dynamic> json) => MResponse(
|
||||||
|
totalItemsCount: json["totalItemsCount"],
|
||||||
|
messageStatus: json["messageStatus"],
|
||||||
|
message: json["message"],
|
||||||
|
data: json["data"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"totalItemsCount": totalItemsCount,
|
||||||
|
"messageStatus": messageStatus,
|
||||||
|
"message": message,
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -1,36 +0,0 @@
|
|||||||
class BranchRatingModel {
|
|
||||||
int? id;
|
|
||||||
String? title;
|
|
||||||
String? review;
|
|
||||||
int? ratNo;
|
|
||||||
int? serviceProviderBranchID;
|
|
||||||
String? serviceProviderBranchName;
|
|
||||||
int? customerID;
|
|
||||||
String? customerName;
|
|
||||||
|
|
||||||
BranchRatingModel({this.id, this.title, this.review, this.ratNo, this.serviceProviderBranchID, this.serviceProviderBranchName, this.customerID, this.customerName});
|
|
||||||
|
|
||||||
BranchRatingModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
title = json['title'];
|
|
||||||
review = json['review'];
|
|
||||||
ratNo = json['ratNo'];
|
|
||||||
serviceProviderBranchID = json['serviceProviderBranchID'];
|
|
||||||
serviceProviderBranchName = json['serviceProviderBranchName'];
|
|
||||||
customerID = json['customerID'];
|
|
||||||
customerName = json['customerName'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
|
||||||
data['id'] = id;
|
|
||||||
data['title'] = title;
|
|
||||||
data['review'] = review;
|
|
||||||
data['ratNo'] = ratNo;
|
|
||||||
data['serviceProviderBranchID'] = serviceProviderBranchID;
|
|
||||||
data['serviceProviderBranchName'] = serviceProviderBranchName;
|
|
||||||
data['customerID'] = customerID;
|
|
||||||
data['customerName'] = customerName;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
class ProviderContactInfoModel {
|
|
||||||
int? id;
|
|
||||||
int? providerID;
|
|
||||||
String? name;
|
|
||||||
int? allDocStatus;
|
|
||||||
String? companyName;
|
|
||||||
String? companyDescription;
|
|
||||||
int? countryID;
|
|
||||||
String? countryName;
|
|
||||||
String? userID;
|
|
||||||
String? memberSince;
|
|
||||||
String? mobile;
|
|
||||||
String? whatsApp;
|
|
||||||
String? email;
|
|
||||||
|
|
||||||
ProviderContactInfoModel({
|
|
||||||
this.id,
|
|
||||||
this.providerID,
|
|
||||||
this.name,
|
|
||||||
this.allDocStatus,
|
|
||||||
this.companyName,
|
|
||||||
this.companyDescription,
|
|
||||||
this.countryID,
|
|
||||||
this.countryName,
|
|
||||||
this.userID,
|
|
||||||
this.memberSince,
|
|
||||||
this.mobile,
|
|
||||||
this.whatsApp,
|
|
||||||
this.email,
|
|
||||||
});
|
|
||||||
|
|
||||||
ProviderContactInfoModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
providerID = json['providerID'];
|
|
||||||
name = json['name'];
|
|
||||||
allDocStatus = json['allDocStatus'];
|
|
||||||
companyName = json['companyName'];
|
|
||||||
companyDescription = json['companyDescription'];
|
|
||||||
countryID = json['countryID'];
|
|
||||||
countryName = json['countryName'];
|
|
||||||
userID = json['userID'];
|
|
||||||
memberSince = json['memberSince'];
|
|
||||||
mobile = json['mobile'];
|
|
||||||
whatsApp = json['whatsApp'];
|
|
||||||
email = json['email'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
class OffersUnreadChatModel {
|
|
||||||
final int reqTotal;
|
|
||||||
final List<OffersUnreadChatDataModel> reqChatUnread;
|
|
||||||
|
|
||||||
OffersUnreadChatModel({
|
|
||||||
required this.reqTotal,
|
|
||||||
required this.reqChatUnread,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OffersUnreadChatModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
return OffersUnreadChatModel(
|
|
||||||
reqTotal: json['total'],
|
|
||||||
reqChatUnread: (json['reqChatCountData'] as List).map((e) => OffersUnreadChatDataModel.fromJson(e)).toList(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class OffersUnreadChatDataModel {
|
|
||||||
String reqTitle;
|
|
||||||
int reqTotal;
|
|
||||||
int requestID;
|
|
||||||
String senderUserID;
|
|
||||||
int unreadMessagesCount;
|
|
||||||
String lastChatTime;
|
|
||||||
String lastChatText;
|
|
||||||
String customerName;
|
|
||||||
|
|
||||||
OffersUnreadChatDataModel({
|
|
||||||
required this.reqTitle,
|
|
||||||
required this.reqTotal,
|
|
||||||
required this.requestID,
|
|
||||||
required this.senderUserID,
|
|
||||||
required this.unreadMessagesCount,
|
|
||||||
required this.lastChatTime,
|
|
||||||
required this.lastChatText,
|
|
||||||
required this.customerName,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OffersUnreadChatDataModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
return OffersUnreadChatDataModel(
|
|
||||||
reqTitle: json['reqTitle'],
|
|
||||||
reqTotal: json['reqTotal'],
|
|
||||||
requestID: json['requestID'],
|
|
||||||
senderUserID: json['senderUserID'],
|
|
||||||
unreadMessagesCount: json['unreadMessagesCount'],
|
|
||||||
lastChatTime: json['lastChatTime'],
|
|
||||||
lastChatText: json['lastChatText'],
|
|
||||||
customerName: json['customerName'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// "reqTitle": "Spare_Parts / Ford / Edge / 2016",
|
|
||||||
// I/flutter (16941): │ "reqTotal": 1,
|
|
||||||
// I/flutter (16941): │ "requestID": 145,
|
|
||||||
// I/flutter (16941): │ "senderUserID": "b56bc6bd-e45c-4644-b7c4-08dd02460895",
|
|
||||||
// I/flutter (16941): │ "unreadMessagesCount": 0,
|
|
||||||
// I/flutter (16941): │ "lastChatTime": "2025-02-12T10:33:42.1433333",
|
|
||||||
// I/flutter (16941): │ "lastChatText": "I am accepting this offer.",
|
|
||||||
// I/flutter (16941): │ "customerName": "Faiz 100"
|
|
||||||
@ -1,158 +0,0 @@
|
|||||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
|
|
||||||
class ProviderOffersChatsModel {
|
|
||||||
int? id;
|
|
||||||
int? requestID;
|
|
||||||
int? serviceProviderID;
|
|
||||||
ServiceProviderModel? serviceProvider;
|
|
||||||
int? offerStatus;
|
|
||||||
RequestOfferStatusEnum? requestOfferStatusEnum;
|
|
||||||
String? offerStatusText;
|
|
||||||
String? comment;
|
|
||||||
String? customerName;
|
|
||||||
double? price;
|
|
||||||
String? serviceItem;
|
|
||||||
String? offeredItemCreatedBy;
|
|
||||||
String? offeredItemCreatedByName;
|
|
||||||
String? offeredItemCreatedOn;
|
|
||||||
String? reqOfferImages;
|
|
||||||
bool? isDeliveryAvailable;
|
|
||||||
String? createdOn;
|
|
||||||
|
|
||||||
ProviderOffersChatsModel({
|
|
||||||
this.id,
|
|
||||||
this.requestID,
|
|
||||||
this.serviceProviderID,
|
|
||||||
this.serviceProvider,
|
|
||||||
this.offerStatus,
|
|
||||||
this.requestOfferStatusEnum,
|
|
||||||
this.offerStatusText,
|
|
||||||
this.comment,
|
|
||||||
this.customerName,
|
|
||||||
this.price,
|
|
||||||
this.serviceItem,
|
|
||||||
this.offeredItemCreatedBy,
|
|
||||||
this.offeredItemCreatedByName,
|
|
||||||
this.offeredItemCreatedOn,
|
|
||||||
this.reqOfferImages,
|
|
||||||
this.isDeliveryAvailable,
|
|
||||||
this.createdOn,
|
|
||||||
});
|
|
||||||
|
|
||||||
ProviderOffersChatsModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
requestID = json['requestID'];
|
|
||||||
serviceProviderID = json['serviceProviderID'];
|
|
||||||
serviceProvider = json['serviceProvider'] != null ? ServiceProviderModel.fromJson(json['serviceProvider']) : null;
|
|
||||||
offerStatus = json['offerStatus'];
|
|
||||||
requestOfferStatusEnum = ((json['offerStatus']) as int).toRequestOfferStatusEnum();
|
|
||||||
offerStatusText = json['offerStatusText'];
|
|
||||||
comment = json['comment'];
|
|
||||||
customerName = json['customerName'];
|
|
||||||
price = json['price'];
|
|
||||||
serviceItem = json['serviceItem'];
|
|
||||||
offeredItemCreatedBy = json['offeredItemCreatedBy'];
|
|
||||||
offeredItemCreatedByName = json['offeredItemCreatedByName'];
|
|
||||||
offeredItemCreatedOn = json['offeredItemCreatedOn'];
|
|
||||||
reqOfferImages = json['reqOfferImages'];
|
|
||||||
isDeliveryAvailable = json['isDeliveryAvailable'];
|
|
||||||
createdOn = json['createdOn'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ServiceProviderModel {
|
|
||||||
int? providerId;
|
|
||||||
String? providerGUID;
|
|
||||||
String? firstName;
|
|
||||||
String? lastName;
|
|
||||||
String? name;
|
|
||||||
int? gender;
|
|
||||||
String? genderName;
|
|
||||||
String? mobileNo;
|
|
||||||
String? email;
|
|
||||||
bool? isEmailVerified;
|
|
||||||
bool? isCompleted;
|
|
||||||
int? city;
|
|
||||||
String? cityName;
|
|
||||||
int? country;
|
|
||||||
String? countryName;
|
|
||||||
int? accountStatus;
|
|
||||||
String? accountStatusText;
|
|
||||||
int? activityStatus;
|
|
||||||
String? activityStatusText;
|
|
||||||
String? bankName;
|
|
||||||
String? iBanNo;
|
|
||||||
bool? isActive;
|
|
||||||
String? subscriptionDate;
|
|
||||||
String? createdOn;
|
|
||||||
String? companyName;
|
|
||||||
String? currency;
|
|
||||||
String? branch;
|
|
||||||
bool? isChatted;
|
|
||||||
bool? isDealership;
|
|
||||||
|
|
||||||
ServiceProviderModel({
|
|
||||||
this.providerId,
|
|
||||||
this.providerGUID,
|
|
||||||
this.firstName,
|
|
||||||
this.lastName,
|
|
||||||
this.name,
|
|
||||||
this.gender,
|
|
||||||
this.genderName,
|
|
||||||
this.mobileNo,
|
|
||||||
this.email,
|
|
||||||
this.isEmailVerified,
|
|
||||||
this.isCompleted,
|
|
||||||
this.city,
|
|
||||||
this.cityName,
|
|
||||||
this.country,
|
|
||||||
this.countryName,
|
|
||||||
this.accountStatus,
|
|
||||||
this.accountStatusText,
|
|
||||||
this.activityStatus,
|
|
||||||
this.activityStatusText,
|
|
||||||
this.bankName,
|
|
||||||
this.iBanNo,
|
|
||||||
this.isActive,
|
|
||||||
this.subscriptionDate,
|
|
||||||
this.createdOn,
|
|
||||||
this.companyName,
|
|
||||||
this.currency,
|
|
||||||
this.branch,
|
|
||||||
this.isChatted,
|
|
||||||
this.isDealership,
|
|
||||||
});
|
|
||||||
|
|
||||||
ServiceProviderModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
providerId = json['providerId'];
|
|
||||||
providerGUID = json['providerGUID'];
|
|
||||||
firstName = json['firstName'];
|
|
||||||
lastName = json['lastName'];
|
|
||||||
name = json['name'];
|
|
||||||
gender = json['gender'];
|
|
||||||
genderName = json['genderName'];
|
|
||||||
mobileNo = json['mobileNo'];
|
|
||||||
email = json['email'];
|
|
||||||
isEmailVerified = json['isEmailVerfied'];
|
|
||||||
isCompleted = json['isCompleted'];
|
|
||||||
city = json['city'];
|
|
||||||
cityName = json['cityName'];
|
|
||||||
country = json['country'];
|
|
||||||
countryName = json['countryName'];
|
|
||||||
accountStatus = json['accountStatus'];
|
|
||||||
accountStatusText = json['accountStatusText'];
|
|
||||||
activityStatus = json['activityStatus'];
|
|
||||||
activityStatusText = json['activityStatusText'];
|
|
||||||
bankName = json['bankName'];
|
|
||||||
iBanNo = json['iBanNo'];
|
|
||||||
isActive = json['isActive'];
|
|
||||||
subscriptionDate = json['subscriptionDate'];
|
|
||||||
createdOn = json['createdOn'];
|
|
||||||
companyName = json['companyName'];
|
|
||||||
currency = json['currency'];
|
|
||||||
branch = json['branch'];
|
|
||||||
isChatted = json['isChatted'];
|
|
||||||
isDealership = json['isDealership'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
||||||
|
|
||||||
class AppInfoModel {
|
|
||||||
int? id;
|
|
||||||
String? header;
|
|
||||||
String? content;
|
|
||||||
bool? isActive;
|
|
||||||
int? channel;
|
|
||||||
List<ImageModel>? images;
|
|
||||||
|
|
||||||
AppInfoModel({this.id, this.header, this.content, this.isActive, this.channel, this.images});
|
|
||||||
|
|
||||||
AppInfoModel.fromJson(Map<String, dynamic> json, {bool isForTermsAndCondition = false}) {
|
|
||||||
String imagesKey = "appInfoImages";
|
|
||||||
if (isForTermsAndCondition) {
|
|
||||||
imagesKey = "termAndConditionImages";
|
|
||||||
}
|
|
||||||
id = json['id'];
|
|
||||||
header = json['header'];
|
|
||||||
content = json['content'];
|
|
||||||
isActive = json['isActive'];
|
|
||||||
channel = json['channel'];
|
|
||||||
if (json[imagesKey] != null) {
|
|
||||||
images = <ImageModel>[];
|
|
||||||
json[imagesKey].forEach((v) {
|
|
||||||
images!.add(ImageModel.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
class AppInvitationHistoryModel {
|
|
||||||
int? id;
|
|
||||||
int? customerID;
|
|
||||||
int? channelID;
|
|
||||||
int? appInvitationEnumID;
|
|
||||||
int? noOfInvites;
|
|
||||||
String? comments;
|
|
||||||
|
|
||||||
AppInvitationHistoryModel({
|
|
||||||
this.id,
|
|
||||||
this.customerID,
|
|
||||||
this.channelID,
|
|
||||||
this.appInvitationEnumID,
|
|
||||||
this.noOfInvites,
|
|
||||||
this.comments,
|
|
||||||
});
|
|
||||||
|
|
||||||
AppInvitationHistoryModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
customerID = json['customerID'];
|
|
||||||
channelID = json['channelID'];
|
|
||||||
appInvitationEnumID = json['appInvitationEnumID'];
|
|
||||||
noOfInvites = json['noofInvites'];
|
|
||||||
comments = json['comments'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
||||||
|
|
||||||
class ContactInfoModel {
|
|
||||||
int? id;
|
|
||||||
String? companyName;
|
|
||||||
String? mobileNo;
|
|
||||||
String? phoneNo;
|
|
||||||
String? email;
|
|
||||||
String? address;
|
|
||||||
String? latitude;
|
|
||||||
String? longitude;
|
|
||||||
int? channel;
|
|
||||||
bool? isActive;
|
|
||||||
List<ImageModel>? contactInfoImages;
|
|
||||||
|
|
||||||
ContactInfoModel({this.id, this.companyName, this.mobileNo, this.phoneNo, this.email, this.address, this.latitude, this.longitude, this.channel, this.isActive, this.contactInfoImages});
|
|
||||||
|
|
||||||
ContactInfoModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
companyName = json['companyName'];
|
|
||||||
mobileNo = json['mobileNo'];
|
|
||||||
phoneNo = json['phoneNo'];
|
|
||||||
email = json['email'];
|
|
||||||
address = json['address'];
|
|
||||||
latitude = json['latitude'];
|
|
||||||
longitude = json['longitude'];
|
|
||||||
channel = json['channel'];
|
|
||||||
isActive = json['isActive'];
|
|
||||||
if (json['contactInfoImages'] != null) {
|
|
||||||
contactInfoImages = <ImageModel>[];
|
|
||||||
json['contactInfoImages'].forEach((v) {
|
|
||||||
contactInfoImages!.add(ImageModel.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
class FAQsModel {
|
|
||||||
int? id;
|
|
||||||
String? question;
|
|
||||||
String? answer;
|
|
||||||
int? sequenceNo;
|
|
||||||
bool? isActive;
|
|
||||||
int? channel;
|
|
||||||
bool? isCollapsed;
|
|
||||||
|
|
||||||
FAQsModel({this.id, this.question, this.answer, this.sequenceNo, this.isActive, this.channel, this.isCollapsed});
|
|
||||||
|
|
||||||
FAQsModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
id = json['id'];
|
|
||||||
question = json['question'];
|
|
||||||
answer = json['answer'];
|
|
||||||
sequenceNo = json['sequenceNo'];
|
|
||||||
isActive = json['isActive'];
|
|
||||||
channel = json['channel'];
|
|
||||||
isCollapsed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
|
||||||
data['id'] = id;
|
|
||||||
data['question'] = question;
|
|
||||||
data['answer'] = answer;
|
|
||||||
data['sequenceNo'] = sequenceNo;
|
|
||||||
data['isActive'] = isActive;
|
|
||||||
data['channel'] = channel;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
|
|
||||||
class ShippingRequestModel {
|
|
||||||
int? id;
|
|
||||||
int? requestID;
|
|
||||||
Request? request;
|
|
||||||
int? pickupOrshippingStatus;
|
|
||||||
ShippingRequestStatusEnum? shippingStatusEnum;
|
|
||||||
SelfPickupRequestStatusEnum? selfPickupRequestStatusEnum;
|
|
||||||
String? deliveredorCollectedOn;
|
|
||||||
String? comment;
|
|
||||||
String? createdOn;
|
|
||||||
int? customerID;
|
|
||||||
String? customerName;
|
|
||||||
int? vehicleTypeID;
|
|
||||||
String? vehicleType;
|
|
||||||
|
|
||||||
ShippingRequestModel({
|
|
||||||
this.id,
|
|
||||||
this.requestID,
|
|
||||||
this.request,
|
|
||||||
this.pickupOrshippingStatus,
|
|
||||||
this.deliveredorCollectedOn,
|
|
||||||
this.comment,
|
|
||||||
this.createdOn,
|
|
||||||
this.customerID,
|
|
||||||
this.customerName,
|
|
||||||
this.vehicleTypeID,
|
|
||||||
this.vehicleType,
|
|
||||||
});
|
|
||||||
|
|
||||||
ShippingRequestModel.fromJsonShipping(Map<String, dynamic> json, bool isForShipping) {
|
|
||||||
id = json['id'];
|
|
||||||
requestID = json['requestID'];
|
|
||||||
request = json['request'] != null ? Request.fromJson(json['request']) : null;
|
|
||||||
pickupOrshippingStatus = isForShipping ? json['shippingStatus'] : json['selfPickUpStatus'];
|
|
||||||
shippingStatusEnum = isForShipping ? (json['shippingStatus'] != null ? (json['shippingStatus'] as int).toShippingStatusEnum() : ShippingRequestStatusEnum.initiated) : null;
|
|
||||||
selfPickupRequestStatusEnum =
|
|
||||||
isForShipping ? null : (json['selfPickUpStatus'] != null ? (json['selfPickUpStatus'] as int).toSelfPickupStatusEnum() : SelfPickupRequestStatusEnum.preparingToCollect);
|
|
||||||
deliveredorCollectedOn = isForShipping ? json['deliveredOn'] : json['collectedOn'];
|
|
||||||
comment = json['comment'];
|
|
||||||
createdOn = json['createdOn'];
|
|
||||||
customerID = json['customerID'];
|
|
||||||
customerName = json['customerName'];
|
|
||||||
vehicleTypeID = json['vehicleTypeID'];
|
|
||||||
vehicleType = json['vehicleType'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Request {
|
|
||||||
int? requestType;
|
|
||||||
String? brand;
|
|
||||||
String? model;
|
|
||||||
int? year;
|
|
||||||
bool? isNew;
|
|
||||||
String? description;
|
|
||||||
double? price;
|
|
||||||
|
|
||||||
Request({this.requestType, this.brand, this.model, this.year, this.isNew, this.description, this.price});
|
|
||||||
|
|
||||||
Request.fromJson(Map<String, dynamic> json) {
|
|
||||||
requestType = json['requestType'];
|
|
||||||
brand = json['brand'];
|
|
||||||
model = json['model'];
|
|
||||||
year = json['year'];
|
|
||||||
isNew = json['isNew'];
|
|
||||||
description = json['description'];
|
|
||||||
price = json['price'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = <String, dynamic>{};
|
|
||||||
data['requestType'] = requestType;
|
|
||||||
data['brand'] = brand;
|
|
||||||
data['model'] = model;
|
|
||||||
data['year'] = year;
|
|
||||||
data['isNew'] = isNew;
|
|
||||||
data['description'] = description;
|
|
||||||
data['price'] = price;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
class BranchSelectionModel {
|
|
||||||
int branchId;
|
|
||||||
String branchName;
|
|
||||||
bool isSelected;
|
|
||||||
bool isOpend;
|
|
||||||
List<UserSelectionModel> usersList;
|
|
||||||
|
|
||||||
BranchSelectionModel
|
|
||||||
|
|
||||||
({
|
|
||||||
|
|
||||||
required
|
|
||||||
|
|
||||||
this
|
|
||||||
|
|
||||||
.
|
|
||||||
branchId,
|
|
||||||
required this.branchName,
|
|
||||||
required this.isSelected,
|
|
||||||
this.isOpend = false,
|
|
||||||
required this.usersList,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class UserSelectionModel {
|
|
||||||
int userId;
|
|
||||||
String userName;
|
|
||||||
bool isSelected;
|
|
||||||
|
|
||||||
UserSelectionModel(
|
|
||||||
{required this.userId, required this.userName, required this.isSelected});
|
|
||||||
}
|
|
||||||
@ -1,98 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class ProviderSubscriptionModel {
|
|
||||||
int? id;
|
|
||||||
int? subscriptionAppliedId;
|
|
||||||
int? serviceProviderId;
|
|
||||||
String? subscriptionName;
|
|
||||||
String? subscriptionDescription;
|
|
||||||
DateTime? dateStart;
|
|
||||||
DateTime? dateEnd;
|
|
||||||
int? branchesRemaining;
|
|
||||||
int? subUsersRemaining;
|
|
||||||
int? subscriptionID;
|
|
||||||
int? adsRemaining;
|
|
||||||
bool? isExpired;
|
|
||||||
bool? isActive;
|
|
||||||
bool? isUpgradeNow;
|
|
||||||
bool? isUpgradeLater;
|
|
||||||
bool? isTrialSubscription;
|
|
||||||
dynamic currentSubscription;
|
|
||||||
int? totalBranches;
|
|
||||||
int? totalSubUsers;
|
|
||||||
int? totalAds;
|
|
||||||
|
|
||||||
|
|
||||||
ProviderSubscriptionModel({
|
|
||||||
this.id,
|
|
||||||
this.subscriptionAppliedId,
|
|
||||||
this.serviceProviderId,
|
|
||||||
this.subscriptionName,
|
|
||||||
this.subscriptionDescription,
|
|
||||||
this.dateStart,
|
|
||||||
this.dateEnd,
|
|
||||||
this.branchesRemaining,
|
|
||||||
this.subUsersRemaining,
|
|
||||||
this.adsRemaining,
|
|
||||||
this.isExpired,
|
|
||||||
this.isActive,
|
|
||||||
this.isUpgradeNow,
|
|
||||||
this.isUpgradeLater,
|
|
||||||
this.isTrialSubscription,
|
|
||||||
this.currentSubscription,
|
|
||||||
this.subscriptionID,
|
|
||||||
this.totalAds,
|
|
||||||
this.totalBranches,
|
|
||||||
this.totalSubUsers,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory ProviderSubscriptionModel.fromRawJson(String str) => ProviderSubscriptionModel.fromJson(json.decode(str));
|
|
||||||
|
|
||||||
String toRawJson() => json.encode(toJson());
|
|
||||||
|
|
||||||
factory ProviderSubscriptionModel.fromJson(Map<String, dynamic> json) => ProviderSubscriptionModel(
|
|
||||||
id: json["id"],
|
|
||||||
subscriptionAppliedId: json["subscriptionAppliedID"],
|
|
||||||
serviceProviderId: json["serviceProviderID"],
|
|
||||||
subscriptionID: json["subscriptionID"],
|
|
||||||
subscriptionName: json["subscriptionName"],
|
|
||||||
subscriptionDescription: json["subscriptionDescription"],
|
|
||||||
dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]),
|
|
||||||
dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]),
|
|
||||||
branchesRemaining: json["branchesRemaining"],
|
|
||||||
subUsersRemaining: json["subUsersRemaining"],
|
|
||||||
adsRemaining: json["adsRemaining"],
|
|
||||||
isExpired: json["isExpired"],
|
|
||||||
isActive: json["isActive"],
|
|
||||||
isUpgradeNow: json["isUpgradeNow"],
|
|
||||||
isUpgradeLater: json["isUpgradeLater"],
|
|
||||||
isTrialSubscription: json["isTrialSubscription"],
|
|
||||||
currentSubscription: json["currentSubscription"],
|
|
||||||
totalBranches: json["totalBranches"],
|
|
||||||
totalAds: json["totalAds"],
|
|
||||||
totalSubUsers: json["totalSubUsers"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"id": id,
|
|
||||||
"subscriptionAppliedID": subscriptionAppliedId,
|
|
||||||
"serviceProviderID": serviceProviderId,
|
|
||||||
"subscriptionID": subscriptionID,
|
|
||||||
"subscriptionName": subscriptionName,
|
|
||||||
"subscriptionDescription": subscriptionDescription,
|
|
||||||
"dateStart": dateStart?.toIso8601String(),
|
|
||||||
"dateEnd": dateEnd?.toIso8601String(),
|
|
||||||
"branchesRemaining": branchesRemaining,
|
|
||||||
"subUsersRemaining": subUsersRemaining,
|
|
||||||
"adsRemaining": adsRemaining,
|
|
||||||
"isExpired": isExpired,
|
|
||||||
"isActive": isActive,
|
|
||||||
"isUpgradeNow": isUpgradeNow,
|
|
||||||
"isUpgradeLater": isUpgradeLater,
|
|
||||||
"isTrialSubscription": isTrialSubscription,
|
|
||||||
"currentSubscription": currentSubscription,
|
|
||||||
"totalAds": totalAds,
|
|
||||||
"totalSubUsers": totalSubUsers,
|
|
||||||
"totalBranches": totalBranches,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,643 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.dart';
|
|
||||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
||||||
import 'package:mc_common_app/models/appointments_models/appointment_basic_detail_model.dart';
|
|
||||||
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/branch_review_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/profile/branch.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/profile/categroy.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/profile/document.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/profile/services.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/provider_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services_models/item_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services_models/service_model.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
|
|
||||||
abstract class BranchRepo {
|
|
||||||
Future<GenericRespModel> createBranch({
|
|
||||||
required String branchName,
|
|
||||||
required String branchDescription,
|
|
||||||
required int cityId,
|
|
||||||
required String address,
|
|
||||||
required String openTime,
|
|
||||||
required String closeTime,
|
|
||||||
required double latitude,
|
|
||||||
required double longitude,
|
|
||||||
required List<BranchPostingImages> imagesList,
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateBranch({
|
|
||||||
required int branchId,
|
|
||||||
required String branchName,
|
|
||||||
required String branchDescription,
|
|
||||||
required String openTime,
|
|
||||||
required String closeTime,
|
|
||||||
required int cityId,
|
|
||||||
required String address,
|
|
||||||
required String latitude,
|
|
||||||
required String longitude,
|
|
||||||
required List<BranchPostingImages> imagesList,
|
|
||||||
bool isNeedToDelete = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<GenericRespModel> deleteBranch({required int branchId});
|
|
||||||
|
|
||||||
Future<Branch> fetchAllBranches();
|
|
||||||
|
|
||||||
Future<Category> fetchBranchCategory();
|
|
||||||
|
|
||||||
Future<Services> fetchServicesByCategoryId({required int serviceCategoryId});
|
|
||||||
|
|
||||||
Future<Services> fetchProviderServices(String branchID, String serviceCategoryId);
|
|
||||||
|
|
||||||
Future<List<ServiceModel>> fetchProviderServicesModelByCategoryIdAndBranchID(String branchID, String serviceCategoryId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> createNewService(List<Map<String, dynamic>> map);
|
|
||||||
|
|
||||||
Future<Document> getServiceProviderDocument(dynamic userId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> serviceProviderDocumentsUpdate(List<DocumentData>? documents);
|
|
||||||
|
|
||||||
Future<ProviderModel> getBranchAndServices();
|
|
||||||
|
|
||||||
Future<List<ProviderBasicDataModel>> getAllProvidersWitheBasicData();
|
|
||||||
|
|
||||||
Future<GenericRespModel> createService(List<Map<String, dynamic>> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateService(List<Map<String, dynamic>> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateServiceStatus({required int branchId, required List<int> serviceIds, required ServiceStatusEnum serviceStatusEnum});
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateCategoryStatus({required int branchId, required int categoryId, required ServiceStatusEnum serviceStatusEnum});
|
|
||||||
|
|
||||||
Future<List<AppointmentBasicDetailsModel>> getAppointmentsByCategoryOrService({required int branchId, required int categoryId, required int serviceId});
|
|
||||||
|
|
||||||
Future<GenericRespModel> getMatchedServices(int oldBranchId, int newBranchId, int categoryId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> duplicateItems({required String providerBranchID, required List<int> items});
|
|
||||||
|
|
||||||
Future<GenericRespModel> getAllProviderDealers(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> getBranchUsers(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> assignDealerToBranch(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> removeDealerFromBranch(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> addNewServicesInAppointment(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<List<BranchDetailModel>> getAllNearBranchAndServices({required double latitude, required double longitude});
|
|
||||||
|
|
||||||
Future<List<ItemData>> getServiceItems({required int serviceId});
|
|
||||||
|
|
||||||
Future<ProviderProfileModel> getBranchAndServicesByProviderId(int providerId, {double? latitude, double? longitude});
|
|
||||||
|
|
||||||
Future<List<BranchDetailModel>> getBranchesByFilters({
|
|
||||||
List<int>? providerIdsList,
|
|
||||||
List<int>? categoryIdsList,
|
|
||||||
List<int>? serviceIdsList,
|
|
||||||
int? distanceKm,
|
|
||||||
int? rating,
|
|
||||||
double? latitude,
|
|
||||||
double? longitude,
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<List<BranchDetailModel>> getMyRecentBranchesWithServices();
|
|
||||||
|
|
||||||
Future<List<BranchRatingModel>> getBranchRatings({required int serviceProviderBranchID});
|
|
||||||
|
|
||||||
Future<GenericRespModel> submitBranchRatings({required int serviceProviderBranchID, required String title, required String review, required double ratingNo});
|
|
||||||
|
|
||||||
Future<GenericRespModel> addProviderToFavourite({required int providerID});
|
|
||||||
|
|
||||||
Future<GenericRespModel> removeProviderFromFavourite({required int providerID});
|
|
||||||
|
|
||||||
Future<List<ProviderProfileModel>> getMyFavoriteProviders();
|
|
||||||
}
|
|
||||||
|
|
||||||
class BranchRepoImp implements BranchRepo {
|
|
||||||
ApiClient apiClient = injector.get<ApiClient>();
|
|
||||||
AppState appState = injector.get<AppState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> createBranch({
|
|
||||||
required String branchName,
|
|
||||||
required String branchDescription,
|
|
||||||
required int cityId,
|
|
||||||
required String address,
|
|
||||||
required String openTime,
|
|
||||||
required String closeTime,
|
|
||||||
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.toString(),
|
|
||||||
"address": address,
|
|
||||||
"openTime": openTime,
|
|
||||||
"closeTime": closeTime,
|
|
||||||
"latitude": latitude,
|
|
||||||
"longitude": longitude,
|
|
||||||
"isActive": true,
|
|
||||||
"serviceProviderBranchImages": serviceProviderBranchImages,
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Branch> fetchAllBranches() async {
|
|
||||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => Branch.fromJson(json), ApiConsts.serviceProviderBranchGet, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Category> fetchBranchCategory() async {
|
|
||||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => Category.fromJson(json), ApiConsts.serviceCategoryGet, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Services> fetchServicesByCategoryId({required int serviceCategoryId}) async {
|
|
||||||
var postParams = {"ServiceCategoryID": serviceCategoryId.toString()};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => Services.fromJson(json), ApiConsts.servicesGet, queryParameters: serviceCategoryId.toString() != "-1" ? postParams : null, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> createNewService(List<Map<String, dynamic>> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderServiceCreate, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Document> getServiceProviderDocument(dynamic userId) async {
|
|
||||||
var queryParameters = {
|
|
||||||
"ServiceProviderID": userId.toString(),
|
|
||||||
};
|
|
||||||
String? token = AppState().getUser.data?.accessToken;
|
|
||||||
debugPrint(token);
|
|
||||||
return await injector
|
|
||||||
.get<ApiClient>()
|
|
||||||
.getJsonForObject((json) => Document.fromJson(json), ApiConsts.fetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> serviceProviderDocumentsUpdate(List<DocumentData>? documents) async {
|
|
||||||
List<Map<String, dynamic>> map = [];
|
|
||||||
for (int i = 0; i < documents!.length; i++) {
|
|
||||||
if (documents[i].document != null) {
|
|
||||||
var postParams = {
|
|
||||||
"id": documents[i].id,
|
|
||||||
"serviceProviderID": documents[i].serviceProviderId,
|
|
||||||
"documentID": documents[i].documentId,
|
|
||||||
"documentExt": documents[i].fileExt,
|
|
||||||
"documentImage": documents[i].document,
|
|
||||||
"isActive": true,
|
|
||||||
"dateExpire": documents[i].dateExpire,
|
|
||||||
};
|
|
||||||
map.add(postParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderDocumentUpdate, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ProviderModel> getBranchAndServices() async {
|
|
||||||
var postParams = {"serviceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => ProviderModel.fromJson(json), ApiConsts.branchesAndServices, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ProviderBasicDataModel>> getAllProvidersWitheBasicData() async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
token: t,
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.serviceProviderDDLGet,
|
|
||||||
);
|
|
||||||
List<ProviderBasicDataModel> providersList = List.generate(adsGenericModel.data.length, (index) => ProviderBasicDataModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return providersList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateBranch({
|
|
||||||
required int branchId,
|
|
||||||
required String branchName,
|
|
||||||
required String branchDescription,
|
|
||||||
required String openTime,
|
|
||||||
required String closeTime,
|
|
||||||
required int cityId,
|
|
||||||
required String address,
|
|
||||||
required String latitude,
|
|
||||||
required String longitude,
|
|
||||||
required List<BranchPostingImages> imagesList,
|
|
||||||
bool isNeedToDelete = true,
|
|
||||||
}) 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
String lat = "0", long = "0";
|
|
||||||
try {
|
|
||||||
lat = latitude.toString().substring(0, 9);
|
|
||||||
long = longitude.toString().substring(0, 9);
|
|
||||||
} catch (e) {}
|
|
||||||
var postParams = {
|
|
||||||
"id": branchId,
|
|
||||||
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
|
||||||
"branchName": branchName,
|
|
||||||
"branchDescription": branchDescription,
|
|
||||||
"openTime": openTime,
|
|
||||||
"closeTime": closeTime,
|
|
||||||
"cityID": cityId,
|
|
||||||
"address": address,
|
|
||||||
"latitude": lat,
|
|
||||||
"longitude": long,
|
|
||||||
"serviceProviderBranchImages": serviceProviderBranchImages,
|
|
||||||
"isActive": isNeedToDelete
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.updateProviderBranch, postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> deleteBranch({required int branchId}) async {
|
|
||||||
var postParams = {
|
|
||||||
"id": branchId,
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.deleteProviderBranch, postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> createService(List<Map<String, dynamic>> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderServiceCreate, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateService(List<Map<String, dynamic>> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderServiceUpdate, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateServiceStatus({required int branchId, required List<int> serviceIds, required ServiceStatusEnum serviceStatusEnum}) async {
|
|
||||||
List<String> ids = [];
|
|
||||||
|
|
||||||
for (var id in serviceIds) {
|
|
||||||
ids.add(id.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
int providerID = AppState().getUser.data!.userInfo!.providerId;
|
|
||||||
var map = {
|
|
||||||
"ServiceProviderID": providerID.toString(),
|
|
||||||
"ProviderBranchID": branchId.toString(),
|
|
||||||
"ProviderServiceIDs": ids,
|
|
||||||
"Status": serviceStatusEnum.getIdFromServiceStatusEnum().toString(),
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderServiceStatusUpdate, queryParameters: map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateCategoryStatus({required int branchId, required int categoryId, required ServiceStatusEnum serviceStatusEnum}) async {
|
|
||||||
int providerID = AppState().getUser.data!.userInfo!.providerId;
|
|
||||||
var map = {
|
|
||||||
"ServiceProviderID": providerID.toString(),
|
|
||||||
"ProviderBranchID": branchId.toString(),
|
|
||||||
"ServiceCategoryID": categoryId.toString(),
|
|
||||||
"Status": serviceStatusEnum.getIdFromServiceStatusEnum().toString(),
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.serviceProviderServiceStatusUpdate, queryParameters: map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<AppointmentBasicDetailsModel>> getAppointmentsByCategoryOrService({required int branchId, required int categoryId, required int serviceId}) async {
|
|
||||||
var map = {
|
|
||||||
"ProviderBranchID": branchId.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (serviceId != -1) {
|
|
||||||
map.addAll({
|
|
||||||
"ServiceProviderServiceID": serviceId.toString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (categoryId != -1) {
|
|
||||||
map.addAll({
|
|
||||||
"ServiceProviderServiceID": serviceId.toString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
GenericRespModel genericRespModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.serviceProviderAppointmentGetByCategoryOrService,
|
|
||||||
queryParameters: map,
|
|
||||||
token: t,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<AppointmentBasicDetailsModel> basicAppointmentList = List.generate(genericRespModel.data.length, (index) => AppointmentBasicDetailsModel.fromJson(genericRespModel.data[index]));
|
|
||||||
|
|
||||||
return basicAppointmentList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> getMatchedServices(int oldBranchId, int newBranchId, int categoryId) async {
|
|
||||||
var postParams = {
|
|
||||||
"ProviderBranchIDExisted": oldBranchId.toString(),
|
|
||||||
"ProviderBranchIDNew": newBranchId.toString(),
|
|
||||||
"CategoryID": categoryId.toString(),
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.getMatchedServices, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> duplicateItems({required String providerBranchID, required List<int> items}) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, dynamic> map = {
|
|
||||||
"providerBranchID": providerBranchID,
|
|
||||||
"serviceItems": items,
|
|
||||||
};
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.duplicateItems, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> getAllProviderDealers(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.getAllProviderDealers, queryParameters: map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> getBranchUsers(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.getBranchUser, queryParameters: map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> assignDealerToBranch(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.assignDealerToBranch, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> removeDealerFromBranch(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.removeDealerFromBranch, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Services> fetchProviderServices(String branchID, String serviceCategoryId) async {
|
|
||||||
var postParams = {
|
|
||||||
"ServiceCategoryID": serviceCategoryId,
|
|
||||||
"ProviderBranchID": branchID,
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.getJsonForObject((json) => Services.fromJson(json), ApiConsts.getProviderServices, queryParameters: postParams, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ServiceModel>> fetchProviderServicesModelByCategoryIdAndBranchID(String branchID, String serviceCategoryId) async {
|
|
||||||
var queryParameters = {
|
|
||||||
"ID": branchID,
|
|
||||||
"ServiceCategoryIDs": [serviceCategoryId],
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAllNearBranches,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
);
|
|
||||||
List<BranchDetailModel> nearBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
if (nearBranches.isNotEmpty) {
|
|
||||||
List<ServiceModel> services = nearBranches.first.branchServices ?? [];
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> addNewServicesInAppointment(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.addNewServicesInAppointment, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<BranchDetailModel>> getAllNearBranchAndServices({required double latitude, required double longitude}) async {
|
|
||||||
var queryParameters = {
|
|
||||||
"isActive": "true",
|
|
||||||
"Status": "3",
|
|
||||||
"latitude": latitude.toString(),
|
|
||||||
"longitude": longitude.toString(),
|
|
||||||
};
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAllNearBranches,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
);
|
|
||||||
List<BranchDetailModel> nearBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return nearBranches;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<BranchDetailModel>> getMyRecentBranchesWithServices() async {
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getMyRecentBranches,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
);
|
|
||||||
List<BranchDetailModel> recentBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return recentBranches;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ItemData>> getServiceItems({required int serviceId}) async {
|
|
||||||
var queryParameters = {
|
|
||||||
"ServiceProviderServiceID": serviceId.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getServiceItems,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: serviceId.toString() != "-1" ? queryParameters : null,
|
|
||||||
);
|
|
||||||
List<ItemData> serviceItems = List.generate(adsGenericModel.data.length, (index) => ItemData.fromJson(adsGenericModel.data[index]));
|
|
||||||
return serviceItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ProviderProfileModel> getBranchAndServicesByProviderId(int providerId, {double? latitude, double? longitude}) async {
|
|
||||||
var postParams = {
|
|
||||||
"serviceProviderID": providerId.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (latitude != null && longitude != null) {
|
|
||||||
postParams.addAll({"Longitude": "$longitude"});
|
|
||||||
postParams.addAll({"Latitude": "$latitude"});
|
|
||||||
}
|
|
||||||
GenericRespModel adsGenericModel =
|
|
||||||
await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.branchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams);
|
|
||||||
|
|
||||||
return ProviderProfileModel.fromJson(adsGenericModel.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<BranchDetailModel>> getBranchesByFilters({
|
|
||||||
List<int>? providerIdsList,
|
|
||||||
List<int>? categoryIdsList,
|
|
||||||
List<int>? serviceIdsList,
|
|
||||||
int? distanceKm,
|
|
||||||
int? rating,
|
|
||||||
double? latitude,
|
|
||||||
double? longitude,
|
|
||||||
}) async {
|
|
||||||
List<String> providerIds = [];
|
|
||||||
if (providerIdsList != null) {
|
|
||||||
for (var element in providerIdsList) {
|
|
||||||
providerIds.add(element.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> categoryIds = [];
|
|
||||||
if (categoryIdsList != null) {
|
|
||||||
for (var element in categoryIdsList) {
|
|
||||||
categoryIds.add(element.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> serviceIds = [];
|
|
||||||
if (serviceIdsList != null) {
|
|
||||||
for (var element in serviceIdsList) {
|
|
||||||
serviceIds.add(element.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var postParams = {
|
|
||||||
"ServiceProviderIDs": providerIds,
|
|
||||||
"ServiceCategoryIDs": categoryIds,
|
|
||||||
"ServiceIDs": serviceIds,
|
|
||||||
"DistanceByKM": "${distanceKm ?? 0}",
|
|
||||||
"Rating": "${rating ?? 0}",
|
|
||||||
"Latitude": latitude.toString(),
|
|
||||||
"Longitude": longitude.toString(),
|
|
||||||
"Status": "3",
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAllNearBranches,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: postParams,
|
|
||||||
);
|
|
||||||
List<BranchDetailModel> nearBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return nearBranches;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<BranchRatingModel>> getBranchRatings({required int serviceProviderBranchID}) async {
|
|
||||||
var postParams = {"ServiceProviderBranchID": serviceProviderBranchID.toString()};
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getBranchRatings,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: postParams,
|
|
||||||
);
|
|
||||||
List<BranchRatingModel> branchRatings = List.generate(adsGenericModel.data.length, (index) => BranchRatingModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return branchRatings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> submitBranchRatings({required int serviceProviderBranchID, required String title, required String review, required double ratingNo}) async {
|
|
||||||
final customerID = appState.getUser.data!.userInfo!.customerId;
|
|
||||||
final parameters = {"title": title, "review": review, "ratNo": ratingNo, "serviceProviderBranchID": serviceProviderBranchID, "customerID": "$customerID"};
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.createBranchRatings,
|
|
||||||
parameters,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
);
|
|
||||||
return adsGenericModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> addProviderToFavourite({required int providerID}) async {
|
|
||||||
final customerID = appState.getUser.data!.userInfo!.customerId;
|
|
||||||
final parameters = {
|
|
||||||
"providerID": providerID.toString(),
|
|
||||||
"customerID": customerID.toString(),
|
|
||||||
};
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.favouriteServiceProviderCreate,
|
|
||||||
parameters,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
);
|
|
||||||
return adsGenericModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> removeProviderFromFavourite({required int providerID}) async {
|
|
||||||
final parameters = {"id": providerID.toString()};
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.unFavouriteServiceProvider,
|
|
||||||
parameters,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
);
|
|
||||||
return adsGenericModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ProviderProfileModel>> getMyFavoriteProviders() async {
|
|
||||||
final customerID = appState.getUser.data!.userInfo!.customerId;
|
|
||||||
|
|
||||||
var postParams = {"customerID": customerID.toString()};
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.favouriteServiceProviderGet,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: postParams,
|
|
||||||
);
|
|
||||||
List<ProviderProfileModel> favProviders = List.generate(adsGenericModel.data.length, (index) => ProviderProfileModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
return favProviders;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.dart';
|
|
||||||
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/services_models/item_model.dart';
|
|
||||||
|
|
||||||
|
|
||||||
abstract class ItemsRepo {
|
|
||||||
Future<GenericRespModel> createServiceItems(Map map);
|
|
||||||
|
|
||||||
Future<ItemModel> getServiceItems(int serviceId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateServiceItem(Map map);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemsRepoImp implements ItemsRepo {
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> createServiceItems(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createItems, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ItemModel> getServiceItems(int serviceId) async {
|
|
||||||
var queryParameters = {
|
|
||||||
"ServiceProviderServiceID": serviceId.toString(),
|
|
||||||
};
|
|
||||||
String? token = AppState().getUser.data?.accessToken;
|
|
||||||
return await injector
|
|
||||||
.get<ApiClient>()
|
|
||||||
.getJsonForObject((json) => ItemModel.fromJson(json), ApiConsts.getServiceItems, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateServiceItem(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.updateServiceItem, map, token: t);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:mc_common_app/api/api_client.dart';
|
||||||
|
import 'package:mc_common_app/classes/app_state.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
||||||
|
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
||||||
|
import 'package:mc_common_app/models/provider_branches_models/provider_profile_model.dart';
|
||||||
|
import 'package:mc_common_app/models/services_models/item_model.dart';
|
||||||
|
|
||||||
|
abstract class ProviderRepo {
|
||||||
|
Future<List<BranchDetailModel>> getAllNearBranchAndServices();
|
||||||
|
|
||||||
|
Future<List<ItemData>> getServiceItems(int serviceId);
|
||||||
|
|
||||||
|
Future<ProviderProfileModel> getBranchAndServices(int providerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProviderRepoImp implements ProviderRepo {
|
||||||
|
ApiClient apiClient = injector.get<ApiClient>();
|
||||||
|
AppState appState = injector.get<AppState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<BranchDetailModel>> getAllNearBranchAndServices() async {
|
||||||
|
GenericRespModel adsGenericModel = await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.GetAllNearBranches, token: appState.getUser.data!.accessToken);
|
||||||
|
List<BranchDetailModel> nearBranches = List.generate(adsGenericModel.data.length, (index) => BranchDetailModel.fromJson(adsGenericModel.data[index]));
|
||||||
|
return nearBranches;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<ItemData>> getServiceItems(int serviceId) async {
|
||||||
|
var queryParameters = {
|
||||||
|
"ServiceProviderServiceID": serviceId.toString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
||||||
|
(json) => GenericRespModel.fromJson(json),
|
||||||
|
ApiConsts.getServiceItems,
|
||||||
|
token: appState.getUser.data!.accessToken,
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
);
|
||||||
|
List<ItemData> serviceItems = List.generate(adsGenericModel.data.length, (index) => ItemData.fromJson(adsGenericModel.data[index]));
|
||||||
|
return serviceItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ProviderProfileModel> getBranchAndServices(int providerId) async {
|
||||||
|
var postParams = {"serviceProviderID": providerId.toString()};
|
||||||
|
GenericRespModel adsGenericModel =
|
||||||
|
await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.BranchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams);
|
||||||
|
|
||||||
|
return ProviderProfileModel.fromJson(adsGenericModel.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,82 +0,0 @@
|
|||||||
import 'package:mc_common_app/models/appointments_models/schedule_model.dart';
|
|
||||||
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/profile/services.dart';
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.dart';
|
|
||||||
|
|
||||||
abstract class ScheduleRepo {
|
|
||||||
Future<Services> getAllServices(String branchId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> createSchedule(Map map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> checkServiceGroupInBranchSchedule(Map map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> addServicesInSchedule(Map map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateSchedule(Map map);
|
|
||||||
|
|
||||||
Future<Schedule> getSchedules(String branchId);
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateServicesInSchedule(Map map);
|
|
||||||
|
|
||||||
Future<GenericRespModel> setScheduleInActive(int scheduleId, int branchId);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ScheduleRepoImp implements ScheduleRepo {
|
|
||||||
@override
|
|
||||||
Future<Services> getAllServices(String branchId) async {
|
|
||||||
Map<String, dynamic> map = {"ProviderBranchID": branchId};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().getJsonForObject((json) => Services.fromJson(json), ApiConsts.getServicesOfBranch, token: t, queryParameters: map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> createSchedule(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createSchedule, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> checkServiceGroupInBranchSchedule(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.checkGroupServiceInBranchSchedule, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> addServicesInSchedule(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.createGroup, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Schedule> getSchedules(String branchId) async {
|
|
||||||
Map<String, dynamic> map = {"ServiceProviderBranchID": branchId};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().getJsonForObject((json) => Schedule.fromJson(json), ApiConsts.getSchedule, token: t, queryParameters: map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> setScheduleInActive(int scheduleId, int branchId) async {
|
|
||||||
Map<String, dynamic> map = {
|
|
||||||
"id": scheduleId,
|
|
||||||
"serviceProviderBranchID": branchId,
|
|
||||||
"isActive": false,
|
|
||||||
};
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.setScheduleInactive, token: t, map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateSchedule(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.updateSchedule, map, token: t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateServicesInSchedule(Map map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.updateGroup, map, token: t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,214 +0,0 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.dart';
|
|
||||||
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/setting_utils_models/app_info_model.dart';
|
|
||||||
import 'package:mc_common_app/models/setting_utils_models/app_invitation_history_model.dart';
|
|
||||||
import 'package:mc_common_app/models/setting_utils_models/contact_infos_model.dart';
|
|
||||||
import 'package:mc_common_app/models/setting_utils_models/faqs_model.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
import 'package:mc_common_app/utils/utils.dart';
|
|
||||||
|
|
||||||
abstract class SettingOptionsRepo {
|
|
||||||
Future<List<FAQsModel>> getAllFaqs();
|
|
||||||
|
|
||||||
Future<List<ContactInfoModel>> getAllContactInfos();
|
|
||||||
|
|
||||||
Future<List<AppInfoModel>> getAppInfoList();
|
|
||||||
|
|
||||||
Future<List<AppInfoModel>> getTermsAndConditions();
|
|
||||||
|
|
||||||
Future<GenericRespModel> appInvitationCreate({required int channelId, required String message});
|
|
||||||
|
|
||||||
Future<List<AppInvitationHistoryModel>> getAppInvitationsHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
class SettingOptionsRepoImp extends SettingOptionsRepo {
|
|
||||||
ApiClient apiClient = injector.get<ApiClient>();
|
|
||||||
AppState appState = injector.get<AppState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<FAQsModel>> getAllFaqs() async {
|
|
||||||
int channel = 0;
|
|
||||||
|
|
||||||
if (AppState().currentAppType == AppType.provider) {
|
|
||||||
channel = 2;
|
|
||||||
} else {
|
|
||||||
channel = 3;
|
|
||||||
}
|
|
||||||
final params = {
|
|
||||||
"Channel": channel.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAllFAQs,
|
|
||||||
token: token,
|
|
||||||
queryParameters: params,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FAQsModel> list = List.generate(genericRespModel.data.length, (index) => FAQsModel.fromJson(genericRespModel.data[index]));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ContactInfoModel>> getAllContactInfos() async {
|
|
||||||
int channel = 0;
|
|
||||||
|
|
||||||
if (AppState().currentAppType == AppType.provider) {
|
|
||||||
channel = 2;
|
|
||||||
} else {
|
|
||||||
channel = 3;
|
|
||||||
}
|
|
||||||
final params = {"Channel": channel.toString()};
|
|
||||||
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getContactInfo,
|
|
||||||
queryParameters: params,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ContactInfoModel> list = List.generate(genericRespModel.data.length, (index) => ContactInfoModel.fromJson(genericRespModel.data[index]));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<AppInfoModel>> getAppInfoList() async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
int channel = 0;
|
|
||||||
|
|
||||||
if (AppState().currentAppType == AppType.provider) {
|
|
||||||
channel = 2;
|
|
||||||
} else {
|
|
||||||
channel = 3;
|
|
||||||
}
|
|
||||||
final params = {
|
|
||||||
"Channel": channel.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAppInfo,
|
|
||||||
token: token,
|
|
||||||
queryParameters: params,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<AppInfoModel> list = List.generate(genericRespModel.data.length, (index) => AppInfoModel.fromJson(genericRespModel.data[index]));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<AppInfoModel>> getTermsAndConditions() async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
int channel = 0;
|
|
||||||
|
|
||||||
if (AppState().currentAppType == AppType.provider) {
|
|
||||||
channel = 2;
|
|
||||||
} else {
|
|
||||||
channel = 3;
|
|
||||||
}
|
|
||||||
final params = {
|
|
||||||
"Channel": channel.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getTermsAndConditions,
|
|
||||||
token: token,
|
|
||||||
queryParameters: params,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<AppInfoModel> list = List.generate(genericRespModel.data.length, (index) => AppInfoModel.fromJson(genericRespModel.data[index], isForTermsAndCondition: true));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> appInvitationCreate({required int channelId, required String message}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
final params = {
|
|
||||||
"appInvitationEnumID": channelId.toString(),
|
|
||||||
"comments": message,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (AppState().currentAppType == AppType.customer) {
|
|
||||||
params.addAll({
|
|
||||||
"customerID": (appState.getUser.data!.userInfo!.customerId ?? "0").toString(),
|
|
||||||
"channelID": "3",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
params.addAll({
|
|
||||||
"providerID": (appState.getUser.data!.userInfo!.providerId ?? "0").toString(),
|
|
||||||
"channelID": "2",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.createAppInvitation,
|
|
||||||
token: token,
|
|
||||||
params,
|
|
||||||
);
|
|
||||||
return genericRespModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<AppInvitationHistoryModel>> getAppInvitationsHistory() async {
|
|
||||||
final params = {
|
|
||||||
"CustomerID": (appState.getUser.data!.userInfo!.customerId ?? "0").toString(),
|
|
||||||
"ChannelID": "3",
|
|
||||||
};
|
|
||||||
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getAppInvitationHistory,
|
|
||||||
queryParameters: params,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<AppInvitationHistoryModel> list = List.generate(genericRespModel.data.length, (index) => AppInvitationHistoryModel.fromJson(genericRespModel.data[index]));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.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/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/shipping_models/shipping_status_model.dart';
|
|
||||||
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
import 'package:mc_common_app/utils/utils.dart';
|
|
||||||
|
|
||||||
abstract class ShippingRepo {
|
|
||||||
Future<List<ShippingRequestModel>> getSelfPickupRequestListByStatus({SelfPickupRequestStatusEnum? selfPickupRequestStatus, int? requestId});
|
|
||||||
|
|
||||||
Future<List<ShippingRequestModel>> getShippingRequestListByStatus({ShippingRequestStatusEnum? shippingStatusEnum, int? requestId});
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateShippingRequestStatus({required ShippingRequestStatusEnum shippingStatusEnum, required int shippingRequestId, String? comment});
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateSelfPickupRequestStatus({required SelfPickupRequestStatusEnum selfPickupStatusEnum, required int shippingRequestId, String? comment});
|
|
||||||
}
|
|
||||||
|
|
||||||
class ShippingRepoImp extends ShippingRepo {
|
|
||||||
ApiClient apiClient = injector.get<ApiClient>();
|
|
||||||
AppState appState = injector.get<AppState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ShippingRequestModel>> getShippingRequestListByStatus({ShippingRequestStatusEnum? shippingStatusEnum, int? requestId}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map queryParameters = {
|
|
||||||
"requestID": "${requestId ?? 0}",
|
|
||||||
"shippingStatus": "${shippingStatusEnum != null ? shippingStatusEnum.getIdFromShippingStatusEnum() : -1}", // -1 to get all requests
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.shippingRequestStatusGet,
|
|
||||||
queryParameters,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ShippingRequestModel> list = List.generate(genericRespModel.data.length, (index) => ShippingRequestModel.fromJsonShipping(genericRespModel.data[index], true));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<ShippingRequestModel>> getSelfPickupRequestListByStatus({SelfPickupRequestStatusEnum? selfPickupRequestStatus, int? requestId}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map queryParameters = {
|
|
||||||
"requestID": "${requestId ?? 0}",
|
|
||||||
"selfPickUpStatus": "${selfPickupRequestStatus != null ? selfPickupRequestStatus.getIdFromSelfPickupStatusEnum() : -1}", // -1 to get all requests
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.selfPickupRequestStatusGet,
|
|
||||||
queryParameters,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ShippingRequestModel> list = List.generate(genericRespModel.data.length, (index) => ShippingRequestModel.fromJsonShipping(genericRespModel.data[index], false));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateShippingRequestStatus({required ShippingRequestStatusEnum shippingStatusEnum, required int shippingRequestId, String? comment}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {
|
|
||||||
"id": "$shippingRequestId",
|
|
||||||
"shippingStatus": "${shippingStatusEnum.getIdFromShippingStatusEnum()}",
|
|
||||||
"comment": comment ?? "",
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.shippingRequestStatusUpdate,
|
|
||||||
queryParameters,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
}
|
|
||||||
|
|
||||||
return genericRespModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> updateSelfPickupRequestStatus({required SelfPickupRequestStatusEnum selfPickupStatusEnum, required int shippingRequestId, String? comment}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {
|
|
||||||
"id": "$shippingRequestId",
|
|
||||||
"selfPickUpStatus": "${selfPickupStatusEnum.getIdFromSelfPickupStatusEnum()}",
|
|
||||||
"comment": comment ?? "",
|
|
||||||
};
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await apiClient.postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.selfPickupRequestStatusUpdate,
|
|
||||||
queryParameters,
|
|
||||||
token: token,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (genericRespModel.messageStatus != 1 || genericRespModel.data == null) {
|
|
||||||
Utils.showToast(genericRespModel.message ?? LocaleKeys.somethingWrong.tr());
|
|
||||||
}
|
|
||||||
|
|
||||||
return genericRespModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,178 +0,0 @@
|
|||||||
import 'package:mc_common_app/api/api_client.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/classes/consts.dart';
|
|
||||||
import 'package:mc_common_app/config/dependency_injection.dart';
|
|
||||||
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
||||||
import 'package:mc_common_app/models/provider_branches_models/branch_detail_model.dart';
|
|
||||||
import 'package:mc_common_app/models/subscriptions_models/branch_user_selection_model.dart';
|
|
||||||
import 'package:mc_common_app/models/subscriptions_models/subscription_model.dart';
|
|
||||||
import 'package:mc_common_app/models/user_models/branch_user.dart';
|
|
||||||
|
|
||||||
abstract class SubscriptionRepo {
|
|
||||||
// Future<SubscriptionModel> getAllSubscriptions(String? serviceProviderID);
|
|
||||||
|
|
||||||
// Future<List<ProviderSubscriptionModel>> getProviderSubscription({String? serviceProviderID});
|
|
||||||
|
|
||||||
Future<SubscriptionModel> getMySubscriptions(String? serviceProviderID);
|
|
||||||
|
|
||||||
Future<SubscriptionModel> getSubscriptionBySP(String? serviceProviderID, bool isRenew);
|
|
||||||
|
|
||||||
Future<GenericRespModel> calculationUpgradePrice(String? serviceProviderID, String? newSubscription);
|
|
||||||
|
|
||||||
Future<GenericRespModel> payForProviderSubscription(Map<String, dynamic> map);
|
|
||||||
|
|
||||||
Future<List<BranchSelectionModel>> getSPBranchUserGet(Map<String, String> map);
|
|
||||||
}
|
|
||||||
|
|
||||||
class SubscriptionRepoImp extends SubscriptionRepo {
|
|
||||||
ApiClient apiClient = injector.get<ApiClient>();
|
|
||||||
AppState appState = injector.get<AppState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<SubscriptionModel> getSubscriptionBySP(String? serviceProviderID, bool isRenew) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, dynamic> queryParameters = {};
|
|
||||||
if (serviceProviderID != null) {
|
|
||||||
queryParameters = {
|
|
||||||
"ProviderID": serviceProviderID,
|
|
||||||
"IsRenew": isRenew.toString(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => SubscriptionModel.fromJson(json),
|
|
||||||
ApiConsts.getSubscriptionBySP,
|
|
||||||
token: t,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> calculationUpgradePrice(String? serviceProviderID, String? newSubscription) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {};
|
|
||||||
if (serviceProviderID != null) {
|
|
||||||
queryParameters = {
|
|
||||||
"ServiceProviderID": serviceProviderID,
|
|
||||||
"NewSubscription": newSubscription!,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.calculationUpgradePrice,
|
|
||||||
token: t,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<GenericRespModel> payForProviderSubscription(Map<String, dynamic> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
return await injector.get<ApiClient>().postJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.payFortOrderProviderSubscriptionCreate,
|
|
||||||
map,
|
|
||||||
token: t,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<BranchSelectionModel>> getSPBranchUserGet(Map<String, String> map) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
|
|
||||||
GenericRespModel genericRespModel = await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.getSPBranchUserGet,
|
|
||||||
token: t,
|
|
||||||
queryParameters: map,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<BranchSelectionModel> branchList = [];
|
|
||||||
|
|
||||||
if (genericRespModel.data != null) {
|
|
||||||
List<BranchDetailModel> branches = [];
|
|
||||||
List<BranchUser> branchUsers = [];
|
|
||||||
|
|
||||||
// List<BranchUsersDatum>.from(json["data"]!.map((x) => BranchUsersDatum.fromJson(x))
|
|
||||||
branches = List<BranchDetailModel>.from(genericRespModel.data["branches"]["data"]!.map((x) => BranchDetailModel.fromJson(x)));
|
|
||||||
branchUsers = List<BranchUser>.from(genericRespModel.data["branchUsers"]["data"]!.map((x) => BranchUser.fromJson(x)));
|
|
||||||
for (int i = 0; i < branches.length; i++) {
|
|
||||||
List<UserSelectionModel> availableUsers = [];
|
|
||||||
for (int j = 0; j < branchUsers.length; j++) {
|
|
||||||
if (branches[i].id == branchUsers[j].serviceProviderBranchID) {
|
|
||||||
availableUsers.add(UserSelectionModel(userId: branchUsers[j].id, userName: ("${branchUsers[j].firstName ?? ""} ${branchUsers[j].lastName}"), isSelected: false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
branchList.add(BranchSelectionModel(branchId: branches[i].id ?? 0, branchName: branches[i].branchName ?? "", isSelected: false, usersList: availableUsers));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return branchList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<SubscriptionModel> getMySubscriptions(String? serviceProviderID) async {
|
|
||||||
String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {};
|
|
||||||
if (serviceProviderID != null) {
|
|
||||||
queryParameters = {
|
|
||||||
"ID": serviceProviderID,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return await injector.get<ApiClient>().getJsonForObject((json) => SubscriptionModel.fromJson(json), ApiConsts.getAllSubscriptions, token: t, queryParameters: queryParameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<SubscriptionModel> getAllSubscriptions(String? serviceProviderID) async {
|
|
||||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
// Map<String, String> queryParameters = {};
|
|
||||||
// if (serviceProviderID != null) {
|
|
||||||
// queryParameters = {
|
|
||||||
// "ID": serviceProviderID,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return await injector.get<ApiClient>().getJsonForObject((json) => SubscriptionModel.fromJson(json), ApiConsts.getAllSubscriptions, token: t, queryParameters: queryParameters);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<List<ProviderSubscriptionModel>> getProviderSubscription({String? serviceProviderID}) async {
|
|
||||||
// Map<String, String> queryParameters = {};
|
|
||||||
// if (serviceProviderID != null) {
|
|
||||||
// queryParameters = {
|
|
||||||
// "ServiceProviderID": serviceProviderID,
|
|
||||||
// "IsActiveSubscriptionForProvider": "true",
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
// token: appState.getUser.data!.accessToken,
|
|
||||||
// (json) => GenericRespModel.fromJson(json),
|
|
||||||
// ApiConsts.getMySubscriptions,
|
|
||||||
// queryParameters: queryParameters,
|
|
||||||
// );
|
|
||||||
// List<ProviderSubscriptionModel> providerSubList = List.generate(adsGenericModel.data.length, (index) => ProviderSubscriptionModel.fromJson(adsGenericModel.data[index]));
|
|
||||||
// return providerSubList;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Future<SubscriptionModel> getProviderSubscription(
|
|
||||||
// String? serviceProviderID) async {
|
|
||||||
// String t = AppState().getUser.data!.accessToken ?? "";
|
|
||||||
// Map<String, String> queryParameters = {};
|
|
||||||
// if (serviceProviderID != null) {
|
|
||||||
// queryParameters = {
|
|
||||||
// "ID": serviceProviderID,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return await injector.get<ApiClient>().getJsonForObject(
|
|
||||||
// (json) => SubscriptionModel.fromJson(json),
|
|
||||||
// ApiConsts.getMySubscriptions,
|
|
||||||
// token: t,
|
|
||||||
// queryParameters: queryParameters);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:local_auth/local_auth.dart';
|
|
||||||
import 'package:local_auth_android/local_auth_android.dart';
|
|
||||||
import 'package:local_auth_darwin/types/auth_messages_ios.dart';
|
|
||||||
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
|
|
||||||
abstract class CommonAuthServices {
|
|
||||||
Future<bool> authenticate();
|
|
||||||
|
|
||||||
Future<List<BiometricType>> getAvailBio();
|
|
||||||
}
|
|
||||||
|
|
||||||
class CommonAuthImp implements CommonAuthServices {
|
|
||||||
final LocalAuthentication localAuth = LocalAuthentication();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool> authenticate() async {
|
|
||||||
try {
|
|
||||||
final availableBiometrics = await localAuth.getAvailableBiometrics();
|
|
||||||
if (availableBiometrics.isEmpty) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final didAuthenticate = await localAuth.authenticate(
|
|
||||||
localizedReason: "Scan your fingerprint or face ID to authenticate",
|
|
||||||
options: const AuthenticationOptions(
|
|
||||||
stickyAuth: false,
|
|
||||||
biometricOnly: true,
|
|
||||||
sensitiveTransaction: true,
|
|
||||||
useErrorDialogs: true,
|
|
||||||
),
|
|
||||||
authMessages: [
|
|
||||||
AndroidAuthMessages(
|
|
||||||
cancelButton: LocaleKeys.cancel.tr(),
|
|
||||||
biometricHint: LocaleKeys.useFingerPrintFaceID.tr(),
|
|
||||||
goToSettingsButton: LocaleKeys.settings.tr(),
|
|
||||||
goToSettingsDescription: LocaleKeys.setupTouchID.tr(),
|
|
||||||
),
|
|
||||||
IOSAuthMessages(
|
|
||||||
cancelButton: LocaleKeys.cancel.tr(),
|
|
||||||
goToSettingsButton: LocaleKeys.settings.tr(),
|
|
||||||
goToSettingsDescription: LocaleKeys.setupTouchID.tr(),
|
|
||||||
lockOut: LocaleKeys.reenableTouchID.tr(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
return didAuthenticate;
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print('Error during authentication: $e');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<BiometricType>> getAvailBio() async {
|
|
||||||
return await localAuth.getAvailableBiometrics();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Future<void> getHuaweiAuth() async {
|
|
||||||
// DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
|
||||||
// AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
|
||||||
// // if (androidInfo.brand == "HUAWEI") {
|
|
||||||
// // huawei.canAuth();
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@ -1,115 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/main.dart';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
abstract class FirebaseMessagingService {
|
|
||||||
Future<String> getFirebaseToken();
|
|
||||||
|
|
||||||
Future<void> initializeNotifications();
|
|
||||||
}
|
|
||||||
|
|
||||||
class FirebaseMessagingServiceImp implements FirebaseMessagingService {
|
|
||||||
final FlutterLocalNotificationsPlugin flutterLocalNotifications;
|
|
||||||
final FirebaseMessaging firebaseMessaging;
|
|
||||||
|
|
||||||
FirebaseMessagingServiceImp({required this.firebaseMessaging, required this.flutterLocalNotifications});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<String> getFirebaseToken() async => await firebaseMessaging.getToken() ?? "";
|
|
||||||
|
|
||||||
Future<void> requestPermissions() async {
|
|
||||||
if (Platform.isIOS) {
|
|
||||||
await flutterLocalNotifications.resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()?.requestPermissions(alert: true, badge: true, sound: true);
|
|
||||||
} else if (Platform.isAndroid) {
|
|
||||||
AndroidFlutterLocalNotificationsPlugin? androidImplementation = flutterLocalNotifications.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();
|
|
||||||
bool? granted = await androidImplementation?.requestNotificationsPermission();
|
|
||||||
if (granted == false) {
|
|
||||||
await Permission.notification.request();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> initializeNotifications() async {
|
|
||||||
await requestPermissions();
|
|
||||||
AppState().setDeviceToken = await getFirebaseToken();
|
|
||||||
AppState().setDeviceType = Platform.isAndroid ? "1" : "2";
|
|
||||||
await Permission.notification.isDenied.then((bool value) {
|
|
||||||
if (value) {
|
|
||||||
Permission.notification.request();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
|
|
||||||
const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('ic_launcher');
|
|
||||||
DarwinInitializationSettings initializationSettingsDarwin = const DarwinInitializationSettings(
|
|
||||||
requestAlertPermission: true,
|
|
||||||
requestBadgePermission: true,
|
|
||||||
requestCriticalPermission: true,
|
|
||||||
requestProvisionalPermission: true,
|
|
||||||
requestSoundPermission: true,
|
|
||||||
defaultPresentAlert: true,
|
|
||||||
defaultPresentBadge: true,
|
|
||||||
defaultPresentBanner: true,
|
|
||||||
defaultPresentList: true,
|
|
||||||
defaultPresentSound: true,
|
|
||||||
);
|
|
||||||
final InitializationSettings initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsDarwin);
|
|
||||||
await flutterLocalNotifications.initialize(initializationSettings, onDidReceiveNotificationResponse: (notificationResponse) {}, );
|
|
||||||
|
|
||||||
RemoteMessage? initialMessage = await FirebaseMessaging.instance.getInitialMessage();
|
|
||||||
|
|
||||||
if (initialMessage != null) _handleNotification(initialMessage);
|
|
||||||
|
|
||||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
|
||||||
if (message.notification != null) _handleNotification(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen(_handleNotification);
|
|
||||||
|
|
||||||
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
|
|
||||||
|
|
||||||
FirebaseMessaging.instance.onTokenRefresh.listen((String token) async {
|
|
||||||
AppState().setDeviceToken = token;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onDidReceiveLocalNotification(int id, String? title, String? body, String? payload) async {
|
|
||||||
logger.i(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleNotification(RemoteMessage message) async {
|
|
||||||
logger.i(message.notification!.title);
|
|
||||||
logger.i(message.notification!.body);
|
|
||||||
|
|
||||||
displayNotification(title: message.notification!.title ?? '', body: message.notification!.body ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> displayNotification({required String title, required String body}) async {
|
|
||||||
const AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails(
|
|
||||||
"0",
|
|
||||||
'mowater',
|
|
||||||
channelDescription: 'mowater_notifications',
|
|
||||||
importance: Importance.max,
|
|
||||||
priority: Priority.high,
|
|
||||||
ticker: 'ticker',
|
|
||||||
);
|
|
||||||
|
|
||||||
const DarwinNotificationDetails iOSPlatformChannelSpecifics = DarwinNotificationDetails(threadIdentifier: 'thread_id');
|
|
||||||
const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails, iOS: iOSPlatformChannelSpecifics);
|
|
||||||
await flutterLocalNotifications.show(0, title, body, notificationDetails, payload: 'item x');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
|
||||||
Future<dynamic> backgroundMessageHandler(RemoteMessage message) async {
|
|
||||||
await Firebase.initializeApp();
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue