Merge branch 'mirza_development' into 'master'
Mirza development See merge request mirza.shafique/car_common_app!2merge-requests/3/merge
commit
5bbceee9da
@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="29.159" height="24.616" viewBox="0 0 29.159 24.616">
|
||||
<g id="promotion" transform="translate(-2 -3.116)">
|
||||
<path id="Path_4626" data-name="Path 4626" d="M26.785,3.408a.292.292,0,0,0-.417-.263L11.455,10.236h.021V20.442h-.021l14.913,7.092a.292.292,0,0,0,.417-.263ZM10.019,20.078V10.6H6.544A4.644,4.644,0,0,0,2,15.339a4.722,4.722,0,0,0,3.191,4.525l2.395,7.663a.292.292,0,0,0,.278.2h3.945a.292.292,0,0,0,.278-.378L9.814,20.078ZM7.728,16.068a.729.729,0,0,0,.729-.729v-.208a.729.729,0,0,0-.729-.729H6.686a.729.729,0,0,0-.729.729v.208a.729.729,0,0,0,.729.729Z" transform="translate(0 0)" fill="#767676" fill-rule="evenodd"/>
|
||||
<path id="Path_4627" data-name="Path 4627" d="M22.29,17.715a5.1,5.1,0,0,0,0-9.224ZM20.832,8.052a5.1,5.1,0,1,0,0,10.1Z" transform="translate(5.953 2.236)" fill="#767676" fill-rule="evenodd"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 878 B |
@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="25.034" height="25.034" viewBox="0 0 25.034 25.034">
|
||||
<g id="weekly-calendar-page-symbol" transform="translate(139)">
|
||||
<path id="Path_4379" data-name="Path 4379" d="M22.53,0H2.5A2.511,2.511,0,0,0,0,2.5V22.53a2.512,2.512,0,0,0,2.5,2.5H22.53a2.512,2.512,0,0,0,2.5-2.5V2.5A2.511,2.511,0,0,0,22.53,0ZM6.756,22.031H2.921V18.62H6.756v3.411Zm0-4.555H2.921v-3.41H6.756v3.41ZM6.467,3.794A1.063,1.063,0,1,1,7.529,2.731,1.062,1.062,0,0,1,6.467,3.794Zm5.406,18.237H8.039V18.62h3.834Zm0-4.555H8.039v-3.41h3.834Zm0-4.552H8.039V9.514h3.834ZM11.455,2.731a1.062,1.062,0,1,1,1.062,1.062A1.062,1.062,0,0,1,11.455,2.731Zm5.54,14.745H13.159v-3.41H17v3.41Zm0-4.552H13.159V9.514H17v3.41ZM17.5,2.731a1.062,1.062,0,1,1,1.062,1.062A1.062,1.062,0,0,1,17.5,2.731Zm4.609,14.745H18.278v-3.41h3.835Zm0-4.552H18.278V9.514h3.835Z" transform="translate(-139)" fill="#767676"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 908 B |
@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="22.851" height="24.894" viewBox="0 0 22.851 24.894">
|
||||
<g id="Layer_2" data-name="Layer 2" transform="translate(-2.981 -2)">
|
||||
<path id="Path_4628" data-name="Path 4628" d="M18.185,17.74a6.372,6.372,0,0,1-7.113,0,6.291,6.291,0,0,1-3.574,1.1A6.111,6.111,0,0,1,5,18.318v7.655A2.675,2.675,0,0,0,7.667,28.64h3.112V23.306a1.778,1.778,0,0,1,1.778-1.778H17a1.778,1.778,0,0,1,1.778,1.778V28.64h3.112a2.675,2.675,0,0,0,2.667-2.667V18.185a6.209,6.209,0,0,1-6.375-.445Z" transform="translate(-0.224 -1.746)" fill="#767676"/>
|
||||
<path id="Path_4629" data-name="Path 4629" d="M13.5,24h4.445v5.334H13.5Z" transform="translate(-1.167 -2.441)" fill="#767676"/>
|
||||
<path id="Path_4630" data-name="Path 4630" d="M9.363,14.8,10.869,2H7.685A2.667,2.667,0,0,0,5.156,3.823L3.234,9.592A4.322,4.322,0,0,0,4.9,14.638a4.543,4.543,0,0,0,4.461.164Z" transform="translate(0 0)" fill="#767676"/>
|
||||
<path id="Path_4631" data-name="Path 4631" d="M27.484,9.592,25.56,3.823A2.667,2.667,0,0,0,23.03,2H20.147l1.526,12.964a4.39,4.39,0,0,0,4.143-.326,4.319,4.319,0,0,0,1.669-5.046Z" transform="translate(-1.904)" fill="#767676"/>
|
||||
<path id="Path_4632" data-name="Path 4632" d="M18.4,14.2A.867.867,0,0,1,18.882,14L17.471,2H13.7L12.282,14.091a.842.842,0,0,1,.188.115A4.559,4.559,0,0,0,18.4,14.2Z" transform="translate(-1.032 0)" fill="#767676"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="28.123" height="26.245" viewBox="0 0 28.123 26.245">
|
||||
<path id="XMLID_219_" d="M28.984,15.637A2.077,2.077,0,0,1,27.025,17h-.716V27.309a.938.938,0,0,1-.937.937H19.748V21.685a4.687,4.687,0,0,0-9.374,0v6.562H4.749a.938.938,0,0,1-.937-.937V17H3.095a2.1,2.1,0,0,1-1.378-3.675L12.665,2.955a3.486,3.486,0,0,1,4.792,0L28.431,13.347A2.066,2.066,0,0,1,28.984,15.637Z" transform="translate(-0.999 -2.001)" fill="#273139"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 467 B |
@ -0,0 +1,5 @@
|
||||
<svg id="interview_5_" data-name="interview (5)" xmlns="http://www.w3.org/2000/svg" width="25.794" height="25.794" viewBox="0 0 25.794 25.794">
|
||||
<path id="Path_4658" data-name="Path 4658" d="M205.7,0h-9.713A3.182,3.182,0,0,0,192.8,3.184v14.57a.756.756,0,0,0,1.209.6l3.036-2.277H205.7a3.182,3.182,0,0,0,3.184-3.184V3.184A3.182,3.182,0,0,0,205.7,0Zm-5.612,12.034h-3.291a.756.756,0,1,1,0-1.511h3.291a.756.756,0,1,1,0,1.511Zm4.8-3.238h-8.094a.756.756,0,1,1,0-1.511h8.094a.756.756,0,0,1,0,1.511Zm0-3.238h-8.094a.756.756,0,1,1,0-1.511h8.094a.756.756,0,0,1,0,1.511Zm0,0" transform="translate(-183.088)" fill="#767676"/>
|
||||
<path id="Path_4659" data-name="Path 4659" d="M31.57,244.561A3.572,3.572,0,1,1,28,240.988,3.572,3.572,0,0,1,31.57,244.561Zm0,0" transform="translate(-23.195 -228.847)" fill="#767676"/>
|
||||
<path id="Path_4660" data-name="Path 4660" d="M4.8,382.8a4.8,4.8,0,0,0-4.8,4.8v.95a.756.756,0,0,0,.756.756H8.85a.756.756,0,0,0,.756-.756v-.95A4.8,4.8,0,0,0,4.8,382.8Zm0,0" transform="translate(0 -363.519)" fill="#767676"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@ -1,10 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension WidgetExtensions on Widget {
|
||||
Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this);
|
||||
|
||||
Widget paddingAll(double _value) => Padding(padding: EdgeInsets.all(_value), child: this);
|
||||
|
||||
Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) =>
|
||||
Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this);
|
||||
}
|
||||
@ -0,0 +1,184 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final branch2 = branch2FromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:mc_common_app/models/profile/categroy.dart';
|
||||
|
||||
|
||||
|
||||
Branch2 branch2FromJson(String str) => Branch2.fromJson(json.decode(str));
|
||||
|
||||
String branch2ToJson(Branch2 data) => json.encode(data.toJson());
|
||||
|
||||
class Branch2 {
|
||||
Branch2({
|
||||
this.messageStatus,
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.message,
|
||||
});
|
||||
|
||||
final int? messageStatus;
|
||||
final int? totalItemsCount;
|
||||
final Data? data;
|
||||
final String? message;
|
||||
|
||||
factory Branch2.fromJson(Map<String, dynamic> json) => Branch2(
|
||||
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
||||
totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"],
|
||||
data: json["data"] == null ? null : Data.fromJson(json["data"]),
|
||||
message: json["message"] == null ? null : json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"messageStatus": messageStatus == null ? null : messageStatus,
|
||||
"totalItemsCount": totalItemsCount == null ? null : totalItemsCount,
|
||||
"data": data == null ? null : data!.toJson(),
|
||||
"message": message == null ? null : message,
|
||||
};
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
this.id,
|
||||
this.companyName,
|
||||
this.countryName,
|
||||
this.companyDescription,
|
||||
this.allDocStatus,
|
||||
this.isValidSubscription,
|
||||
this.userId,
|
||||
this.serviceProviderBranch,
|
||||
this.countryID,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String? companyName;
|
||||
final String? countryName;
|
||||
int? countryID;
|
||||
final String? companyDescription;
|
||||
final int? allDocStatus;
|
||||
final bool? isValidSubscription;
|
||||
final String? userId;
|
||||
final List<ServiceProviderBranch>? serviceProviderBranch;
|
||||
|
||||
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
companyName: json["companyName"] == null ? null : json["companyName"],
|
||||
countryName: json["countryName"] == null ? null : json["countryName"],
|
||||
countryID: json["countryID"] == null ? null : json["countryID"],
|
||||
companyDescription: json["companyDescription"] == null ? null : json["companyDescription"],
|
||||
allDocStatus: json["allDocStatus"] == null ? null : json["allDocStatus"],
|
||||
isValidSubscription: json["isValidSubscription"] == null ? null : json["isValidSubscription"],
|
||||
userId: json["userID"] == null ? null : json["userID"],
|
||||
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<ServiceProviderBranch>.from(json["serviceProviderBranch"].map((x) => ServiceProviderBranch.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"companyName": companyName == null ? null : companyName,
|
||||
"companyDescription": companyDescription == null ? null : companyDescription,
|
||||
"allDocStatus": allDocStatus == null ? null : allDocStatus,
|
||||
"isValidSubscription": isValidSubscription == null ? null : isValidSubscription,
|
||||
"userID": userId == null ? null : userId,
|
||||
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class ServiceProviderBranch {
|
||||
ServiceProviderBranch({
|
||||
this.id,
|
||||
this.cityId,
|
||||
this.cityName,
|
||||
this.branchName,
|
||||
this.branchDescription,
|
||||
this.address,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.status,
|
||||
this.serviceProviderServices,
|
||||
this.countryID,
|
||||
this.countryName,
|
||||
this.categories,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
int? countryID;
|
||||
String? countryName;
|
||||
final int? cityId;
|
||||
final dynamic? cityName;
|
||||
final String? branchName;
|
||||
final String? branchDescription;
|
||||
final String? address;
|
||||
final String? latitude;
|
||||
final String? longitude;
|
||||
final int? status;
|
||||
final List<ServiceProviderService>? serviceProviderServices;
|
||||
List<CategoryData>? categories;
|
||||
|
||||
factory ServiceProviderBranch.fromJson(Map<String, dynamic> json) => ServiceProviderBranch(
|
||||
id: json["id"] == null ? null : json["id"],
|
||||
countryID: 0,
|
||||
countryName: "",
|
||||
cityId: json["cityID"] == null ? null : json["cityID"],
|
||||
cityName: json["cityName"],
|
||||
branchName: json["branchName"] == null ? null : json["branchName"],
|
||||
branchDescription: json["branchDescription"] == null ? null : json["branchDescription"],
|
||||
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"],
|
||||
serviceProviderServices: json["serviceProviderServices"] == null ? null : List<ServiceProviderService>.from(json["serviceProviderServices"].map((x) => ServiceProviderService.fromJson(x))),
|
||||
categories: [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id == null ? null : id,
|
||||
"cityID": cityId == null ? null : cityId,
|
||||
"cityName": cityName,
|
||||
"branchName": branchName == null ? null : branchName,
|
||||
"branchDescription": branchDescription == null ? null : branchDescription,
|
||||
"address": address == null ? null : address,
|
||||
"latitude": latitude == null ? null : latitude,
|
||||
"longitude": longitude == null ? null : longitude,
|
||||
"status": status == null ? null : status,
|
||||
"serviceProviderServices": serviceProviderServices == null ? null : List<dynamic>.from(serviceProviderServices!.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class ServiceProviderService {
|
||||
ServiceProviderService({
|
||||
this.serviceId,
|
||||
this.serviceName,
|
||||
this.serviceNameN,
|
||||
this.categoryId,
|
||||
this.categoryName,
|
||||
this.serviceStatus,
|
||||
});
|
||||
|
||||
final int? serviceId;
|
||||
final String? serviceName;
|
||||
final String? serviceNameN;
|
||||
final int? categoryId;
|
||||
final String? categoryName;
|
||||
final int? serviceStatus;
|
||||
|
||||
factory ServiceProviderService.fromJson(Map<String, dynamic> json) => ServiceProviderService(
|
||||
serviceId: json["serviceID"] == null ? null : json["serviceID"],
|
||||
serviceName: json["serviceName"] == null ? null : json["serviceName"],
|
||||
serviceNameN: json["serviceNameN"] == null ? null : json["serviceNameN"],
|
||||
categoryId: json["categoryID"] == null ? null : json["categoryID"],
|
||||
categoryName: json["categoryName"] == null ? null : json["categoryName"],
|
||||
serviceStatus: json["serviceStatus"] == null ? null : json["serviceStatus"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"serviceID": serviceId == null ? null : serviceId,
|
||||
"serviceName": serviceName == null ? null : serviceName,
|
||||
"serviceNameN": serviceNameN == null ? null : serviceNameN,
|
||||
"categoryID": categoryId == null ? null : categoryId,
|
||||
"categoryName": categoryName == null ? null : categoryName,
|
||||
"serviceStatus": serviceStatus == null ? null : serviceStatus,
|
||||
};
|
||||
}
|
||||
@ -1 +1,35 @@
|
||||
|
||||
import 'package:mc_common_app/api/api_client.dart';
|
||||
import 'package:mc_common_app/classes/consts.dart';
|
||||
import 'package:mc_common_app/config/dependencies.dart';
|
||||
import 'package:mc_common_app/models/user/cities.dart';
|
||||
import 'package:mc_common_app/models/user/country.dart';
|
||||
import 'package:mc_common_app/models/user/role.dart';
|
||||
|
||||
abstract class CommonRepo {
|
||||
Future<Country> getAllCountries();
|
||||
|
||||
Future<Cities> getAllCites(String countryId);
|
||||
|
||||
Future<Role> getRoles();
|
||||
}
|
||||
|
||||
class CommonRepoImp implements CommonRepo {
|
||||
@override
|
||||
Future<Country> getAllCountries() async {
|
||||
return await injector.get<ApiClient>().getJsonForObject((json) => Country.fromJson(json), ApiConsts.GetAllCountry);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Cities> getAllCites(String countryId) async {
|
||||
var postParams = {
|
||||
"CountryID": countryId,
|
||||
};
|
||||
return await injector.get<ApiClient>().getJsonForObject((json) => Cities.fromJson(json), ApiConsts.GetAllCities, queryParameters: postParams);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Role> getRoles() async {
|
||||
return await injector.get<ApiClient>().getJsonForObject((json) => Role.fromJson(json), ApiConsts.GetProviderRoles);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,249 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:mc_common_app/utils/AppPermissionHandler.dart';
|
||||
|
||||
import 'package:mc_common_app/utils/utils.dart';
|
||||
|
||||
// import 'package:geodesy/geodesy.dart' as geodesy;
|
||||
|
||||
//Created By Mr.Zohaib
|
||||
class Location {
|
||||
static _Map map = _Map();
|
||||
|
||||
static void havePermission(Function(bool) callback) {
|
||||
Geolocator.checkPermission().then((value) async {
|
||||
if (value == LocationPermission.denied) {
|
||||
value = await Geolocator.requestPermission();
|
||||
callback(![LocationPermission.denied, LocationPermission.deniedForever].contains(value));
|
||||
} else {
|
||||
callback(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void isEnabled(Function(bool) callback) {
|
||||
Geolocator.isLocationServiceEnabled().then((value) => callback(value));
|
||||
}
|
||||
|
||||
static bool _listeningSettingChange = true;
|
||||
|
||||
static void listenGPS({bool change = true, Function(bool)? onChange}) async {
|
||||
_listeningSettingChange = change;
|
||||
if (change == false) return;
|
||||
|
||||
Future.doWhile(() async {
|
||||
await Utils.delay(1000);
|
||||
var enable = await Geolocator.isLocationServiceEnabled();
|
||||
onChange!(enable);
|
||||
return _listeningSettingChange;
|
||||
});
|
||||
}
|
||||
|
||||
static void getCurrentLocation(Function(LatLng?) callback) {
|
||||
void done(Position position) {
|
||||
//AppStorage.sp.saveLocation(position);
|
||||
|
||||
LatLng? myCurrentLocation = LatLng(position.latitude, position.longitude);
|
||||
callback(myCurrentLocation);
|
||||
}
|
||||
|
||||
AppPermissions.location((granted) {
|
||||
if (granted) {
|
||||
Geolocator.getLastKnownPosition(forceAndroidLocationManager: true).then((value) {
|
||||
if (value == null) {
|
||||
Geolocator.getCurrentPosition().then((value) {
|
||||
done(value);
|
||||
});
|
||||
} else {
|
||||
done(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// static LatLng locationAwayFrom(
|
||||
// {required LatLng loc1, num distanceMeters = 200.0, num bearing = 270.0}) {
|
||||
// geodesy.LatLng l1 = geodesy.LatLng(loc1.latitude, loc1.longitude);
|
||||
// geodesy.LatLng destinationPoint = geodesy.Geodesy()
|
||||
// .destinationPointByDistanceAndBearing(l1, distanceMeters, bearing);
|
||||
// return LatLng(destinationPoint.latitude, destinationPoint.longitude);
|
||||
// }
|
||||
|
||||
static Future<double> distanceTo(LatLng destination) async {
|
||||
var myLoc = await Geolocator.getLastKnownPosition();
|
||||
var distance = 0.0;
|
||||
if (myLoc != null) {
|
||||
distance = Geolocator.distanceBetween(destination.latitude, destination.longitude, myLoc.latitude, myLoc.longitude);
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
|
||||
class _Map {
|
||||
Marker createMarker(
|
||||
String id, {
|
||||
required LatLng coordinates,
|
||||
BitmapDescriptor? icon,
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
final MarkerId markerId = MarkerId(id);
|
||||
return Marker(
|
||||
icon: icon ?? BitmapDescriptor.defaultMarker,
|
||||
markerId: markerId,
|
||||
position: coordinates,
|
||||
flat: false,
|
||||
// infoWindow: InfoWindow(title: id, snippet: '*'),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
CameraPosition initialCamera({required Completer<GoogleMapController> mapController, LatLng? position, double zoom = 12}) {
|
||||
position = position ?? LatLng(24.7249303, 46.5416656);
|
||||
CameraPosition riyadhEye = CameraPosition(
|
||||
target: position,
|
||||
zoom: zoom,
|
||||
);
|
||||
mapController.future.then((controller) {
|
||||
controller.animateCamera(CameraUpdate.newCameraPosition(riyadhEye));
|
||||
});
|
||||
return riyadhEye;
|
||||
}
|
||||
|
||||
CameraPosition moveTo(LatLng location, {double zoom = 12, double direction = 0.0, required Completer<GoogleMapController> mapController, bool? animation}) {
|
||||
var camera = CameraPosition(target: location, zoom: zoom, bearing: direction);
|
||||
mapController.future.then((controller) {
|
||||
animation ?? false ? controller.animateCamera(CameraUpdate.newCameraPosition(camera)) : controller.moveCamera(CameraUpdate.newCameraPosition(camera));
|
||||
});
|
||||
return camera;
|
||||
}
|
||||
|
||||
void moveCamera(CameraPosition camera, @required Completer<GoogleMapController> mapController, bool animation) {
|
||||
mapController.future.then((controller) {
|
||||
animation ? controller.animateCamera(CameraUpdate.newCameraPosition(camera)) : controller.moveCamera(CameraUpdate.newCameraPosition(camera));
|
||||
});
|
||||
}
|
||||
|
||||
void scrollBy({double x = 0, double y = 0, required Completer<GoogleMapController> mapController, bool animation = true}) {
|
||||
var camera = CameraUpdate.scrollBy(x, y);
|
||||
mapController.future.then((controller) {
|
||||
animation ? controller.animateCamera(camera) : controller.moveCamera(camera);
|
||||
});
|
||||
}
|
||||
|
||||
void goToCurrentLocation({Completer<GoogleMapController>? mapController, double? direction = 0.0, bool? animation}) {
|
||||
Location.getCurrentLocation((location) {
|
||||
moveTo(location!, zoom: 17, mapController: mapController!, animation: animation, direction: direction!);
|
||||
});
|
||||
}
|
||||
|
||||
// var routes = Map<String, DirectionsRoute>();
|
||||
//
|
||||
// void setRoutePolylines(LatLng? source, LatLng? destination, Set<Polyline> polylines, Completer<GoogleMapController> mapController, Function(DirectionsRoute?) completion) {
|
||||
// if (source == null || destination == null) {
|
||||
// completion(null);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var origin = '${source.latitude},${source.longitude}';
|
||||
// var destin = '${destination.latitude},${destination.longitude}';
|
||||
// var routeId = '$origin->$destination';
|
||||
//
|
||||
// void createPolyline(DirectionsRoute results) {
|
||||
// List<LatLng> polylineCoordinates = results.overviewPath!.map((e) => LatLng(e.latitude, e.longitude)).toList();
|
||||
// PolylineId id = PolylineId("route");
|
||||
// Polyline polyline = Polyline(
|
||||
// polylineId: id,
|
||||
// color: accentColor,
|
||||
// width: 5,
|
||||
// jointType: JointType.round,
|
||||
// startCap: Cap.roundCap,
|
||||
// endCap: Cap.roundCap,
|
||||
// points: polylineCoordinates,
|
||||
// );
|
||||
//
|
||||
// polylines.removeWhere((element) => true);
|
||||
// polylines.add(polyline);
|
||||
//
|
||||
// LatLngBounds bound = getBounds(coordinates: polylineCoordinates);
|
||||
// focusCameraToLatLngBounds(bound: bound, mapController: mapController, padding: 100);
|
||||
// completion(routes[routeId]);
|
||||
// }
|
||||
//
|
||||
// var availableRoute = routes[routeId];
|
||||
// if (availableRoute == null) {
|
||||
// var request = DirectionsRequest(origin: origin, destination: destin);
|
||||
// DirectionsService().route(request, (response, status) {
|
||||
// if (status == DirectionsStatus.ok && response.routes!.isNotEmpty) {
|
||||
// routes[routeId] = response.routes!.first;
|
||||
// createPolyline(response.routes!.first);
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// createPolyline(availableRoute);
|
||||
// }
|
||||
// }
|
||||
|
||||
LatLngBounds getBounds({required List<LatLng> coordinates}) {
|
||||
var lngs = coordinates.map<double>((c) => c.longitude).toList();
|
||||
var lats = coordinates.map<double>((c) => c.latitude).toList();
|
||||
|
||||
double bottomMost = lngs.reduce(min);
|
||||
double topMost = lngs.reduce(max);
|
||||
double leftMost = lats.reduce(min);
|
||||
double rightMost = lats.reduce(max);
|
||||
|
||||
LatLngBounds bounds = LatLngBounds(
|
||||
northeast: LatLng(rightMost, topMost),
|
||||
southwest: LatLng(leftMost, bottomMost),
|
||||
);
|
||||
return bounds;
|
||||
|
||||
double? x0, x1, y0, y1;
|
||||
for (LatLng latLng in coordinates) {
|
||||
if (x0 == null) {
|
||||
x0 = x1 = latLng.latitude;
|
||||
y0 = y1 = latLng.longitude;
|
||||
} else {
|
||||
if (latLng.latitude > x1!) x1 = latLng.latitude;
|
||||
if (latLng.latitude < x0) x0 = latLng.latitude;
|
||||
if (latLng.longitude > y1!) y1 = latLng.longitude;
|
||||
if (latLng.longitude < y0!) y0 = latLng.longitude;
|
||||
}
|
||||
}
|
||||
return LatLngBounds(northeast: LatLng(x1!, y1!), southwest: LatLng(x0!, y0!));
|
||||
}
|
||||
|
||||
void focusCameraToLatLngBounds({LatLngBounds? bound, Completer<GoogleMapController>? mapController, double? padding}) async {
|
||||
if (bound == null) return;
|
||||
|
||||
CameraUpdate camera = CameraUpdate.newLatLngBounds(bound, padding!);
|
||||
final GoogleMapController controller = await mapController!.future;
|
||||
controller.animateCamera(camera);
|
||||
}
|
||||
|
||||
void focusCameraTo2Points({LatLng? point1, LatLng? point2, Completer<GoogleMapController>? mapController, double? padding}) async {
|
||||
var source = point1;
|
||||
var destination = point2;
|
||||
if (source != null && destination != null) {
|
||||
// 'package:google_maps_flutter_platform_interface/src/types/location.dart': Failed assertion: line 72 pos 16: 'southwest.latitude <= northeast.latitude': is not true.
|
||||
LatLngBounds bound;
|
||||
if (source.latitude <= destination.latitude) {
|
||||
bound = LatLngBounds(southwest: source, northeast: destination);
|
||||
} else {
|
||||
bound = LatLngBounds(southwest: destination, northeast: source);
|
||||
}
|
||||
|
||||
if (bound == null) return;
|
||||
|
||||
focusCameraToLatLngBounds(bound: bound, mapController: mapController, padding: padding);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,425 @@
|
||||
import 'package:mc_common_app/config/dependencies.dart';
|
||||
import 'package:mc_common_app/extensions/int_extensions.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/user/country.dart';
|
||||
import 'package:mc_common_app/models/user/role.dart';
|
||||
import 'package:mc_common_app/repositories/user_repo.dart';
|
||||
import 'package:mc_common_app/utils/utils.dart';
|
||||
import 'package:mc_common_app/view_models/user_view_model.dart';
|
||||
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||
|
||||
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
||||
import 'package:mc_common_app/widgets/show_fill_button.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mc_common_app/widgets/tab/role_type_tab.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../theme/colors.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RegisterPage> createState() => _RegisterPageState();
|
||||
}
|
||||
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
String phoneNum = "", countryCode = "";
|
||||
|
||||
int role = -1, countryId = -1;
|
||||
|
||||
TextEditingController emailController = TextEditingController();
|
||||
|
||||
Future<Role>? futureRoles;
|
||||
Future<Country>? futureCountries;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
fetchData();
|
||||
}
|
||||
|
||||
fetchData() {
|
||||
UserRepo userRepo = injector.get<UserRepo>();
|
||||
userRepo.getRoles().then((value) {
|
||||
setState(() {
|
||||
futureRoles = Future.value(value);
|
||||
});
|
||||
});
|
||||
userRepo.getAllCountries().then((value) {
|
||||
setState(() {
|
||||
futureCountries = Future.value(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final UserVM userVM = context.read<UserVM>();
|
||||
return Scaffold(
|
||||
appBar: const CustomAppBar(isRemoveBackButton: false, title: ""),
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(
|
||||
children: [
|
||||
12.height,
|
||||
LocaleKeys.signUp.tr().toText(
|
||||
fontSize: 20,
|
||||
letterSpacing: -1.44,
|
||||
),
|
||||
LocaleKeys.enterPhoneNumber.tr().toText(
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
fontSize: 14,
|
||||
height: 23 / 24,
|
||||
letterSpacing: -0.48,
|
||||
),
|
||||
30.height,
|
||||
FutureBuilder<Role>(
|
||||
future: futureRoles,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
List<DropValue> dropList = [];
|
||||
snapshot.data?.data?.forEach((element) {
|
||||
dropList.add(DropValue(element.id ?? 0, EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" ? element.roleNameN ?? "" : element.roleName ?? "", ""));
|
||||
});
|
||||
if (role == -1) {
|
||||
role = snapshot.data?.data?.first.id ?? -1;
|
||||
}
|
||||
return RoleTypeTab(
|
||||
0,
|
||||
dropList,
|
||||
onSelect: (DropValue value) {
|
||||
role = value.id;
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
18.height,
|
||||
FutureBuilder<Country>(
|
||||
future: futureCountries,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
List<DropValue> dropList = [];
|
||||
snapshot.data?.data?.forEach((element) {
|
||||
dropList.add(DropValue(
|
||||
element.id ?? 0,
|
||||
EasyLocalization.of(context)?.currentLocale?.countryCode == "SA"
|
||||
? (element.countryNameN ?? "") + " " + (element.countryCode ?? "")
|
||||
: (element.countryName ?? "") + " " + (element.countryCode ?? ""),
|
||||
element.countryCode ?? ""));
|
||||
});
|
||||
return Column(
|
||||
children: [
|
||||
LocaleKeys.selectYourCountry.tr().toText(
|
||||
fontSize: 14,
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
10.height,
|
||||
DropdownField(
|
||||
(DropValue value) {
|
||||
setState(() {
|
||||
countryCode = value.subValue;
|
||||
countryId = value.id;
|
||||
});
|
||||
},
|
||||
list: dropList,
|
||||
hint: LocaleKeys.chooseCountry.tr(),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return CircularProgressIndicator();
|
||||
}
|
||||
},
|
||||
),
|
||||
18.height,
|
||||
LocaleKeys.enterPhoneForVerfication.tr().toText(
|
||||
fontSize: 14,
|
||||
color: MyColors.lightTextColor,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
10.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Utils.mExp(1),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
(countryCode.isEmpty ? "+00" : "+" + countryCode),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
" | ",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: TextField(
|
||||
controller: emailController,
|
||||
onChanged: (v) {
|
||||
phoneNum = v;
|
||||
},
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: MyColors.black,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
hintStyle: TextStyle(color: MyColors.lightTextColor, fontSize: 20),
|
||||
hintText: "546758594",
|
||||
contentPadding: EdgeInsets.zero,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Utils.mExp(1),
|
||||
],
|
||||
),
|
||||
40.height,
|
||||
ShowFillButton(
|
||||
title: LocaleKeys.continu.tr(),
|
||||
maxWidth: double.infinity,
|
||||
onPressed: () {
|
||||
if (validation()) userVM.performBasicOtpRegisterPage(context, countryCode: countryCode, phoneNum: phoneNum, role: role);
|
||||
// if (validation()) performBasicOtp(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> performBasicOtp(BuildContext context) async {
|
||||
//
|
||||
// Utils.showLoading(context);
|
||||
// BasicOtp basicOtp = await UserApiClent().basicOtp(countryCode + phoneNum, roleId: role);
|
||||
// Utils.hideLoading(context);
|
||||
// if (basicOtp.messageStatus == 1) {
|
||||
// showMDialog(context, child: OtpDialog(
|
||||
// onClick: (String code) async {
|
||||
// pop(context);
|
||||
// Utils.showLoading(context);
|
||||
// RegisterUser user = await UserApiClent().basicVerify(countryCode + phoneNum, code, basicOtp.data!.userToken ?? "");
|
||||
// Utils.hideLoading(context);
|
||||
// if (user.messageStatus == 1) {
|
||||
// Utils.showToast(user.message ?? "");
|
||||
// navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user);
|
||||
// } else {
|
||||
// Utils.showToast(user.message ?? "");
|
||||
// }
|
||||
// },
|
||||
// ));
|
||||
// } else {
|
||||
// Utils.showToast(basicOtp.message ?? "");
|
||||
// }
|
||||
// }
|
||||
|
||||
bool validation() {
|
||||
bool isValid = true;
|
||||
if (role == -1) {
|
||||
Utils.showToast("Please select Provider Role");
|
||||
isValid = false;
|
||||
} else if (countryCode.isEmpty) {
|
||||
Utils.showToast("Please select Country Code");
|
||||
isValid = false;
|
||||
} else if (phoneNum.isEmpty) {
|
||||
Utils.showToast("Please add Phone No");
|
||||
isValid = false;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
}
|
||||
|
||||
// class _RegisterPageState extends State<RegisterPage> {
|
||||
// String phoneNum = "", countryCode = "";
|
||||
//
|
||||
// int role = 4, countryId = -1;
|
||||
//
|
||||
// TextEditingController emailController = TextEditingController();
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final UserVM userVM = context.read<UserVM>();
|
||||
// return Scaffold(
|
||||
// appBar:CustomAppBar(
|
||||
// isRemoveBackButton: false, title: ""),
|
||||
// body: Container(
|
||||
// width: double.infinity,
|
||||
// height: double.infinity,
|
||||
// padding: const EdgeInsets.all(20),
|
||||
// child: SingleChildScrollView(
|
||||
// child: SizedBox(
|
||||
// height: MediaQuery.of(context).size.height,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// 12.height,
|
||||
// LocaleKeys.signUp.tr().toText(fontSize: 20, letterSpacing: -1.44,),
|
||||
// 20.height,
|
||||
// LocaleKeys.enterPhoneNumber.tr().toText(
|
||||
// color: MyColors.lightTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 14,
|
||||
// height: 23 / 24,
|
||||
// letterSpacing: -0.48,
|
||||
// ),
|
||||
// 30.height,
|
||||
// FutureBuilder<Country>(
|
||||
// future: userVM.getAllCountries(),
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.hasData) {
|
||||
// List<DropValue> dropList = [];
|
||||
// snapshot.data?.data?.forEach((element) {
|
||||
// dropList.add(DropValue(
|
||||
// element.id ?? 0,
|
||||
// EasyLocalization.of(context)?.currentLocale?.countryCode == "SA"
|
||||
// ? (element.countryNameN ?? "") + " " + (element.countryCode ?? "")
|
||||
// : (element.countryName ?? "") + " " + (element.countryCode ?? ""),
|
||||
// element.countryCode ?? ""));
|
||||
// });
|
||||
// return Column(
|
||||
// children: [
|
||||
// LocaleKeys.selectYourCountry.tr().toText(
|
||||
// color: MyColors.lightTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 14,
|
||||
// height: 23 / 24,
|
||||
// letterSpacing: -0.48,
|
||||
// ),
|
||||
// 10.height,
|
||||
// DropdownField(
|
||||
// (DropValue value) {
|
||||
// setState(() {
|
||||
// countryCode = value.subValue;
|
||||
// countryId = value.id;
|
||||
// });
|
||||
// },
|
||||
// list: dropList,
|
||||
// hint: LocaleKeys.chooseCountry.tr(),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else {
|
||||
// return const CircularProgressIndicator();
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// 18.height,
|
||||
// LocaleKeys.enterPhoneForVerfication.tr().toText(
|
||||
// color: MyColors.lightTextColor,
|
||||
// textAlign: TextAlign.center,
|
||||
// fontSize: 14,
|
||||
// height: 23 / 24,
|
||||
// letterSpacing: -0.48,
|
||||
// ),
|
||||
// 10.height,
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// children: [
|
||||
// Utils.mExp(1),
|
||||
// Expanded(
|
||||
// flex: 3,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// (countryCode.isEmpty ? "+00" : "+" + countryCode),
|
||||
// style: const TextStyle(
|
||||
// fontSize: 20,
|
||||
// color: MyColors.black,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// const Text(
|
||||
// " | ",
|
||||
// style: TextStyle(
|
||||
// fontSize: 20,
|
||||
// color: MyColors.black,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// Flexible(
|
||||
// child: TextField(
|
||||
// controller: emailController,
|
||||
// onChanged: (v) {
|
||||
// phoneNum = v;
|
||||
// },
|
||||
// style: const TextStyle(
|
||||
// fontSize: 20,
|
||||
// color: MyColors.black,
|
||||
// ),
|
||||
// decoration: const InputDecoration(
|
||||
// hintStyle: TextStyle(color: MyColors.lightTextColor, fontSize: 20),
|
||||
// hintText: "546758594",
|
||||
// contentPadding: EdgeInsets.zero,
|
||||
// border: InputBorder.none,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Utils.mExp(1),
|
||||
// ],
|
||||
// ),
|
||||
// 40.height,
|
||||
// ShowFillButton(
|
||||
// title: LocaleKeys.continu.tr(),
|
||||
// maxWidth: double.infinity,
|
||||
// onPressed: () {
|
||||
// if (validation()) userVM.performBasicOtpRegisterPage(context, countryCode: countryCode, phoneNum: phoneNum, role: role);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// bool validation() {
|
||||
// bool isValid = true;
|
||||
// if (role == -1) {
|
||||
// Utils.showToast(LocaleKeys.selectProviderRole.tr());
|
||||
// //("Please select Provider Role");
|
||||
// isValid = false;
|
||||
// } else if (countryCode.isEmpty) {
|
||||
// Utils.showToast(LocaleKeys.selectCountryCode.tr());
|
||||
// //("Please select Country Code");
|
||||
// isValid = false;
|
||||
// } else if (phoneNum.isEmpty) {
|
||||
// Utils.showToast(LocaleKeys.addPhoneNo.tr());
|
||||
// //("Please add Phone No");
|
||||
// isValid = false;
|
||||
// }
|
||||
// return isValid;
|
||||
// }
|
||||
// }
|
||||
@ -0,0 +1,61 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||
import 'package:mc_common_app/theme/colors.dart';
|
||||
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
||||
|
||||
class RoleTypeTab extends StatefulWidget {
|
||||
int selectedIndex;
|
||||
List<DropValue> dropList;
|
||||
Function(DropValue value) onSelect;
|
||||
|
||||
RoleTypeTab(this.selectedIndex, this.dropList, {required this.onSelect});
|
||||
|
||||
@override
|
||||
State<RoleTypeTab> createState() => _RoleTypeTabState();
|
||||
}
|
||||
|
||||
class _RoleTypeTabState extends State<RoleTypeTab> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
child: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.selectedIndex = index;
|
||||
widget.onSelect(widget.dropList[index]);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
width: (MediaQuery.of(context).size.width / 2)-30,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.selectedIndex == index ? MyColors.darkPrimaryColor : Colors.grey[200],
|
||||
// border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(0)),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.dropList[index].value,
|
||||
style: TextStyle(
|
||||
color: widget.selectedIndex == index ? MyColors.white : Colors.black,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return 12.width;
|
||||
},
|
||||
itemCount: widget.dropList.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue