This commit is contained in:
Hamza-Ayed
2023-09-05 11:24:45 +03:00
parent ef6d3604cd
commit 4380826253
9 changed files with 418 additions and 158 deletions

View File

@@ -10,4 +10,7 @@ class AppCredintials {
String getBasicAuthCredentials() { String getBasicAuthCredentials() {
return base64Encode(utf8.encode(basicAuthCredentials)); return base64Encode(utf8.encode(basicAuthCredentials));
} }
static const String transactionCloude =
'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F';
} }

View File

@@ -26,7 +26,7 @@ class CRUD {
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') {
// print(jsonData); print(jsonData);
return response.body; return response.body;
} }
return jsonData['status']; return jsonData['status'];

View File

@@ -6,12 +6,15 @@ 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';
import 'package:location/location.dart'; import 'package:location/location.dart';
import 'package:path/path.dart';
import 'package:ride/constant/box_name.dart'; import 'package:ride/constant/box_name.dart';
import 'package:ride/constant/colors.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/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/controller/functions/toast.dart';
import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/elevated_btn.dart';
import '../../main.dart'; import '../../main.dart';
import '../../models/model/locations.dart'; import '../../models/model/locations.dart';
@@ -36,6 +39,7 @@ class MapController extends GetxController {
final location = Location(); final location = Location();
late LocationData currentLocation; late LocationData currentLocation;
double heightMenu = 0; double heightMenu = 0;
double widthMenu = 0;
double heightPickerContainer = 90; double heightPickerContainer = 90;
double mainBottomMenuMap = Get.height * .2; double mainBottomMenuMap = Get.height * .2;
bool heightMenuBool = false; bool heightMenuBool = false;
@@ -99,6 +103,7 @@ class MapController extends GetxController {
void getDrawerMenu() { void getDrawerMenu() {
heightMenuBool = !heightMenuBool; heightMenuBool = !heightMenuBool;
heightMenu = heightMenuBool == true ? 100 : 0; heightMenu = heightMenuBool == true ? 100 : 0;
widthMenu = heightMenuBool == true ? 110 : 0;
update(); update();
} }
@@ -197,6 +202,9 @@ class MapController extends GetxController {
isMainBottomMenuMap = !isMainBottomMenuMap; isMainBottomMenuMap = !isMainBottomMenuMap;
mainBottomMenuMap = mainBottomMenuMap =
isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .66; isMainBottomMenuMap == true ? Get.height * .2 : Get.height * .66;
if (heightMenuBool == true) {
getDrawerMenu();
}
update(); update();
} }
@@ -430,7 +438,7 @@ class MapController extends GetxController {
String duratioByPassenger = ''; String duratioByPassenger = '';
void getNearestDriverByPassengerLocation() async { void getNearestDriverByPassengerLocation() async {
if (polylines.isEmpty) { if (polylines.isEmpty || data.isEmpty) {
double nearestDistance = double.infinity; double nearestDistance = double.infinity;
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) { for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
var carLocation = dataCarsLocationByPassenger['message'][i]; var carLocation = dataCarsLocationByPassenger['message'][i];
@@ -536,16 +544,18 @@ class MapController extends GetxController {
getDistanceFromText(data[0]['distance']['text']); getDistanceFromText(data[0]['distance']['text']);
// Animate the camera to the adjusted bounds // Animate the camera to the adjusted bounds
if (distanceOfDestnation <= 10) { if (distanceOfDestnation <= 5) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14));
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 13));
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12)); mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12));
} else if (distanceOfDestnation > 10 && distanceOfDestnation < 16) { } else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11)); mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
} else if (distanceOfDestnation > 16 && distanceOfDestnation < 30) { } else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10)); mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
} else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) { } else if (distanceOfDestnation >= 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8)); mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 7));
} else if (distanceOfDestnation > 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6));
} }
if (polylines.isNotEmpty) { if (polylines.isNotEmpty) {
clearpolyline(); clearpolyline();
@@ -579,6 +589,17 @@ class MapController extends GetxController {
CRUD().get(link: AppLink.getPassengersPromo, payload: { CRUD().get(link: AppLink.getPassengersPromo, payload: {
'promo_code': promo.text, 'promo_code': promo.text,
}).then((value) { }).then((value) {
if (value == 'failure') {
Get.defaultDialog(
title: 'Promo End !'.tr,
confirm: MyElevatedButton(
title: 'Back',
onPressed: () {
Get.back();
Get.back();
},
));
}
var decod = jsonDecode(value); var decod = jsonDecode(value);
if (decod["status"] == "success") { if (decod["status"] == "success") {
@@ -589,6 +610,7 @@ class MapController extends GetxController {
promoTaken = true; promoTaken = true;
update(); update();
print(totalPassenger); print(totalPassenger);
Get.back();
} }
}); });
} }

View File

@@ -3,11 +3,13 @@ import 'package:get/get.dart';
import '../../constant/box_name.dart'; import '../../constant/box_name.dart';
import '../../main.dart'; import '../../main.dart';
import '../firebase/firbase_messge.dart';
import '../themes/themes.dart'; import '../themes/themes.dart';
class LocaleController extends GetxController { class LocaleController extends GetxController {
Locale? language; Locale? language;
void restartApp() {
runApp(const MyApp());
}
ThemeData appTheme = themeEnglish; ThemeData appTheme = themeEnglish;
@@ -35,6 +37,7 @@ class LocaleController extends GetxController {
box.write(BoxName.lang, langcode); box.write(BoxName.lang, langcode);
Get.changeTheme(appTheme); Get.changeTheme(appTheme);
Get.updateLocale(locale); Get.updateLocale(locale);
restartApp();
update(); update();
} }

View File

@@ -26,8 +26,7 @@ class PaymentController extends GetxController {
box.write(BoxName.passengerWalletFound, isWalletFound); box.write(BoxName.passengerWalletFound, isWalletFound);
// totalPassengerWalletDetails = box.read(BoxName.passengerWalletDetails); // totalPassengerWalletDetails = box.read(BoxName.passengerWalletDetails);
if (totalPassengerWalletDetails == null || if (totalPassengerWalletDetails.isEmpty) {
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) {
@@ -75,9 +74,8 @@ class PaymentController extends GetxController {
} }
@override @override
void onInit() async { void onInit() {
await getPassengerWallet(); getPassengerWallet();
super.onInit(); super.onInit();
} }
} }

View File

@@ -7,6 +7,7 @@ import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
import '../../../constant/style.dart'; import '../../../constant/style.dart';
import '../../../controller/functions/toast.dart';
import '../../../controller/home/map_page_controller.dart'; import '../../../controller/home/map_page_controller.dart';
GetBuilder<MapController> buttomSheetMapPage() { GetBuilder<MapController> buttomSheetMapPage() {
@@ -233,62 +234,70 @@ GetBuilder<MapController> buttomSheetMapPage() {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
Get if (controller
.defaultDialog( .promoTaken ==
title: 'Add Promo' false) {
.tr, Get.defaultDialog(
content: title: 'Add Promo'.tr,
Column( content: Column(
children: [ children: [
SizedBox( SizedBox(
width: Get.width * .7, width:
child: TextFormField( Get.width * .7,
controller: controller.promo, child:
decoration: InputDecoration( TextFormField(
labelText: 'Promo Code'.tr, controller: controller.promo,
hintText: 'Enter promo code'.tr, decoration: InputDecoration(
border: OutlineInputBorder( labelText: 'Promo Code'.tr,
borderRadius: BorderRadius.circular(10), hintText: 'Enter promo code'.tr,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
filled: true,
fillColor: Colors.grey[200],
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: AppColor.primaryColor,
width: 2.0,
), ),
filled: true, borderRadius: BorderRadius.circular(10),
fillColor: Colors.grey[200], ),
focusedBorder: OutlineInputBorder( errorBorder: OutlineInputBorder(
borderSide: const BorderSide( borderSide: const BorderSide(
color: AppColor.primaryColor, color: Colors.red,
width: 2.0, width: 2.0,
),
borderRadius: BorderRadius.circular(10),
), ),
errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide( ),
color: Colors.red, enabledBorder: OutlineInputBorder(
width: 2.0, borderSide: const BorderSide(
), color: Colors.grey,
borderRadius: BorderRadius.circular(10), width: 1.0,
),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.grey,
width: 1.0,
),
borderRadius: BorderRadius.circular(10),
), ),
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); },
} )
}, ],
) ));
], } else {
)); Get.snackbar(
'You have promo!'
.tr,
'',
backgroundColor:
AppColor
.redColor);
}
}, },
child: Text( child: Text(
'Add Promo'.tr, 'Add Promo'.tr,

View File

@@ -43,31 +43,32 @@ class MainBottomMenuMap extends StatelessWidget {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(15), padding: const EdgeInsets.all(15),
child: Container( child: InkWell(
width: Get.width * .8, onTap: () => controller.changeMainBottomMenuMap(),
height: Get.height * .1, child: Container(
decoration: const BoxDecoration( width: Get.width * .8,
boxShadow: [ height: Get.height * .1,
BoxShadow( decoration: const BoxDecoration(
color: AppColor.accentColor, boxShadow: [
blurRadius: 5, BoxShadow(
offset: Offset(2, 4)), color: AppColor.accentColor,
BoxShadow( blurRadius: 5,
color: AppColor.accentColor, offset: Offset(2, 4)),
blurRadius: 5, BoxShadow(
offset: Offset(-2, -2)) color: AppColor.accentColor,
], blurRadius: 5,
color: AppColor.secondaryColor, offset: Offset(-2, -2))
borderRadius: BorderRadius.all( ],
Radius.elliptical(15, 30), color: AppColor.secondaryColor,
borderRadius: BorderRadius.all(
Radius.elliptical(15, 30),
),
), ),
),
child: GestureDetector(
onTap: () => controller.changeMainBottomMenuMap(),
child: DefaultTextStyle( child: DefaultTextStyle(
style: AppStyle.title, style: AppStyle.title,
child: Center( child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
height: 30, height: 30,
@@ -88,16 +89,33 @@ class MainBottomMenuMap extends StatelessWidget {
}, },
), ),
), ),
Text('Nearest Car for you about '.tr + Row(
(controller.nearestCar != null mainAxisAlignment:
? controller.nearestCar!.duration MainAxisAlignment.center,
.toString() children: [
: 'N/A')) Text('Nearest Car for you about '.tr),
Container(
decoration: BoxDecoration(
border: Border.all(
color: AppColor.redColor,
width: 3)),
child: Padding(
padding: const EdgeInsets.all(4),
child: Text(
(controller.nearestCar != null
? controller
.duratioByPassenger
.toString()
: 'N/A')),
),
),
],
)
], ],
), ),
), ),
), )),
)), ),
), ),
controller.isMainBottomMenuMap controller.isMainBottomMenuMap
? const FavioratePlacesDialogu() ? const FavioratePlacesDialogu()

View File

@@ -1,5 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/views/home/my_wallet/passenger_wallet.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
import '../../../controller/home/map_page_controller.dart'; import '../../../controller/home/map_page_controller.dart';
@@ -16,76 +19,221 @@ class MapMenuWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<MapController>( return GetBuilder<MapController>(
builder: (controller) => Positioned( builder: (controller) => Stack(children: [
right: 60, Positioned(
left: 60, right: 60,
child: Padding( left: 60,
padding: const EdgeInsets.only(right: 20), child: Padding(
child: Opacity( padding: const EdgeInsets.only(right: 20),
alwaysIncludeSemantics: false, child: Opacity(
opacity: 0.99, // Adjust the opacity value as needed alwaysIncludeSemantics: false,
child: AnimatedContainer( opacity: 1, // Adjust the opacity value as needed
width: Get.width * .6, child: AnimatedContainer(
decoration: const BoxDecoration( width: Get.width * .6,
borderRadius: BorderRadius.all(Radius.circular(12)), decoration: const BoxDecoration(
color: AppColor.secondaryColor, borderRadius: BorderRadius.all(Radius.circular(12)),
boxShadow: [ color: AppColor.secondaryColor,
BoxShadow( boxShadow: [
color: AppColor.primaryColor, BoxShadow(
offset: Offset(-7, -7), color: AppColor.accentColor,
blurRadius: 0, offset: Offset(-3, -3),
spreadRadius: 0, blurRadius: 0,
blurStyle: BlurStyle.outer), spreadRadius: 0,
BoxShadow( blurStyle: BlurStyle.outer),
color: AppColor.accentColor, BoxShadow(
offset: Offset(3, 3), color: AppColor.accentColor,
blurRadius: 0, offset: Offset(3, 3),
spreadRadius: 0, blurRadius: 0,
blurStyle: BlurStyle.outer) spreadRadius: 0,
]), blurStyle: BlurStyle.outer)
transform: ]),
Matrix4.translationValues(controller.heightMenu * .1, 1, 1), transform: Matrix4.translationValues(
curve: Curves.easeOutCubic, controller.heightMenu * .1, 1, 1),
clipBehavior: Clip.hardEdge, curve: Curves.easeOutCubic,
duration: const Duration(milliseconds: 300), clipBehavior: Clip.hardEdge,
height: controller.heightMenu, duration: const Duration(milliseconds: 300),
child: controller.heightMenuBool height: controller.heightMenu,
? Row( child: controller.heightMenuBool
mainAxisAlignment: MainAxisAlignment.spaceAround, ? Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceAround,
IconWidgetMenu( children: [
IconWidgetMenu(
onpressed: () {
Get.to(
() => const NotificationPage(),
transition: Transition.circularReveal,
);
},
title: 'Notifications'.tr,
icon: Icons.notifications),
IconWidgetMenu(
onpressed: () { onpressed: () {
Get.to( Get.to(
() => const NotificationPage(), () => const PassengerProfilePage(),
transition: Transition.circularReveal, transition: Transition.zoom,
); );
}, },
title: 'Notifications'.tr, icon: Icons.person,
icon: Icons.notifications), title: 'Profile'.tr,
IconWidgetMenu( ),
onpressed: () { IconWidgetMenu(
Get.to( title: 'Home'.tr,
() => const PassengerProfilePage(), onpressed: () {
transition: Transition.zoom, Get.to(
); () => const HomePage(),
}, transition: Transition.downToUp,
icon: Icons.person, curve: Curves.easeInOutExpo,
title: 'Profile'.tr, );
), },
IconWidgetMenu( icon: Icons.home),
title: 'Home'.tr, ],
onpressed: () { )
Get.to( : const SizedBox(), // Choose the desired overlay color
() => const HomePage(), )),
transition: Transition.downToUp, ),
curve: Curves.easeInOutExpo, ),
); Positioned(
}, right: 5,
icon: Icons.home), top: 110,
], child: AnimatedContainer(
) duration: const Duration(milliseconds: 300),
: const SizedBox(), // Choose the desired overlay color decoration: const BoxDecoration(
)), borderRadius: BorderRadius.all(Radius.circular(12)),
color: AppColor.secondaryColor,
boxShadow: [
BoxShadow(
color: AppColor.accentColor,
offset: Offset(-3, -3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer),
BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer)
]),
width: controller.widthMenu,
height: Get.height * .3,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconMainPageMap(
onTap: () {
Get.to(() => const PassengerWallet());
},
title: 'My Wallet',
icon: Icons.wallet,
),
IconMainPageMap(
onTap: () {},
title: 'Order History',
icon: Icons.history,
),
IconMainPageMap(
onTap: () {},
title: 'Tariff',
icon: Icons.money,
),
],
),
)),
Positioned(
left: 5,
top: 110,
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)),
color: AppColor.secondaryColor,
boxShadow: [
BoxShadow(
color: AppColor.accentColor,
offset: Offset(-3, -3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer),
BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer)
]),
width: controller.widthMenu,
height: Get.height * .3,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconMainPageMap(
onTap: () {},
title: 'Settings',
icon: Icons.settings,
),
IconMainPageMap(
onTap: () {},
title: 'Feed Back',
icon: Icons.feedback,
),
IconMainPageMap(
onTap: () {},
title: 'Promos',
icon: Icons.monetization_on,
),
],
),
))
]),
);
}
}
class IconMainPageMap extends StatelessWidget {
const IconMainPageMap({
super.key,
required this.title,
required this.onTap,
required this.icon,
});
final String title;
final IconData icon;
final Callback onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(4),
child: Container(
width: double.maxFinite,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)),
color: AppColor.secondaryColor,
boxShadow: [
BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.outer,
),
],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Icon(icon),
Text(
title.tr,
style: AppStyle.subtitle,
),
],
),
),
), ),
), ),
); );

View File

@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/controller/payment/payment_controller.dart';
import 'package:ride/views/widgets/my_scafold.dart';
import '../../../constant/colors.dart';
class PassengerWallet extends StatelessWidget {
const PassengerWallet({super.key});
@override
Widget build(BuildContext context) {
Get.put(PaymentController());
return MyScafolld(
title: 'My Wallet',
isleading: true,
body: [
GetBuilder<PaymentController>(
builder: (controller) => Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)),
color: AppColor.secondaryColor,
boxShadow: [
BoxShadow(
color: AppColor.accentColor,
offset: Offset(-1, -1),
blurRadius: 0,
spreadRadius: 0,
blurStyle: BlurStyle.normal),
BoxShadow(
color: AppColor.accentColor,
offset: Offset(3, 3),
blurRadius: 1,
spreadRadius: 0,
blurStyle: BlurStyle.normal)
]),
child: Padding(
padding: const EdgeInsets.all(10),
child: Text(
'You Have ${controller.passengerTotalWalletAmount} JD in SEFER Wallet',
style: AppStyle.title,
),
),
),
],
),
],
),
)
],
);
}
}