Phase 1 API's complition
parent
9591eca23c
commit
1e16bb3635
@ -0,0 +1,42 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "815750722565",
|
||||
"firebase_url": "https://api-project-815750722565.firebaseio.com",
|
||||
"project_id": "api-project-815750722565",
|
||||
"storage_bucket": "api-project-815750722565.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:815750722565:android:62281cd3e5df4063",
|
||||
"android_client_info": {
|
||||
"package_name": "com.ejada.hmg"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "815750722565-3a0gc7neins0eoahdrimrfksk0sqice8.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDUfg6AKM1-00WyzpvLImUBC46wFrq9-qw"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"analytics_service": {
|
||||
"status": 1
|
||||
},
|
||||
"appinvite_service": {
|
||||
"status": 1,
|
||||
"other_platform_oauth_client": []
|
||||
},
|
||||
"ads_service": {
|
||||
"status": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<svg id="Group_768" data-name="Group 768" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
|
||||
<defs>
|
||||
<clipPath id="clip-path">
|
||||
<rect id="Rectangle_1490" data-name="Rectangle 1490" width="16" height="16" fill="#2699fb"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="Group_767" data-name="Group 767" clip-path="url(#clip-path)">
|
||||
<path id="Path_669" data-name="Path 669" d="M18.08,177.688l.127.038v-1.174h-.552v1.136a.711.711,0,0,1,.425,0" transform="translate(-17.103 -171.035)" fill="#2699fb"/>
|
||||
<path id="Path_670" data-name="Path 670" d="M52.966,203.035v.512l.552.166v-.678Z" transform="translate(-51.31 -196.69)" fill="#2699fb"/>
|
||||
<rect id="Rectangle_1487" data-name="Rectangle 1487" width="0.552" height="0.552" transform="translate(6.621 6.621)" fill="#2699fb"/>
|
||||
<rect id="Rectangle_1488" data-name="Rectangle 1488" width="0.552" height="1.103" transform="translate(7.724 6.069)" fill="#2699fb"/>
|
||||
<rect id="Rectangle_1489" data-name="Rectangle 1489" width="0.552" height="0.552" transform="translate(8.828 6.621)" fill="#2699fb"/>
|
||||
<path id="Path_671" data-name="Path 671" d="M477.242,177.689v-1.137h-.552v1.174l.129-.039a.751.751,0,0,1,.214-.031.738.738,0,0,1,.209.033" transform="translate(-461.793 -171.035)" fill="#2699fb"/>
|
||||
<path id="Path_672" data-name="Path 672" d="M441.379,203.035v.678l.552-.166v-.512Z" transform="translate(-427.586 -196.69)" fill="#2699fb"/>
|
||||
<path id="Path_673" data-name="Path 673" d="M196.138,5.076l1.508-1.885a1.937,1.937,0,0,0,.423-1.206V1.931a1.931,1.931,0,0,0-3.862,0v.054a1.939,1.939,0,0,0,.423,1.206Zm0-4.248a1.1,1.1,0,1,1-1.1,1.1,1.1,1.1,0,0,1,1.1-1.1" transform="translate(-188.138)" fill="#2699fb"/>
|
||||
<path id="Path_674" data-name="Path 674" d="M390.345,0a1.933,1.933,0,0,0-1.931,1.931v.054a1.938,1.938,0,0,0,.423,1.206l1.508,1.885,1.508-1.885a1.937,1.937,0,0,0,.423-1.206V1.931A1.933,1.933,0,0,0,390.345,0m0,3.034a1.1,1.1,0,1,1,1.1-1.1,1.1,1.1,0,0,1-1.1,1.1" transform="translate(-376.276)" fill="#2699fb"/>
|
||||
<path id="Path_675" data-name="Path 675" d="M1.931,5.076,3.439,3.191a1.937,1.937,0,0,0,.423-1.206V1.931A1.931,1.931,0,0,0,0,1.931v.054A1.938,1.938,0,0,0,.423,3.191Zm0-4.248a1.1,1.1,0,1,1-1.1,1.1,1.1,1.1,0,0,1,1.1-1.1" fill="#2699fb"/>
|
||||
<path id="Path_676" data-name="Path 676" d="M198.069,248.275v-1.1h-3.862v2.759h3.862Zm-2.759,1.1h-.552v-.552h.552Zm0-1.1h-.552v-.552h.552Zm1.1,1.1h-.552v-.552h.552Zm0-1.1h-.552v-.552h.552Zm1.1,1.1h-.552v-.552h.552Zm0-1.1h-.552v-.552h.552Z" transform="translate(-188.138 -239.448)" fill="#2699fb"/>
|
||||
<path id="Path_677" data-name="Path 677" d="M91.035,282.483H88.276v1.655h2.759Zm-1.655,1.1h-.552v-.552h.552Zm1.1,0h-.552v-.552h.552Z" transform="translate(-85.517 -273.655)" fill="#2699fb"/>
|
||||
<path id="Path_678" data-name="Path 678" d="M338.207,282.483h-2.759v1.655h2.759Zm-1.655,1.1H336v-.552h.552Zm1.1,0H337.1v-.552h.552Z" transform="translate(-324.965 -273.655)" fill="#2699fb"/>
|
||||
<path id="Path_679" data-name="Path 679" d="M406.069,230.445v.194h.552a.552.552,0,0,1,.552.552v1.655h1.655V229.74a.209.209,0,0,0-.264-.2l-2.348.7A.2.2,0,0,0,406.069,230.445Zm1.655.194h.552v.552h-.552Zm0,1.1h.552v.552h-.552Z" transform="translate(-393.379 -222.363)" fill="#2699fb"/>
|
||||
<path id="Path_680" data-name="Path 680" d="M289.492,353.1h-5.907v.276a.276.276,0,0,0,.276.276h2.759a.828.828,0,1,1,0,1.655h-1.655a.276.276,0,0,0-.276.276.829.829,0,0,1-.828.828h-1.1a.276.276,0,1,0,0,.552.829.829,0,0,1,.828.828v.065a9.105,9.105,0,0,0,6.025-4.471l.024-.043a.161.161,0,0,0,.02-.079A.162.162,0,0,0,289.492,353.1Z" transform="translate(-273.654 -342.07)" fill="#2699fb"/>
|
||||
<path id="Path_681" data-name="Path 681" d="M5.793,357.518a.828.828,0,1,1,0-1.655h.552a.276.276,0,1,0,0-.552H3.034a.828.828,0,1,1,0-1.655H4.69a.276.276,0,0,0,.276-.276V353.1H.162a.162.162,0,0,0-.162.162.161.161,0,0,0,.02.079l.024.043a9.105,9.105,0,0,0,6.025,4.471v-.065a.276.276,0,0,0-.276-.276" transform="translate(0 -342.07)" fill="#2699fb"/>
|
||||
<path id="Path_682" data-name="Path 682" d="M17.655,232.84H19.31v-1.655a.552.552,0,0,1,.552-.552h.552v-.194a.2.2,0,0,0-.146-.2l-2.348-.7a.208.208,0,0,0-.264.2Zm.552-2.207h.552v.552h-.552Zm0,1.1h.552v.552h-.552Z" transform="translate(-17.103 -222.357)" fill="#2699fb"/>
|
||||
<path id="Path_683" data-name="Path 683" d="M94.621,357.518a.828.828,0,1,1,0-1.655h1.1a.276.276,0,0,0,.276-.276.829.829,0,0,1,.828-.828h1.655a.276.276,0,1,0,0-.552H95.724a.829.829,0,0,1-.828-.828V353.1H91.035v.276a.829.829,0,0,1-.828.828H88.552a.276.276,0,0,0,0,.552h3.31a.828.828,0,0,1,0,1.655H91.31a.276.276,0,1,0,0,.552.829.829,0,0,1,.828.828v.167a8.783,8.783,0,0,0,2.759,0v-.167a.276.276,0,0,0-.276-.276" transform="translate(-85.517 -342.07)" fill="#2699fb"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,10 @@
|
||||
<svg id="Group_772" data-name="Group 772" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18" height="18" viewBox="0 0 18 18">
|
||||
<defs>
|
||||
<clipPath id="clip-path">
|
||||
<rect id="Rectangle_1492" data-name="Rectangle 1492" width="18" height="18" fill="#2699fb"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="Group_771" data-name="Group 771" clip-path="url(#clip-path)">
|
||||
<path id="Path_688" data-name="Path 688" d="M9,0a9,9,0,1,0,9,9A9,9,0,0,0,9,0m3.471,11.315a.818.818,0,1,1-1.137,1.177l-.02-.02L9,10.156,6.686,12.471a.818.818,0,0,1-1.157-1.157L7.843,9,5.529,6.684A.818.818,0,1,1,6.666,5.507l.02.02L9,7.842l2.314-2.315a.818.818,0,1,1,1.177,1.137l-.02.02L10.157,9Z" transform="translate(0 0.001)" fill="#2699fb"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 760 B |
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14.41" height="19.215" viewBox="0 0 14.41 19.215">
|
||||
<path id="Path_665" data-name="Path 665" d="M12.609,7.806V5.4A5.4,5.4,0,1,0,1.8,5.4v2.4A1.769,1.769,0,0,0,0,9.608v7.806a1.806,1.806,0,0,0,1.8,1.8H12.609a1.806,1.806,0,0,0,1.8-1.8V9.608a1.769,1.769,0,0,0-1.8-1.8M3,5.4a4.2,4.2,0,1,1,8.406,0v2.4H3Zm4.8,8.887v1.321a.6.6,0,1,1-1.2,0V14.292A1.749,1.749,0,0,1,5.4,12.61a1.8,1.8,0,1,1,3.6,0,1.749,1.749,0,0,1-1.2,1.681" fill="#2699fb"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 487 B |
@ -0,0 +1,13 @@
|
||||
<svg id="Group_770" data-name="Group 770" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16.001" viewBox="0 0 16 16.001">
|
||||
<defs>
|
||||
<clipPath id="clip-path">
|
||||
<rect id="Rectangle_1491" data-name="Rectangle 1491" width="16" height="16.001" fill="#2699fb"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="Group_769" data-name="Group 769" clip-path="url(#clip-path)">
|
||||
<path id="Path_684" data-name="Path 684" d="M211.911,0a1.931,1.931,0,0,0-1.906,1.906,1.931,1.931,0,0,0,1.906,1.906,1.907,1.907,0,0,0,0-3.813" transform="translate(-203.442)" fill="#2699fb"/>
|
||||
<path id="Path_685" data-name="Path 685" d="M184.93,122a2.8,2.8,0,0,1-2.081.938,2.864,2.864,0,0,1-2.112-.938,2.791,2.791,0,0,0-.732,1.875v.469a.469.469,0,0,0,.469.469h4.719a.469.469,0,0,0,.469-.469v-.469A2.791,2.791,0,0,0,184.93,122" transform="translate(-174.379 -118.187)" fill="#2699fb"/>
|
||||
<path id="Path_686" data-name="Path 686" d="M4.53,295.841l-2.389-4.79a.938.938,0,0,0-1.255-.422l-.624.309a.469.469,0,0,0-.211.63l2.813,5.626a.469.469,0,0,0,.628.211l.616-.305a.938.938,0,0,0,.423-1.259" transform="translate(0 -281.452)" fill="#2699fb"/>
|
||||
<path id="Path_687" data-name="Path 687" d="M101.828,236.829a.935.935,0,0,0-1.238.122l-2.563,3.15a1.133,1.133,0,0,1-.694.3H95.149a.469.469,0,0,1,0-.938h1.875a.938.938,0,1,0,0-1.875H94.568c-.234,0-.35-.148-.534-.309a3.262,3.262,0,0,0-2.91-.712,3.42,3.42,0,0,0-1.439.719l-.014-.011-.678.6,2.665,5.343h5.368a2.824,2.824,0,0,0,2.25-1.125l2.75-3.938a.945.945,0,0,0-.2-1.322" transform="translate(-86.211 -229.088)" fill="#2699fb"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 675 B |
@ -0,0 +1,69 @@
|
||||
import 'dart:async';
|
||||
import 'package:car_provider_app/classes/app_state.dart';
|
||||
import 'package:car_provider_app/models/m_response.dart';
|
||||
import 'package:car_provider_app/models/profile/branch.dart';
|
||||
import 'package:car_provider_app/models/profile/categroy.dart';
|
||||
import 'package:car_provider_app/models/profile/document.dart';
|
||||
import 'package:car_provider_app/models/profile/services.dart';
|
||||
import 'package:car_provider_app/models/user/country.dart';
|
||||
import 'package:car_provider_app/models/user/role.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:car_provider_app/classes/consts.dart';
|
||||
import 'package:car_provider_app/models/content_info_model.dart';
|
||||
import 'package:car_provider_app/models/member_model.dart';
|
||||
import 'package:car_provider_app/models/surah_model.dart';
|
||||
import 'package:car_provider_app/models/user/basic_otp.dart';
|
||||
import 'package:car_provider_app/models/user/register_user.dart';
|
||||
|
||||
import '../api_client.dart';
|
||||
|
||||
class BranchApiClent {
|
||||
static final BranchApiClent _instance = BranchApiClent._internal();
|
||||
|
||||
BranchApiClent._internal();
|
||||
|
||||
factory BranchApiClent() => _instance;
|
||||
|
||||
Future<MResponse> createBranch(String branchName, String branchDescription, String cityId, String address, String latitude, String longitude) async {
|
||||
var postParams = {
|
||||
// "id": 0,
|
||||
"serviceProviderID": AppState().getUser.data?.userInfo?.providerId ?? "",
|
||||
"branchName": branchName,
|
||||
"branchDescription": branchDescription,
|
||||
"cityID": cityId,
|
||||
"address": address,
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
"isActive": true
|
||||
};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.createProviderBranch, postParams, token: t);
|
||||
}
|
||||
|
||||
Future<Branch> fetchAllBranches() async {
|
||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().getJsonForObject((json) => Branch.fromJson(json), ApiConsts.ServiceProviderBranchGet, queryParameters: postParams, token: t);
|
||||
}
|
||||
|
||||
Future<Category> fetchBranchCategory() async {
|
||||
var postParams = {"ServiceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().getJsonForObject((json) => Category.fromJson(json), ApiConsts.ServiceCategory_Get, queryParameters: postParams, token: t);
|
||||
}
|
||||
|
||||
Future<Services> fetchServices(String serviceCategoryId) async {
|
||||
var postParams = {"ServiceCategoryID": serviceCategoryId};
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
print("tokeen " + t);
|
||||
return await ApiClient().getJsonForObject((json) => Services.fromJson(json), ApiConsts.Services_Get, queryParameters: postParams, token: t);
|
||||
}
|
||||
|
||||
Future<MResponse> createService(List<Map<String, dynamic>> map) async {
|
||||
String t = AppState().getUser.data!.accessToken ?? "";
|
||||
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ServiceProviderService_Create, map, token: t);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
// 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,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory MResponse.fromJson(Map<String, dynamic> json) => MResponse(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final branch = branchFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Branch branchFromJson(String str) => Branch.fromJson(json.decode(str));
|
||||
|
||||
String branchToJson(Branch data) => json.encode(data.toJson());
|
||||
|
||||
class Branch {
|
||||
Branch({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<BranchData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Branch.fromJson(Map<String, dynamic> json) => Branch(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<BranchData>.from(json["data"].map((x) => BranchData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class BranchData {
|
||||
BranchData({
|
||||
this.id,
|
||||
this.serviceProviderId,
|
||||
this.branchName,
|
||||
this.branchDescription,
|
||||
this.cityId,
|
||||
this.address,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.status,
|
||||
});
|
||||
|
||||
int? id;
|
||||
int? serviceProviderId;
|
||||
String? branchName;
|
||||
String? branchDescription;
|
||||
int? cityId;
|
||||
String? address;
|
||||
String? latitude;
|
||||
String? longitude;
|
||||
int? status;
|
||||
|
||||
factory BranchData.fromJson(Map<String, dynamic> json) => BranchData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"],
|
||||
branchName: json["branchName"] == null ? null : json["branchName"],
|
||||
branchDescription: json["branchDescription"] == null ? null : json["branchDescription"],
|
||||
cityId: json["cityID"] == null ? null : json["cityID"],
|
||||
address: json["address"] == null ? null : json["address"],
|
||||
latitude: json["latitude"] == null ? null : json["latitude"],
|
||||
longitude: json["longitude"] == null ? null : json["longitude"],
|
||||
status: json["status"] == null ? null : json["status"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"serviceProviderID": serviceProviderId == null ? null : serviceProviderId,
|
||||
"branchName": branchName == null ? null : branchName,
|
||||
"branchDescription": branchDescription == null ? null : branchDescription,
|
||||
"cityID": cityId == null ? null : cityId,
|
||||
"address": address == null ? null : address,
|
||||
"latitude": latitude == null ? null : latitude,
|
||||
"longitude": longitude == null ? null : longitude,
|
||||
"status": status == null ? null : status,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final category = categoryFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Category categoryFromJson(String str) => Category.fromJson(json.decode(str));
|
||||
|
||||
String categoryToJson(Category data) => json.encode(data.toJson());
|
||||
|
||||
class Category {
|
||||
Category({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<CategoryData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Category.fromJson(Map<String, dynamic> json) => Category(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<CategoryData>.from(json["data"].map((x) => CategoryData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class CategoryData {
|
||||
CategoryData({
|
||||
this.id,
|
||||
this.categoryName,
|
||||
this.categoryNameN,
|
||||
this.serviceCategoryIconUrl,
|
||||
this.serviceCategoryImageUrl,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? categoryName;
|
||||
String? categoryNameN;
|
||||
dynamic? serviceCategoryIconUrl;
|
||||
dynamic? serviceCategoryImageUrl;
|
||||
|
||||
factory CategoryData.fromJson(Map<String, dynamic> json) => CategoryData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
categoryName: json["categoryName"] == null ? null : json["categoryName"],
|
||||
categoryNameN: json["categoryNameN"] == null ? null : json["categoryNameN"],
|
||||
serviceCategoryIconUrl: json["serviceCategoryIconUrl"],
|
||||
serviceCategoryImageUrl: json["serviceCategoryImageUrl"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"categoryName": categoryName == null ? null : categoryName,
|
||||
"categoryNameN": categoryNameN == null ? null : categoryNameN,
|
||||
"serviceCategoryIconUrl": serviceCategoryIconUrl,
|
||||
"serviceCategoryImageUrl": serviceCategoryImageUrl,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final services = servicesFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Services servicesFromJson(String str) => Services.fromJson(json.decode(str));
|
||||
|
||||
String servicesToJson(Services data) => json.encode(data.toJson());
|
||||
|
||||
class Services {
|
||||
Services({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<ServicesData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Services.fromJson(Map<String, dynamic> json) => Services(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<ServicesData>.from(json["data"].map((x) => ServicesData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class ServicesData {
|
||||
ServicesData({
|
||||
this.id,
|
||||
this.description,
|
||||
this.descriptionN,
|
||||
this.serviceIconUrl,
|
||||
this.serviceImageUrl,
|
||||
this.serviceCategoryId,
|
||||
this.categoryName,
|
||||
this.isSelected,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? description;
|
||||
String? descriptionN;
|
||||
dynamic? serviceIconUrl;
|
||||
dynamic? serviceImageUrl;
|
||||
int? serviceCategoryId;
|
||||
dynamic? categoryName;
|
||||
bool? isSelected;
|
||||
|
||||
factory ServicesData.fromJson(Map<String, dynamic> json) => ServicesData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
description: json["description"] == null ? null : json["description"],
|
||||
descriptionN: json["descriptionN"] == null ? null : json["descriptionN"],
|
||||
serviceIconUrl: json["serviceIconUrl"],
|
||||
serviceImageUrl: json["serviceImageUrl"],
|
||||
serviceCategoryId: json["serviceCategoryID"] == null ? null : json["serviceCategoryID"],
|
||||
categoryName: json["categoryName"],
|
||||
isSelected: false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"description": description == null ? null : description,
|
||||
"descriptionN": descriptionN == null ? null : descriptionN,
|
||||
"serviceIconUrl": serviceIconUrl,
|
||||
"serviceImageUrl": serviceImageUrl,
|
||||
"serviceCategoryID": serviceCategoryId == null ? null : serviceCategoryId,
|
||||
"categoryName": categoryName,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final cities = citiesFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Cities citiesFromJson(String str) => Cities.fromJson(json.decode(str));
|
||||
|
||||
String citiesToJson(Cities data) => json.encode(data.toJson());
|
||||
|
||||
class Cities {
|
||||
Cities({
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.messageStatus,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? totalItemsCount;
|
||||
List<CityData>? data;
|
||||
int? messageStatus;
|
||||
String? message;
|
||||
|
||||
factory Cities.fromJson(Map<String, dynamic> json) => Cities(
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : List<CityData>.from(json["data"].map((x) => CityData.fromJson(x))),
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class CityData {
|
||||
CityData({
|
||||
this.id,
|
||||
this.cityName,
|
||||
this.cityNameN,
|
||||
this.countryId,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? cityName;
|
||||
String? cityNameN;
|
||||
int? countryId;
|
||||
|
||||
factory CityData.fromJson(Map<String, dynamic> json) => CityData(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
cityName: json["cityName"] == null ? null : json["cityName"],
|
||||
cityNameN: json["cityNameN"] == null ? null : json["cityNameN"],
|
||||
countryId: json["countryID"] == null ? null : json["countryID"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"cityName": cityName == null ? null : cityName,
|
||||
"cityNameN": cityNameN == null ? null : cityNameN,
|
||||
"countryID": countryId == null ? null : countryId,
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
class AppMap extends StatefulWidget {
|
||||
final CameraPositionCallback onCameraMove;
|
||||
Map initialCamera;
|
||||
|
||||
late AppMapState _state;
|
||||
final Function onMapCreated;
|
||||
|
||||
AppMap(this.initialCamera, {required this.onCameraMove, required this.onMapCreated});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _state = AppMapState();
|
||||
|
||||
moveTo({required CameraPosition cameraPostion}) {
|
||||
_state.googleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPostion));
|
||||
}
|
||||
}
|
||||
|
||||
class AppMapState extends State<AppMap> {
|
||||
bool isHuawei = false;
|
||||
|
||||
Completer<GoogleMapController> _googleMapControllerComp = Completer();
|
||||
late GoogleMapController googleMapController;
|
||||
|
||||
checkIsHuawei() async {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isHuawei == null) return CircularProgressIndicator();
|
||||
return googleMap();
|
||||
}
|
||||
|
||||
Widget googleMap() {
|
||||
return GoogleMap(
|
||||
mapType: MapType.normal,
|
||||
zoomControlsEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
myLocationEnabled: true,
|
||||
initialCameraPosition: CameraPosition.fromMap(widget.initialCamera) ?? CameraPosition(target: LatLng(-26.1711459, 27.9002758), zoom: 2.0),
|
||||
onCameraMove: widget.onCameraMove,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
googleMapController = controller;
|
||||
_googleMapControllerComp.complete(controller);
|
||||
widget.onMapCreated();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:car_provider_app/utils/navigator.dart';
|
||||
import 'package:car_provider_app/widgets/show_fill_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import 'map_selection_widget.dart';
|
||||
|
||||
class PickLocationPage extends StatefulWidget {
|
||||
Function(double, double, String) onPickAddress;
|
||||
|
||||
PickLocationPage({required this.onPickAddress});
|
||||
|
||||
@override
|
||||
State<PickLocationPage> createState() => _PickLocationPageState();
|
||||
}
|
||||
|
||||
class _PickLocationPageState extends State<PickLocationPage> {
|
||||
double latitude = 0;
|
||||
double longitude = 0;
|
||||
|
||||
final Set<Marker> markers = new Set();
|
||||
late AppMap appMap;
|
||||
|
||||
static CameraPosition _kGooglePlex = CameraPosition(
|
||||
target: LatLng(37.42796133580664, -122.085749655962),
|
||||
zoom: 14.4746,
|
||||
);
|
||||
late LatLng currentPostion;
|
||||
Completer<GoogleMapController> mapController = Completer();
|
||||
final ValueNotifier<String> _counter = ValueNotifier<String>("");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
appMap = AppMap(
|
||||
_kGooglePlex.toMap() as Map,
|
||||
onCameraMove: (camera) {
|
||||
_updatePosition(camera);
|
||||
},
|
||||
onMapCreated: () {
|
||||
// goToCurrentLocation();
|
||||
_getUserLocation();
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Pick Location"),
|
||||
),
|
||||
body: Container(
|
||||
child: Stack(
|
||||
children: [
|
||||
if (appMap != null) appMap,
|
||||
ValueListenableBuilder<String>(
|
||||
builder: (BuildContext context, String value, Widget? child) {
|
||||
// This builder will only get called when the _counter
|
||||
// is updated.
|
||||
return value.isNotEmpty
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
margin: EdgeInsets.all(12),
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Text(value ?? ""),
|
||||
)),
|
||||
)
|
||||
: Container();
|
||||
},
|
||||
valueListenable: _counter,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Icon(
|
||||
Icons.place,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShowFillButton(
|
||||
title: "Pick Address",
|
||||
onPressed: () {
|
||||
widget.onPickAddress(latitude, longitude, _counter.value);
|
||||
pop(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _updatePosition(CameraPosition _position) async {
|
||||
latitude = _position.target.latitude;
|
||||
longitude = _position.target.longitude;
|
||||
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
|
||||
_counter.value = (placemarks.first.name) ?? "" + " " + (placemarks.first.street ?? "") + " " + (placemarks.first.country ?? "");
|
||||
}
|
||||
|
||||
void _getUserLocation() async {
|
||||
if (await Permission.location.request().isGranted) {
|
||||
var position = await GeolocatorPlatform.instance.getCurrentPosition();
|
||||
currentPostion = LatLng(position.latitude, position.longitude);
|
||||
latitude = position.latitude;
|
||||
longitude = position.longitude;
|
||||
setMap();
|
||||
} else {
|
||||
requestPermissions().then(
|
||||
(value) async {
|
||||
if (value[Permission.location]!.isGranted) {
|
||||
var position = await GeolocatorPlatform.instance.getCurrentPosition();
|
||||
currentPostion = LatLng(position.latitude, position.longitude);
|
||||
latitude = position.latitude;
|
||||
longitude = position.longitude;
|
||||
setMap();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setMap() {
|
||||
setState(() {
|
||||
_kGooglePlex = CameraPosition(
|
||||
target: currentPostion,
|
||||
zoom: 14.4746,
|
||||
);
|
||||
appMap.moveTo(cameraPostion: _kGooglePlex);
|
||||
});
|
||||
}
|
||||
|
||||
Future<String> getCurrentAddress() async {
|
||||
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
|
||||
return placemarks.first.name ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<Permission, PermissionStatus>> requestPermissions() async {
|
||||
var permissionResults = [Permission.calendar].request();
|
||||
return permissionResults;
|
||||
}
|
||||
@ -0,0 +1,185 @@
|
||||
import 'package:car_provider_app/api/client/branch_api_client.dart';
|
||||
import 'package:car_provider_app/classes/utils.dart';
|
||||
import 'package:car_provider_app/models/m_response.dart';
|
||||
import 'package:car_provider_app/models/profile/branch.dart';
|
||||
import 'package:car_provider_app/models/profile/categroy.dart';
|
||||
import 'package:car_provider_app/models/profile/services.dart';
|
||||
import 'package:car_provider_app/models/user/country.dart';
|
||||
import 'package:car_provider_app/widgets/dropdown/dropdow_field.dart';
|
||||
import 'package:car_provider_app/widgets/show_fill_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:car_provider_app/extensions/int_extensions.dart';
|
||||
import 'package:car_provider_app/extensions/string_extensions.dart';
|
||||
|
||||
class CreateServicesPage extends StatefulWidget {
|
||||
@override
|
||||
State<CreateServicesPage> createState() => _CreateServicesPageState();
|
||||
}
|
||||
|
||||
class _CreateServicesPageState extends State<CreateServicesPage> {
|
||||
String? branchName;
|
||||
int categoryId = -1, branchId = -1;
|
||||
|
||||
List<DropValue> countryDropList = [];
|
||||
List<DropValue> categoryDropList = [];
|
||||
|
||||
Branch? branch;
|
||||
Category? category;
|
||||
Services? services;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
fetchBranches();
|
||||
}
|
||||
|
||||
fetchBranches() async {
|
||||
branch = await BranchApiClent().fetchAllBranches();
|
||||
setState(() {
|
||||
branch!.data?.forEach((element) {
|
||||
countryDropList.add(new DropValue(element.id ?? 0, ((element.branchName!.isEmpty ? "N/A" : element.branchName) ?? "N/A"), ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fetchBrancheCategory() async {
|
||||
category = await BranchApiClent().fetchBranchCategory();
|
||||
setState(() {
|
||||
category!.data?.forEach((element) {
|
||||
categoryDropList.add(new DropValue(element.id ?? 0, ((element.categoryName!.isEmpty ? "N/A" : element.categoryName) ?? "N/A"), ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fetchServices() async {
|
||||
services = await BranchApiClent().fetchServices(categoryId.toString());
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Define Services"),
|
||||
),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
branch != null
|
||||
? DropdownField((DropValue value) {
|
||||
setState(() {
|
||||
// countryCode = value.subValue;
|
||||
// countryId = value.id;
|
||||
// fetchCites();
|
||||
branchId = value.id;
|
||||
fetchBrancheCategory();
|
||||
});
|
||||
}, list: countryDropList, hint: "Select Branch")
|
||||
: CircularProgressIndicator(),
|
||||
12.height,
|
||||
(category != null)
|
||||
? DropdownField((DropValue value) {
|
||||
setState(() {
|
||||
// countryCode = value.subValue;
|
||||
// countryId = value.id;
|
||||
// fetchCites();
|
||||
categoryId = value.id;
|
||||
fetchServices();
|
||||
});
|
||||
}, list: categoryDropList, hint: "Select Service Category")
|
||||
: branchId == -1
|
||||
? Container()
|
||||
: CircularProgressIndicator(),
|
||||
12.height,
|
||||
if (services != null)
|
||||
ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: services!.data![index].isSelected,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
services!.data![index].isSelected = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
12.width,
|
||||
(services!.data![index].description ?? "").toText12()
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return 1.height;
|
||||
},
|
||||
itemCount: services!.data!.length,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (checkServicesSelection())
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShowFillButton(
|
||||
title: "Save",
|
||||
width: double.infinity,
|
||||
onPressed: () {
|
||||
createService();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool checkServicesSelection() {
|
||||
bool isServiceSelected = false;
|
||||
try {
|
||||
services!.data!.forEach((element) {
|
||||
if (element.isSelected ?? false) isServiceSelected = true;
|
||||
});
|
||||
} catch (e) {
|
||||
isServiceSelected = false;
|
||||
}
|
||||
|
||||
return isServiceSelected;
|
||||
}
|
||||
|
||||
createService() async {
|
||||
List<Map<String, dynamic>> map = [];
|
||||
for (int i = 0; i < services!.data!.length; i++) {
|
||||
if (services!.data![i].isSelected ?? false) {
|
||||
var postParams = {
|
||||
// "id": services!.data![i].id,
|
||||
"providerBranchID": branchId,
|
||||
"serviceID": services!.data![i].id,
|
||||
"isAllowAppointment": true,
|
||||
"isActive": true
|
||||
};
|
||||
map.add(postParams);
|
||||
}
|
||||
}
|
||||
Utils.showLoading(context);
|
||||
MResponse mResponse = await BranchApiClent().createService(map);
|
||||
Utils.hideLoading(context);
|
||||
Utils.showToast(mResponse.message ?? "");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
import 'package:car_provider_app/config/routes.dart';
|
||||
import 'package:car_provider_app/extensions/string_extensions.dart';
|
||||
import 'package:car_provider_app/utils/navigator.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class DealershipPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Dealership Setting"),
|
||||
),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: SvgPicture.asset("assets/icons/ic_settings.svg"),
|
||||
title: "General".toText12(),
|
||||
),
|
||||
ListTile(
|
||||
leading: SvgPicture.asset("assets/icons/ic_branchs.svg"),
|
||||
title: "Define Branches".toText12(),
|
||||
onTap: () {
|
||||
navigateWithName(context, AppRoutes.defineBranch);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: SvgPicture.asset("assets/icons/ic_services.svg"),
|
||||
title: "Define Services".toText12(),
|
||||
onTap: () {
|
||||
navigateWithName(context, AppRoutes.createServices);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: SvgPicture.asset("assets/icons/ic_provider.svg"),
|
||||
title: "Define Providers".toText12(),
|
||||
),
|
||||
ListTile(
|
||||
leading: SvgPicture.asset("assets/icons/ic_close_account.svg"),
|
||||
title: "Close Account".toText12(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,163 @@
|
||||
import 'package:car_provider_app/api/client/branch_api_client.dart';
|
||||
import 'package:car_provider_app/api/client/user_api_client.dart';
|
||||
import 'package:car_provider_app/classes/utils.dart';
|
||||
import 'package:car_provider_app/extensions/int_extensions.dart';
|
||||
import 'package:car_provider_app/models/m_response.dart';
|
||||
import 'package:car_provider_app/models/user/cities.dart';
|
||||
import 'package:car_provider_app/models/user/country.dart';
|
||||
import 'package:car_provider_app/pages/location/pick_location_page.dart';
|
||||
import 'package:car_provider_app/utils/utils.dart';
|
||||
import 'package:car_provider_app/widgets/dropdown/dropdow_field.dart';
|
||||
import 'package:car_provider_app/widgets/show_fill_button.dart';
|
||||
import 'package:car_provider_app/widgets/txt_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DefineBranchPage extends StatefulWidget {
|
||||
@override
|
||||
State<DefineBranchPage> createState() => _DefineBranchPageState();
|
||||
}
|
||||
|
||||
class _DefineBranchPageState extends State<DefineBranchPage> {
|
||||
String countryCode = "", address = "", branchName = "", branchDescription = "";
|
||||
double latitude = 0, longitude = 0;
|
||||
int role = -1, countryId = -1, cityId = -1;
|
||||
|
||||
List<DropValue> countryDropList = [];
|
||||
List<DropValue> citiesDropList = [];
|
||||
|
||||
Country? country;
|
||||
Cities? cities;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
fetchCountry();
|
||||
}
|
||||
|
||||
fetchCountry() async {
|
||||
country = await UserApiClent().getAllCountries();
|
||||
setState(() {
|
||||
country!.data?.forEach((element) {
|
||||
countryDropList.add(new DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fetchCites() async {
|
||||
cities = await UserApiClent().getAllCites(countryId.toString());
|
||||
setState(() {
|
||||
cities!.data?.forEach((element) {
|
||||
citiesDropList.add(new DropValue(element.id ?? 0, (element.cityName ?? ""), element.id.toString() ?? ""));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"Define Branch",
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
children: [
|
||||
country != null
|
||||
? DropdownField((DropValue value) {
|
||||
setState(() {
|
||||
countryCode = value.subValue;
|
||||
countryId = value.id;
|
||||
fetchCites();
|
||||
});
|
||||
}, list: countryDropList, hint: "Chosse Country")
|
||||
: CircularProgressIndicator(),
|
||||
12.height,
|
||||
if (countryId != -1)
|
||||
cities != null
|
||||
? DropdownField((DropValue value) {
|
||||
setState(() {
|
||||
// countryCode = value.subValue;
|
||||
cityId = value.id;
|
||||
});
|
||||
}, list: citiesDropList, hint: "Chosse City")
|
||||
: CircularProgressIndicator(),
|
||||
12.height,
|
||||
if (cityId != -1)
|
||||
Column(
|
||||
children: [
|
||||
TxtField(
|
||||
hint: "Branch Name",
|
||||
value: branchName,
|
||||
onChanged: (v) {
|
||||
branchName = v;
|
||||
},
|
||||
),
|
||||
12.height,
|
||||
TxtField(
|
||||
hint: "Branch Description",
|
||||
value: branchDescription,
|
||||
onChanged: (v) {
|
||||
branchDescription = v;
|
||||
},
|
||||
),
|
||||
12.height,
|
||||
TxtField(
|
||||
hint: "Address",
|
||||
isNeedClickAll: true,
|
||||
maxLines: 5,
|
||||
value: address,
|
||||
// onChanged: (v) {},
|
||||
),
|
||||
12.height,
|
||||
ShowFillButton(
|
||||
title: "Pick Address",
|
||||
onPressed: () {
|
||||
navigateTo(
|
||||
context,
|
||||
PickLocationPage(
|
||||
onPickAddress: (double latitude, double longitude, String address) {
|
||||
setState(() {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.address = address;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShowFillButton(
|
||||
title: "Create Branch",
|
||||
onPressed: () async {
|
||||
Utils.showLoading(context);
|
||||
MResponse res = await BranchApiClent().createBranch(branchName, branchDescription, cityId.toString(), address, latitude.toString(), longitude.toString());
|
||||
Utils.hideLoading(context);
|
||||
Utils.showToast(res.message ?? "");
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue