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.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
description: This file stores settings for Dart & Flutter DevTools.
|
|
||||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
|
||||||
extensions:
|
|
||||||
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,39 +0,0 @@
|
|||||||
class FAQsModel {
|
|
||||||
int? id;
|
|
||||||
String? question;
|
|
||||||
String? answer;
|
|
||||||
int? sequenceNo;
|
|
||||||
bool? isActive;
|
|
||||||
int? channel;
|
|
||||||
bool? isCollapsed;
|
|
||||||
String? questionN;
|
|
||||||
String? answerN;
|
|
||||||
|
|
||||||
FAQsModel({this.id, this.question, this.answer, this.sequenceNo, this.isActive, this.channel, this.isCollapsed,
|
|
||||||
this.questionN, this.answerN, });
|
|
||||||
|
|
||||||
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;
|
|
||||||
questionN = json['questionN'];
|
|
||||||
answerN = json['answerN'];
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
data['questionN'] = questionN;
|
|
||||||
data['answerN'] = answerN;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,86 +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;
|
|
||||||
String? numberOfShipping;
|
|
||||||
|
|
||||||
ShippingRequestModel({
|
|
||||||
this.id,
|
|
||||||
this.requestID,
|
|
||||||
this.request,
|
|
||||||
this.pickupOrshippingStatus,
|
|
||||||
this.deliveredorCollectedOn,
|
|
||||||
this.comment,
|
|
||||||
this.createdOn,
|
|
||||||
this.customerID,
|
|
||||||
this.customerName,
|
|
||||||
this.vehicleTypeID,
|
|
||||||
this.vehicleType,
|
|
||||||
this.numberOfShipping,
|
|
||||||
});
|
|
||||||
|
|
||||||
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'];
|
|
||||||
numberOfShipping = json['numberOfShipping'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,655 +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);
|
|
||||||
print("branchesAndServices response ===== ${adsGenericModel.data}");
|
|
||||||
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};
|
|
||||||
|
|
||||||
if (!appState.getIsViewOnly) {
|
|
||||||
parameters["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(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!appState.getIsViewOnly) {
|
|
||||||
parameters["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 = <String, dynamic>{};
|
|
||||||
|
|
||||||
if (!appState.getIsViewOnly) {
|
|
||||||
postParams["customerID"] = customerID.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
GenericRespModel adsGenericModel = await apiClient.getJsonForObject(
|
|
||||||
(json) => GenericRespModel.fromJson(json),
|
|
||||||
ApiConsts.favouriteServiceProviderGet,
|
|
||||||
token: appState.getUser.data!.accessToken,
|
|
||||||
queryParameters: postParams.isNotEmpty ? postParams : null,
|
|
||||||
);
|
|
||||||
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,220 +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) {
|
|
||||||
if (!appState.getIsViewOnly) {
|
|
||||||
params.addAll({
|
|
||||||
"customerID": (appState.getUser.data!.userInfo!.customerId ?? "0").toString(),
|
|
||||||
"channelID": "3",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
params.addAll({
|
|
||||||
"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,127 +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, String? numberOfShipping});
|
|
||||||
|
|
||||||
Future<GenericRespModel> updateSelfPickupRequestStatus({required SelfPickupRequestStatusEnum selfPickupStatusEnum, required int shippingRequestId, String? comment, String? numberOfShipping});
|
|
||||||
}
|
|
||||||
|
|
||||||
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, String? numberOfShipping}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {
|
|
||||||
"id": "$shippingRequestId",
|
|
||||||
"shippingStatus": "${shippingStatusEnum.getIdFromShippingStatusEnum()}",
|
|
||||||
"comment": comment ?? "",
|
|
||||||
"numberOfShipping": numberOfShipping ?? "",
|
|
||||||
};
|
|
||||||
|
|
||||||
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, String? numberOfShipping}) async {
|
|
||||||
String token = appState.getUser.data!.accessToken ?? "";
|
|
||||||
Map<String, String> queryParameters = {
|
|
||||||
"id": "$shippingRequestId",
|
|
||||||
"selfPickUpStatus": "${selfPickupStatusEnum.getIdFromSelfPickupStatusEnum()}",
|
|
||||||
"comment": comment ?? "",
|
|
||||||
"numberOfShipping": numberOfShipping ?? "",
|
|
||||||
};
|
|
||||||
|
|
||||||
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,206 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:app_links/app_links.dart';
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:mc_common_app/config/routes.dart';
|
|
||||||
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
||||||
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
|
|
||||||
import 'package:mc_common_app/utils/utils.dart';
|
|
||||||
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
/// Handles opening the ad detail screen directly when the app is launched or
|
|
||||||
/// resumed via a shared ad link, for Android App Links / iOS Universal Links
|
|
||||||
/// (https://ms.hmg.com/ad/1541) AND the custom-scheme fallback used by that
|
|
||||||
/// same web page when App Links verification isn't active
|
|
||||||
/// (mowatercustomer://ad/1541, mowaterprovider://ad/1541).
|
|
||||||
class AdDeepLinkService {
|
|
||||||
static final AppLinks _appLinks = AppLinks();
|
|
||||||
static StreamSubscription<Uri>? _subscription;
|
|
||||||
static Uri? _lastHandledUri;
|
|
||||||
|
|
||||||
// Route name given to the inert, self-removing placeholder pushed from main.dart's
|
|
||||||
// onUnknownRoute for Android's native deep-link route forwarding (see that file for
|
|
||||||
// why it exists). It's pushed and removed again within a frame, so the route-settle
|
|
||||||
// polling below must ignore it rather than treat its brief presence/absence as a real
|
|
||||||
// navigation change -- otherwise the route name never reads as "stable" and _openAd
|
|
||||||
// gives up without ever opening the ad.
|
|
||||||
static const String ignoredPlaceholderRouteName = '__ad_deep_link_ignore__';
|
|
||||||
|
|
||||||
static String? _currentTopRouteName;
|
|
||||||
|
|
||||||
/// Register via MaterialApp(navigatorObservers: [AdDeepLinkService.routeObserver]).
|
|
||||||
/// This is the only reliable way to know the current top route name from here --
|
|
||||||
/// confirmed on a real device: ModalRoute.of(navigatorKey.currentContext) does NOT
|
|
||||||
/// work for this. navigatorKey.currentContext is the Navigator widget's OWN element,
|
|
||||||
/// which sits ABOVE all its routes in the tree, so it has no ModalRoute ancestor and
|
|
||||||
/// that call returns null essentially always. That silently made every route-settle
|
|
||||||
/// poll below read null forever, so _openAd always timed out and gave up without ever
|
|
||||||
/// opening the ad, regardless of login state or what screen was actually showing.
|
|
||||||
static final NavigatorObserver routeObserver = _RouteNameTracker();
|
|
||||||
|
|
||||||
/// Call once, after the app's first frame (so [navigatorKey] is attached to a Navigator).
|
|
||||||
static Future<void> init() async {
|
|
||||||
debugPrint("AdDeepLinkService: init() called");
|
|
||||||
try {
|
|
||||||
final Uri? initialUri = await _appLinks.getInitialLink();
|
|
||||||
debugPrint("AdDeepLinkService: getInitialLink() -> $initialUri");
|
|
||||||
if (initialUri != null) {
|
|
||||||
_handleUri(initialUri);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint("AdDeepLinkService: failed to read initial link - $e");
|
|
||||||
}
|
|
||||||
|
|
||||||
_subscription?.cancel();
|
|
||||||
_subscription = _appLinks.uriLinkStream.listen(
|
|
||||||
(uri) {
|
|
||||||
debugPrint("AdDeepLinkService: uriLinkStream emitted $uri");
|
|
||||||
_handleUri(uri);
|
|
||||||
},
|
|
||||||
onError: (Object e) => debugPrint("AdDeepLinkService: stream error - $e"),
|
|
||||||
);
|
|
||||||
debugPrint("AdDeepLinkService: uriLinkStream subscription active");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _handleUri(Uri uri) {
|
|
||||||
debugPrint("AdDeepLinkService: received $uri");
|
|
||||||
|
|
||||||
// https://ms.hmg.com/ad/1541 -> host="ms.hmg.com", pathSegments=["ad", "1541"]
|
|
||||||
// mowatercustomer://ad/1541 -> host="ad" (Dart treats it as the authority), pathSegments=["1541"]
|
|
||||||
int? adId;
|
|
||||||
if (uri.scheme == 'https') {
|
|
||||||
final segments = uri.pathSegments;
|
|
||||||
if (segments.length >= 2 && segments[0] == 'ad') {
|
|
||||||
adId = int.tryParse(segments[1]);
|
|
||||||
}
|
|
||||||
} else if (uri.host == 'ad' && uri.pathSegments.isNotEmpty) {
|
|
||||||
adId = int.tryParse(uri.pathSegments.first);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adId == null) return;
|
|
||||||
|
|
||||||
// app_links can emit the same initial uri twice (once via getInitialLink, once as
|
|
||||||
// the stream's first event) -- skip the duplicate rather than run _openAd twice.
|
|
||||||
if (uri == _lastHandledUri) {
|
|
||||||
debugPrint("AdDeepLinkService: ignoring duplicate $uri");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_lastHandledUri = uri;
|
|
||||||
_openAd(adId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deliberately no loading dialog anywhere in here: on a cold start (app was killed),
|
|
||||||
// this races the app's own bootstrap navigation -- confirmed on a real device, the
|
|
||||||
// bootstrap chain is SplashPage's hardcoded 5s timer -> pushReplacementNamed to
|
|
||||||
// registerSelection -> (if a saved login exists) a silent auto-login with its own
|
|
||||||
// showLoading/hideLoading dialog -> pushReplacementNamed again towards the dashboard.
|
|
||||||
// Every one of those calls uses a *captured* BuildContext and mutates the same
|
|
||||||
// Navigator via Navigator.of(context), regardless of what else has since been pushed
|
|
||||||
// on top. If we push the ad route while any of that is still in flight, our route gets
|
|
||||||
// clobbered by the next replacement -- in debug this throws "_elements.contains
|
|
||||||
// (element)"; in release (asserts stripped) it silently wedges the Navigator and the
|
|
||||||
// app hangs on a black screen. So: wait for the current route name to stay the same
|
|
||||||
// across two consecutive polls (i.e. bootstrap has actually settled) before touching
|
|
||||||
// the Navigator or fetching anything.
|
|
||||||
static Future<void> _openAd(int adId) async {
|
|
||||||
debugPrint("AdDeepLinkService: _openAd($adId) called");
|
|
||||||
if (!await _waitUntilRouteSettles()) {
|
|
||||||
debugPrint("AdDeepLinkService: app never settled past bootstrap, aborting");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
debugPrint("AdDeepLinkService: route settled at '$_currentTopRouteName'");
|
|
||||||
|
|
||||||
// Checking for a saved token here is NOT a reliable "is the user ready" signal --
|
|
||||||
// confirmed on a real device: a stale token from before the app was killed survives
|
|
||||||
// on disk through the whole re-login flow (splash -> registerSelection -> silent
|
|
||||||
// relogin -> loginMethodSelection OTP screen), so it reads as "already logged in"
|
|
||||||
// while still sitting on the OTP screen, fetches too early with no real session
|
|
||||||
// ready yet, and silently fails. The dashboard route is the one signal that's only
|
|
||||||
// true once a real session is actually in place, however the user got there.
|
|
||||||
if (_currentTopRouteName != AppRoutes.dashboard) {
|
|
||||||
debugPrint("AdDeepLinkService: not on dashboard yet ('$_currentTopRouteName'), waiting for login to finish");
|
|
||||||
if (!await _waitForRoute(AppRoutes.dashboard)) {
|
|
||||||
debugPrint("AdDeepLinkService: gave up waiting for dashboard, aborting");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
debugPrint("AdDeepLinkService: reached dashboard");
|
|
||||||
} else {
|
|
||||||
debugPrint("AdDeepLinkService: already on dashboard, proceeding directly");
|
|
||||||
}
|
|
||||||
|
|
||||||
debugPrint("AdDeepLinkService: fetching ad $adId");
|
|
||||||
AdDetailsModel? adDetails;
|
|
||||||
try {
|
|
||||||
adDetails = await navigatorKey.currentContext?.read<AdVM>().getAdDetailsById(adId);
|
|
||||||
debugPrint("AdDeepLinkService: fetch result adDetails=${adDetails != null ? 'FOUND id=${adDetails.id}' : 'NULL'}");
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint("AdDeepLinkService: failed to fetch ad $adId - $e");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adDetails == null) {
|
|
||||||
Utils.showToast(LocaleKeys.somethingWrong.tr());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Navigate via the NavigatorState directly (not a captured BuildContext) so this
|
|
||||||
// still works even if the route/context active when we started has since changed.
|
|
||||||
debugPrint("AdDeepLinkService: pushing ${AppRoutes.adsDetailView}");
|
|
||||||
navigatorKey.currentState?.pushNamed(AppRoutes.adsDetailView, arguments: adDetails);
|
|
||||||
}
|
|
||||||
|
|
||||||
static String? _currentRouteNameIgnoringPlaceholder() {
|
|
||||||
final name = _currentTopRouteName;
|
|
||||||
// The placeholder pops itself a frame after being pushed -- if this poll happens to
|
|
||||||
// land exactly then, pretend nothing was read rather than counting it as a route.
|
|
||||||
return name == ignoredPlaceholderRouteName ? null : name;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<bool> _waitUntilRouteSettles({int maxAttempts = 60, Duration retryDelay = const Duration(milliseconds: 300)}) async {
|
|
||||||
String? lastRouteName;
|
|
||||||
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
||||||
final currentRouteName = _currentRouteNameIgnoringPlaceholder();
|
|
||||||
|
|
||||||
if (currentRouteName != null && currentRouteName != AppRoutes.splash && currentRouteName == lastRouteName) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (currentRouteName != null) lastRouteName = currentRouteName;
|
|
||||||
if (attempt < maxAttempts) await Future.delayed(retryDelay);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used both for the short "did bootstrap settle" check and for waiting on the
|
|
||||||
// dashboard specifically, which can be user-paced (entering an OTP, picking a login
|
|
||||||
// method) -- default timeout is generous (5 minutes) to cover that case.
|
|
||||||
static Future<bool> _waitForRoute(String targetRoute, {int maxAttempts = 600, Duration retryDelay = const Duration(milliseconds: 500)}) async {
|
|
||||||
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
||||||
if (_currentRouteNameIgnoringPlaceholder() == targetRoute) return true;
|
|
||||||
if (attempt < maxAttempts) await Future.delayed(retryDelay);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RouteNameTracker extends NavigatorObserver {
|
|
||||||
@override
|
|
||||||
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
|
||||||
AdDeepLinkService._currentTopRouteName = route.settings.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
|
||||||
AdDeepLinkService._currentTopRouteName = previousRoute?.settings.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
|
||||||
AdDeepLinkService._currentTopRouteName = previousRoute?.settings.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
|
|
||||||
AdDeepLinkService._currentTopRouteName = newRoute?.settings.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,180 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mc_common_app/classes/app_state.dart';
|
|
||||||
import 'package:mc_common_app/config/routes.dart';
|
|
||||||
import 'package:mc_common_app/models/chat_models/buyers_chat_for_ads_model.dart';
|
|
||||||
import 'package:mc_common_app/models/requests_models/request_model.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
|
||||||
import 'package:mc_common_app/utils/navigator.dart';
|
|
||||||
|
|
||||||
/// Service for handling navigation to different chat types in the app
|
|
||||||
/// Provides centralized navigation logic for Request, Advertisement, and General chats
|
|
||||||
abstract class ChatNavigationService {
|
|
||||||
/// Navigate to Request Offer Chat screen
|
|
||||||
Future<void> navigateToRequestOfferChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required int requestId,
|
|
||||||
required String receiverId,
|
|
||||||
required String senderId,
|
|
||||||
required int requestIndex,
|
|
||||||
required int providerIndex,
|
|
||||||
required RequestModel requestModel,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Navigate to Advertisement Chat screen
|
|
||||||
Future<void> navigateToAdChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required int adsId,
|
|
||||||
required String receiverUserId,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Navigate to General Chat screen
|
|
||||||
Future<void> navigateToGeneralChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required String receiverUserId,
|
|
||||||
Map<String, dynamic>? additionalData,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Navigate to Chat List screen based on chat type
|
|
||||||
Future<void> navigateToChatList({
|
|
||||||
required BuildContext context,
|
|
||||||
required ChatTypeEnum chatType,
|
|
||||||
Map<String, dynamic>? arguments,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChatNavigationServiceImp implements ChatNavigationService {
|
|
||||||
@override
|
|
||||||
Future<void> navigateToRequestOfferChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required int requestId,
|
|
||||||
required String receiverId,
|
|
||||||
required String senderId,
|
|
||||||
required int requestIndex,
|
|
||||||
required int providerIndex,
|
|
||||||
required RequestModel requestModel,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
log("Navigating to Request Offer Chat: requestId=$requestId");
|
|
||||||
|
|
||||||
ChatViewArgumentsForRequest args = ChatViewArgumentsForRequest(
|
|
||||||
chatTypeEnum: ChatTypeEnum.requestOffer,
|
|
||||||
requestId: requestId,
|
|
||||||
receiverId: receiverId,
|
|
||||||
senderId: senderId,
|
|
||||||
requestIndex: requestIndex,
|
|
||||||
providerIndex: providerIndex,
|
|
||||||
requestModel: requestModel,
|
|
||||||
);
|
|
||||||
|
|
||||||
ChatViewArguments chatViewArguments = ChatViewArguments(
|
|
||||||
chatTypeEnum: ChatTypeEnum.requestOffer,
|
|
||||||
chatViewArgumentsForRequest: args,
|
|
||||||
);
|
|
||||||
|
|
||||||
navigateWithName(context, AppRoutes.chatView, arguments: chatViewArguments);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error navigating to request offer chat: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> navigateToAdChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required int adsId,
|
|
||||||
required String receiverUserId,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
log("Navigating to Ad Chat: adsId=$adsId, receiverId=$receiverUserId");
|
|
||||||
|
|
||||||
ChatViewArgumentsForAd args = ChatViewArgumentsForAd(
|
|
||||||
adsID: adsId,
|
|
||||||
receiverUserID: receiverUserId,
|
|
||||||
);
|
|
||||||
|
|
||||||
ChatViewArguments chatViewArguments = ChatViewArguments(
|
|
||||||
chatTypeEnum: ChatTypeEnum.ads,
|
|
||||||
chatViewArgumentsForAd: args,
|
|
||||||
);
|
|
||||||
|
|
||||||
navigateWithName(context, AppRoutes.chatView, arguments: chatViewArguments);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error navigating to ad chat: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> navigateToGeneralChat({
|
|
||||||
required BuildContext context,
|
|
||||||
required String receiverUserId,
|
|
||||||
Map<String, dynamic>? additionalData,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
log("Navigating to General Chat: receiverId=$receiverUserId");
|
|
||||||
|
|
||||||
// General chat implementation
|
|
||||||
// You can extend this based on your general chat requirements
|
|
||||||
ChatViewArguments chatViewArguments = ChatViewArguments(
|
|
||||||
chatTypeEnum: ChatTypeEnum.general,
|
|
||||||
);
|
|
||||||
|
|
||||||
navigateWithName(context, AppRoutes.chatView, arguments: chatViewArguments);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error navigating to general chat: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> navigateToChatList({
|
|
||||||
required BuildContext context,
|
|
||||||
required ChatTypeEnum chatType,
|
|
||||||
Map<String, dynamic>? arguments,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
log("Navigating to Chat List: type=$chatType");
|
|
||||||
|
|
||||||
switch (chatType) {
|
|
||||||
case ChatTypeEnum.requestOffer:
|
|
||||||
// Navigate to Providers Chat List (for customer side)
|
|
||||||
// or Requests list (for provider side)
|
|
||||||
if (AppState().currentAppType == AppType.customer) {
|
|
||||||
navigateWithName(context, AppRoutes.providersChatListPage);
|
|
||||||
} else {
|
|
||||||
// For provider, navigate to requests page
|
|
||||||
navigateWithName(context, AppRoutes.dashboard);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ChatTypeEnum.ads:
|
|
||||||
// Navigate to Ads Buyers Chat List
|
|
||||||
if (arguments != null && arguments['buyers'] != null) {
|
|
||||||
navigateWithName(
|
|
||||||
context,
|
|
||||||
AppRoutes.adsBuyerChatsListView,
|
|
||||||
arguments: arguments['buyers'] as List<BuyersChatForAdsModel>,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Navigate to ads list if buyers not provided
|
|
||||||
navigateWithName(context, AppRoutes.dashboard);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ChatTypeEnum.general:
|
|
||||||
// Navigate to General Chats List
|
|
||||||
if (arguments != null && arguments['requestId'] != null) {
|
|
||||||
navigateWithName(
|
|
||||||
context,
|
|
||||||
AppRoutes.generalChatsListForProvider,
|
|
||||||
arguments: arguments['requestId'] as int,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
navigateWithName(context, AppRoutes.dashboard);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
log("Error navigating to chat list: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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();
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue