8-12/
This commit is contained in:
@@ -1,13 +1,50 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/main.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController firstNameController = TextEditingController();
|
||||
TextEditingController lastNameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool isAgreeTerms = false;
|
||||
|
||||
void login() {
|
||||
//TODO: Implement login logic
|
||||
void changeAgreeTerm() {
|
||||
isAgreeTerms = !isAgreeTerms;
|
||||
print(isAgreeTerms);
|
||||
update();
|
||||
}
|
||||
|
||||
void saveAgreementTerms() {
|
||||
box.write(BoxName.agreeTerms, 'agreed');
|
||||
update();
|
||||
}
|
||||
|
||||
void login() async {
|
||||
Map<String, dynamic> res = await CRUD().post(link: AppLink.login, payload: {
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text
|
||||
});
|
||||
|
||||
if (res.isNotEmpty) {
|
||||
if (res['status'] == 'success1') {
|
||||
print(res);
|
||||
} else {
|
||||
print('noooooooooooooooo');
|
||||
}
|
||||
} else {
|
||||
print('res is null');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
48
lib/controller/auth/register_controller.dart
Normal file
48
lib/controller/auth/register_controller.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class RegisterController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
TextEditingController firstNameController = TextEditingController();
|
||||
TextEditingController lastNameController = TextEditingController();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
|
||||
String birthDate = 'Birth Date'.tr;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
getBirthDate() {
|
||||
Get.defaultDialog(
|
||||
title: 'Select Date',
|
||||
content: SizedBox(
|
||||
width: 300,
|
||||
child: CalendarDatePicker(
|
||||
initialDate: DateTime.now().subtract(const Duration(days: 14 * 365)),
|
||||
firstDate: DateTime.parse('1940-06-01'),
|
||||
lastDate: DateTime.now().subtract(const Duration(days: 14 * 365)),
|
||||
onDateChanged: (date) {
|
||||
// Get the selected date and convert it to a DateTime object
|
||||
DateTime dateTime = date;
|
||||
// Call the getOrders() function from the controller
|
||||
birthDate = dateTime.toString().split(' ')[0];
|
||||
update();
|
||||
Get.back();
|
||||
},
|
||||
|
||||
// onDateChanged: (DateTime value) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void register() {
|
||||
if (formKey.currentState!.validate()) {
|
||||
// Do something with the data
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,17 +9,26 @@ class CRUD {
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
var url = Uri.parse(link);
|
||||
var response = await http.get(
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
},
|
||||
);
|
||||
List data = jsonDecode(response.body)['data'];
|
||||
print(data);
|
||||
return data;
|
||||
// print("--------------" + response.body.toString());
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
print(jsonData['message']);
|
||||
return jsonData['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> post({
|
||||
@@ -50,7 +59,7 @@ class CRUD {
|
||||
return response.body;
|
||||
} else if (jsonData['status'] == 'success1') {
|
||||
print(jsonData['data']);
|
||||
return jsonData['data'];
|
||||
return jsonData;
|
||||
}
|
||||
}
|
||||
return (response.body);
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:math' as math;
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/views/home/map_widget.dart/buttom_sheet_map_show.dart';
|
||||
|
||||
@@ -24,7 +21,9 @@ class MapController extends GetxController {
|
||||
late LatLng newMylocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> carsLocationByPassenger = [];
|
||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
double height = 200;
|
||||
final location = Location();
|
||||
late LocationData currentLocation;
|
||||
@@ -110,7 +109,21 @@ class MapController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
size: Size(50, 50),
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
|
||||
.then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
isloading = true;
|
||||
update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
@@ -134,16 +147,33 @@ class MapController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Configure location accuracy
|
||||
LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
mylocation =
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
// print('accuracy' + _locationData.accuracy.toString());
|
||||
// print(_locationData.latitude);
|
||||
// print(_locationData.time);
|
||||
// print('//////////////////////////////////////');
|
||||
|
||||
// Print location details
|
||||
print('Accuracy: ${_locationData.accuracy}');
|
||||
print('Latitude: ${_locationData.latitude}');
|
||||
print('Longitude: ${_locationData.longitude}');
|
||||
print('Time: ${_locationData.time}');
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getCarsLocationByPassenger() async {
|
||||
List data =
|
||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {});
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(double.parse(data[i]['latitude']),
|
||||
double.parse(data[i]['longitude'])));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -357,11 +387,13 @@ class MapController extends GetxController {
|
||||
List<LatLng> polylineCoordinate = [];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
// getPolyLine();
|
||||
// getMap();
|
||||
getLocation();
|
||||
await getCarsLocationByPassenger();
|
||||
addCustomPicker();
|
||||
addCustomCarIcon();
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user