This commit is contained in:
Hamza-Ayed
2023-09-03 13:48:55 +03:00
parent 4628f91d3e
commit ef6d3604cd
12 changed files with 341 additions and 205 deletions

View File

@@ -4,7 +4,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application android:label="ride" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <application android:label="SEFER" android:name="${applicationName}" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as <!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user the Android process has started. This theme is visible to the user

View File

@@ -1,58 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>GMSApiKey</key> <key>GMSApiKey</key>
<string>YOUR_API_KEY</string> <string>YOUR_API_KEY</string>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required to provide relevant information.</string> <string>Your location is required to provide relevant information.</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>Ride</string> <string>Sefer</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>ride</string> <string>Sefer</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string> <string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string> <string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
<string>Main</string> <string>Main</string>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key> <key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>CADisableMinimumFrameDurationOnPhone</key> <key>CADisableMinimumFrameDurationOnPhone</key>
<true/> <true/>
<key>UIApplicationSupportsIndirectInputEvents</key> <key>UIApplicationSupportsIndirectInputEvents</key>
<true/> <true/>
</dict> </dict>
</plist> </plist>

View File

@@ -16,4 +16,5 @@ class BoxName {
static const String cvvCode = "cvvCode"; static const String cvvCode = "cvvCode";
static const String passengerWalletDetails = "passengerWalletDetails"; static const String passengerWalletDetails = "passengerWalletDetails";
static const String passengerWalletTotal = "passengerWalletTotal"; static const String passengerWalletTotal = "passengerWalletTotal";
static const String passengerWalletFound = "passengerWalletFound";
} }

View File

@@ -5,6 +5,9 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:ride/constant/colors.dart'; import 'package:ride/constant/colors.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/controller/functions/launch.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../constant/box_name.dart'; import '../../constant/box_name.dart';
import '../../constant/credential.dart'; import '../../constant/credential.dart';
@@ -84,31 +87,89 @@ class FirebasMessagesController extends GetxController {
} }
} }
void getToken() async { Future getToken() async {
await fcmToken.getToken().then((token) { fcmToken.getToken().then((token) {
box.write(BoxName.tokenFCM, token); box.write(BoxName.tokenFCM, token);
print(token); print(token);
}); });
FirebaseMessaging.onMessage.listen((RemoteMessage message) { FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print( if (message.data.isNotEmpty) {
'onMessage: ${message.notification!.title} ${message.notification!.body}'); if (message.notification!.title!.contains('Order')) {
if (Get.currentRoute == '/') { var myListString = message.data['myList'];
// If the app is in the foreground, show a dialog to the user var myList = jsonDecode(myListString) as List<dynamic>;
if (message.notification!.title!.contains('ride')) { Get.defaultDialog(
Get.snackbar('ride', 'message', backgroundColor: AppColor.redColor); title: message.notification!.title.toString(),
} content: Column(
} else { crossAxisAlignment: CrossAxisAlignment.start,
// If the app is in the background or terminated, show a system tray message children: [
RemoteNotification? notification = message.notification; // Text(message.notification!.body.toString()),
AndroidNotification? android = message.notification?.android; Padding(
if (notification != null && android != null) { padding: const EdgeInsets.all(8.0),
print( child: TextButton.icon(
'onMessageOpenedApp: ${notification.title} ${notification.body}'); onPressed: () {
if (message.notification!.title!.contains('ride')) { String mapUrl =
Get.snackbar('ride', 'message', backgroundColor: AppColor.redColor); 'https://www.google.com/maps/dir/${myList[0]}/${myList[0]}/';
// SendGpsNow().getSiteNotification(); print(mapUrl);
} launchUrl1(mapUrl);
},
icon: const Icon(Icons.map),
label: Text('Rouats of Trip'.tr)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Tatal From Passenger is '.tr +
double.parse(myList[2]).toStringAsFixed(2),
style: AppStyle.title,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Tatal For You is '.tr +
double.parse(myList[3]).toStringAsFixed(2),
style: AppStyle.title,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Distance is '.tr + myList[4].toString() + ' Minutes'.tr,
style: AppStyle.title,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Duration of Trip is '.tr + myList[5].toString(),
style: AppStyle.title,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MyElevatedButton(
title: 'Apply Order'.tr,
onPressed: () {
//TODO save and request to passenger
},
),
MyElevatedButton(
title: 'Refuse Order'.tr,
onPressed: () {
//TODO save and request to passenger and driver log upto 3 per 1 day
},
kolor: AppColor.redColor,
),
],
),
)
],
));
} }
} }
}); });
@@ -119,8 +180,8 @@ class FirebasMessagesController extends GetxController {
RemoteNotification? notification = message.notification; RemoteNotification? notification = message.notification;
if (notification != null) { if (notification != null) {
print('onMessageOpenedApp: ${notification.title} ${notification.body}'); print('onMessageOpenedApp: ${notification.title} ${notification.body}');
if (message.notification!.title!.contains('ride')) { if (message.notification!.title!.contains('SEFER')) {
Get.snackbar('ride', 'message', backgroundColor: AppColor.redColor); Get.snackbar('SEFER', 'message', backgroundColor: AppColor.redColor);
} }
} }
}); });
@@ -222,4 +283,31 @@ class FirebasMessagesController extends GetxController {
// print('sendNotification() error: $e'); // print('sendNotification() error: $e');
// }); // });
// } // }
void sendNotificationDriverId(String title, body, Strin1, Strin2, Strin3,
Strin4, Strin5, Strin6, token) async {
http
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'key=${AppCredintials.serverAPI}'
},
body: jsonEncode({
'notification': <String, dynamic>{
'title': title,
'body': body,
'sound': 'true'
},
'data': {
'myList': jsonEncode(
[Strin1, Strin2, Strin3, Strin4, Strin5, Strin6]),
},
'priority': 'high',
'to': token,
}))
.whenComplete(() {})
.catchError((e) {
print('sendNotification() error: $e');
});
}
} }

View File

@@ -21,8 +21,8 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}', 'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
}, },
); );
// print("--------------" + response.request.toString()); print("--------------" + response.request.toString());
// print("--------------" + payload.toString()); print("--------------" + payload.toString());
if (response.statusCode == 200) { if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body); var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') { if (jsonData['status'] == 'success') {

View File

@@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:math' show sqrt, pi, cos, sin; import 'dart:math' show sqrt, pi, cos, sin;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart'; import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
@@ -10,6 +9,7 @@ import 'package:location/location.dart';
import 'package:ride/constant/box_name.dart'; import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/credential.dart'; import 'package:ride/constant/credential.dart';
import 'package:ride/constant/links.dart'; import 'package:ride/constant/links.dart';
import 'package:ride/controller/firebase/firbase_messge.dart';
import 'package:ride/controller/functions/crud.dart'; import 'package:ride/controller/functions/crud.dart';
import 'package:ride/controller/functions/secure_storage.dart'; import 'package:ride/controller/functions/secure_storage.dart';
import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/elevated_btn.dart';
@@ -115,11 +115,48 @@ class MapController extends GetxController {
update(); update();
} }
changeConfirmRide() { changeConfirmRide() async {
rideConfirm = true; rideConfirm = true;
print('rideConfirm= $rideConfirm'); print('rideConfirm= $rideConfirm');
//TODO add ride and get ride id and details await CRUD().post(link: AppLink.addRides, payload: {
"start_location":
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
"end_location":
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
"date": DateTime.now().toString(),
"time": DateTime.now().toString(),
"endtime": durationToAdd.toString(),
"price": totalPassenger.toString(),
"passenger_id": box.read(BoxName.pasengerID).toString(),
"driver_id": dataCarsLocationByPassenger['message'][0]['id'].toString(),
"status": "active",
"price_for_driver": totalDriver.toString(),
"price_for_passenger": totaME.toString(),
"distance": distance.toString()
}).then((value) {
print(value);
List<String> body = [
'${data[0]["start_location"]['lat']},${data[0]["start_location"]['lng']}',
'${data[0]["end_location"]['lat']},${data[0]["end_location"]['lng']}',
totalPassenger.toString(),
totalDriver.toString(),
duration.toString(),
distance.toString(),
];
FirebasMessagesController().sendNotificationDriverId(
'Order',
'body',
body[0],
body[1],
body[2],
body[3],
body[4],
body[5],
box.read(BoxName.tokenFCM).toString(), //TODO change to Driver
);
});
update(); update();
} }
@@ -369,7 +406,8 @@ class MapController extends GetxController {
} }
void reloadMarkers() async { void reloadMarkers() async {
await getCarsLocationByPassenger(); //TODO await getCarsLocationByPassenger();
// Clear existing markers // Clear existing markers
markers.clear(); markers.clear();
getNearestDriverByPassengerLocation(); getNearestDriverByPassengerLocation();
@@ -392,59 +430,62 @@ class MapController extends GetxController {
String duratioByPassenger = ''; String duratioByPassenger = '';
void getNearestDriverByPassengerLocation() async { void getNearestDriverByPassengerLocation() async {
double nearestDistance = double.infinity; if (polylines.isEmpty) {
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) { double nearestDistance = double.infinity;
var carLocation = dataCarsLocationByPassenger['message'][i]; for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
var carLocation = dataCarsLocationByPassenger['message'][i];
// double distance1 = Geolocator.distanceBetween( // double distance1 = Geolocator.distanceBetween(
// mylocation.latitude, // mylocation.latitude,
// mylocation.longitude, // mylocation.longitude,
// double.parse(carLocation['latitude']), // double.parse(carLocation['latitude']),
// double.parse(carLocation['longitude']), // double.parse(carLocation['longitude']),
// ); // );
// if (distance1 < nearestDistance) { // if (distance1 < nearestDistance) {
// nearestDistance = distance1; // nearestDistance = distance1;
// // nearestCarLocation = carLocation; // // nearestCarLocation = carLocation;
// nearestCar = CarLocation( // nearestCar = CarLocation(
// distance: distance1, // distance: distance1,
// id: carLocation['driver_id'], // id: carLocation['driver_id'],
// latitude: double.parse(carLocation['latitude']), // latitude: double.parse(carLocation['latitude']),
// longitude: double.parse(carLocation['longitude']), // longitude: double.parse(carLocation['longitude']),
// ); // );
// } // }
isloading = true; isloading = true;
update(); update();
// Make API request to get exact distance and duration // Make API request to get exact distance and duration
String apiUrl = String apiUrl =
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${mylocation.latitude},${mylocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}'; '${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${mylocation.latitude},${mylocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {}); var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
if (response['status'] == "OK") { if (response['status'] == "OK") {
var data = response; var data = response;
// Extract distance and duration from the response and handle accordingly // Extract distance and duration from the response and handle accordingly
int distance1 = data['rows'][0]['elements'][0]['distance']['value']; int distance1 = data['rows'][0]['elements'][0]['distance']['value'];
duration1 = data['rows'][0]['elements'][0]['duration']['value']; duration1 = data['rows'][0]['elements'][0]['duration']['value'];
duratioByPassenger = data['rows'][0]['elements'][0]['duration']['text']; duratioByPassenger =
data['rows'][0]['elements'][0]['duration']['text'];
if (distance1 < nearestDistance) { if (distance1 < nearestDistance) {
nearestDistance = distance1.toDouble(); nearestDistance = distance1.toDouble();
nearestCar = CarLocation( nearestCar = CarLocation(
distance: distance1.toDouble(), distance: distance1.toDouble(),
duration: duration1.toDouble(), duration: duration1.toDouble(),
id: carLocation['driver_id'], id: carLocation['driver_id'],
latitude: double.parse(carLocation['latitude']), latitude: double.parse(carLocation['latitude']),
longitude: double.parse(carLocation['longitude']), longitude: double.parse(carLocation['longitude']),
); );
isloading = false; isloading = false;
update(); update();
}
} }
}
// Handle the distance and duration as needed // Handle the distance and duration as needed
else { else {
print( print(
'Failed to retrieve distance and duration: ${response['status']}'); 'Failed to retrieve distance and duration: ${response['status']}');
// Handle the failure case // Handle the failure case
}
} }
} }
print(nearestCar!.distance); print(nearestCar!.distance);
@@ -534,6 +575,7 @@ class MapController extends GetxController {
bool promoTaken = false; bool promoTaken = false;
void applyPromoCodetoPassenger() async { void applyPromoCodetoPassenger() async {
//TAWJIHI //TAWJIHI
CRUD().get(link: AppLink.getPassengersPromo, payload: { CRUD().get(link: AppLink.getPassengersPromo, payload: {
'promo_code': promo.text, 'promo_code': promo.text,
}).then((value) { }).then((value) {
@@ -736,8 +778,8 @@ class MapController extends GetxController {
@override @override
void onInit() async { void onInit() async {
await getLocation(); await getLocation();
await getCarsLocationByPassenger(); // await getCarsLocationByPassenger();
getNearestDriverByPassengerLocation(); // getNearestDriverByPassengerLocation();
addCustomPicker(); addCustomPicker();
addCustomCarIcon(); addCustomCarIcon();
startMarkerReloading(); startMarkerReloading();

View File

@@ -13,30 +13,34 @@ class PaymentController extends GetxController {
bool isloading = false; bool isloading = false;
bool isWalletCheced = false; bool isWalletCheced = false;
bool isCashCheced = false; bool isCashCheced = false;
bool isWalletFound = false;
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
final promo = TextEditingController(); final promo = TextEditingController();
double totalPassenger = MapController().totalPassenger; double totalPassenger = MapController().totalPassenger;
List<dynamic> totalPassengerWalletDetails = [];
String passengerTotalWalletAmount = '';
getPassengerWallet() async { getPassengerWallet() async {
isloading = true; isloading = true;
update(); update();
if (box.read(BoxName.passengerWalletDetails) == null) { box.write(BoxName.passengerWalletFound, isWalletFound);
// totalPassengerWalletDetails = box.read(BoxName.passengerWalletDetails);
if (totalPassengerWalletDetails == null ||
totalPassengerWalletDetails.isEmpty) {
await CRUD().get(link: AppLink.getWalletByPassenger, payload: { await CRUD().get(link: AppLink.getWalletByPassenger, payload: {
'passenger_id': box.read(BoxName.pasengerID) 'passenger_id': box.read(BoxName.pasengerID)
}).then((value) { }).then((value) {
final total = jsonDecode(value)['message']; print(value);
totalPassengerWalletDetails = jsonDecode(value)['message'];
box.write(BoxName.passengerWalletDetails, total); passengerTotalWalletAmount = totalPassengerWalletDetails[0]['total'];
box.write(BoxName.passengerWalletDetails, totalPassengerWalletDetails);
}); });
isloading = false;
update();
print('from empty');
print(box.read(BoxName.passengerWalletDetails));
} else {
box.read(BoxName.passengerWalletDetails);
update();
print('from full');
print(box.read(BoxName.passengerWalletDetails));
} }
isloading = false;
update();
print(totalPassengerWalletDetails);
} }
void onChangedPymentethodWallet(bool? value) { void onChangedPymentethodWallet(bool? value) {
@@ -63,6 +67,7 @@ class PaymentController extends GetxController {
var firstElement = decod["message"][0]; var firstElement = decod["message"][0];
totalPassenger = totalPassenger - totalPassenger = totalPassenger -
(totalPassenger * int.parse(firstElement['amount'])); (totalPassenger * int.parse(firstElement['amount']));
MapController().promoTaken = true;
update(); update();
print(totalPassenger); print(totalPassenger);
} }
@@ -70,8 +75,8 @@ class PaymentController extends GetxController {
} }
@override @override
void onInit() { void onInit() async {
getPassengerWallet(); await getPassengerWallet();
super.onInit(); super.onInit();
} }

View File

@@ -40,7 +40,7 @@ void main() async {
await FirebasMessagesController().requestFirebaseMessagingPermission(); await FirebasMessagesController().requestFirebaseMessagingPermission();
// await FirebasMessagesController().getNotificationSettings(); // await FirebasMessagesController().getNotificationSettings();
FirebasMessagesController().getToken(); await FirebasMessagesController().getToken();
await FirebasMessagesController().getTokens(); await FirebasMessagesController().getTokens();
LocationPermissions().locationPermissions(); LocationPermissions().locationPermissions();
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);

View File

@@ -129,7 +129,8 @@ class MapPage extends StatelessWidget {
// Circle( // Circle(
// circleId: const CircleId('kk'), // circleId: const CircleId('kk'),
// center: controller.mylocation, // center: controller.mylocation,
// radius: 2000) // radius: 60,
// fillColor: AppColor.primaryColor,)
// }, // },
mapType: mapType:
controller.mapType ? MapType.satellite : MapType.normal, controller.mapType ? MapType.satellite : MapType.normal,

View File

@@ -233,61 +233,62 @@ GetBuilder<MapController> buttomSheetMapPage() {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
Get.defaultDialog( Get
title: 'Add Promo'.tr, .defaultDialog(
content: Column( title: 'Add Promo'
children: [ .tr,
SizedBox( content:
width: Column(
Get.width * .7, children: [
child: SizedBox(
TextFormField( width: Get.width * .7,
controller: child: TextFormField(
controller.promo, controller: controller.promo,
decoration: decoration: InputDecoration(
InputDecoration( labelText: 'Promo Code'.tr,
labelText: 'Promo Code'.tr, hintText: 'Enter promo code'.tr,
hintText: 'Enter promo code'.tr, border: OutlineInputBorder(
border: OutlineInputBorder( borderRadius: BorderRadius.circular(10),
borderRadius: BorderRadius.circular(10), ),
), filled: true,
filled: true, fillColor: Colors.grey[200],
fillColor: Colors.grey[200], focusedBorder: OutlineInputBorder(
focusedBorder: OutlineInputBorder( borderSide: const BorderSide(
borderSide: const BorderSide( color: AppColor.primaryColor,
color: AppColor.primaryColor, width: 2.0,
width: 2.0, ),
borderRadius: BorderRadius.circular(10),
),
errorBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.red,
width: 2.0,
),
borderRadius: BorderRadius.circular(10),
),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(10),
),
), ),
borderRadius: BorderRadius.circular(10),
),
errorBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.red,
width: 2.0,
),
borderRadius: BorderRadius.circular(10),
),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(10),
), ),
), ),
), MyElevatedButton(
), title: 'Add Promo'.tr,
MyElevatedButton( onPressed: () async {
title: if (controller.promoTaken == false) {
'Add Promo'.tr, controller.applyPromoCodetoPassenger();
onPressed: Get.back();
() async { } else {
controller.applyPromoCodetoPassenger(); Get.defaultDialog(title: 'You have Promo ?.'.tr);
Get.back(); }
}, },
) )
], ],
)); ));
}, },
child: Text( child: Text(
'Add Promo'.tr, 'Add Promo'.tr,

View File

@@ -2,11 +2,8 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart'; import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/style.dart'; import 'package:ride/constant/style.dart';
import 'package:ride/controller/functions/secure_storage.dart';
import 'package:ride/controller/home/payment/payment_controller.dart'; import 'package:ride/controller/home/payment/payment_controller.dart';
import 'package:ride/views/widgets/circle_container.dart';
import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/elevated_btn.dart';
import 'package:ride/views/widgets/mycircular.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
import '../../../controller/home/map_page_controller.dart'; import '../../../controller/home/map_page_controller.dart';
@@ -72,7 +69,7 @@ class CashConfirmPageShown extends StatelessWidget {
), ),
Text( Text(
// '${'Your Wallet balance is '.tr}JD ', // '${'Your Wallet balance is '.tr}JD ',
'${'Your Wallet balance is '.tr}JD ${box.read(BoxName.passengerWalletDetails)[0]['total'].toString()}', '${'Your Wallet balance is '.tr}JD ${controller.passengerTotalWalletAmount.toString()}',
style: AppStyle.subtitle, style: AppStyle.subtitle,
), ),
], ],

View File

@@ -6,18 +6,19 @@ import '../../constant/colors.dart';
class MyElevatedButton extends StatelessWidget { class MyElevatedButton extends StatelessWidget {
final String title; final String title;
final VoidCallback onPressed; final VoidCallback onPressed;
final Color kolor;
const MyElevatedButton({ const MyElevatedButton({
Key? key, Key? key,
required this.title, required this.title,
required this.onPressed, required this.onPressed,
this.kolor = AppColor.primaryColor,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ElevatedButton( return ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(AppColor.primaryColor), backgroundColor: MaterialStateProperty.all(kolor),
), ),
onPressed: onPressed, onPressed: onPressed,
child: Text( child: Text(