This commit is contained in:
Hamza Aleghwairyeen
2024-04-18 00:53:16 +03:00
parent d450ad0f93
commit 1f333852ac
11 changed files with 493 additions and 255 deletions

View File

@@ -1,3 +1,4 @@
import 'package:SEFER/controller/functions/location_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/colors.dart';
@@ -5,6 +6,7 @@ import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/auth/captin/history_captain.dart';
import 'package:SEFER/controller/functions/launch.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../../widgets/mycircular.dart';
@@ -20,133 +22,181 @@ class HistoryDetailsPage extends StatelessWidget {
GetBuilder<HistoryCaptainController>(
builder: (historyCaptainController) {
var res = historyCaptainController.historyDetailsData['data'];
return Expanded(
child: historyCaptainController.isloading
? const MyCircularProgressIndicator()
: SingleChildScrollView(
child: Column(
children: [
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.blueColor, width: 2)),
child: TextButton(
onPressed: () {
String mapUrl =
'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/';
print(mapUrl);
showInBrowser(mapUrl);
},
child: Text(
'Trip on Map Click here'.tr,
style: AppStyle.title,
),
return historyCaptainController.isloading
? const MyCircularProgressIndicator()
: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.blueColor, width: 2)),
child: TextButton(
onPressed: () {
String mapUrl =
'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/';
print(mapUrl);
showInBrowser(mapUrl);
},
child: Column(
children: [
SizedBox(
height: Get.height * .2,
width: Get.width * .75,
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: Get.find<LocationController>()
.myLocation, // Assuming passenger location is available
tilt: 80, zoom: 13,
),
zoomControlsEnabled: true,
// liteModeEnabled: true,
polylines: {
Polyline(
zIndex: 2,
consumeTapEvents: true,
geodesic: true,
endCap: Cap.buttCap,
startCap: Cap.buttCap,
visible: true,
polylineId: const PolylineId('route'),
points: [
LatLng(
double.parse(res['start_location']
.toString()
.split(',')[0]),
double.parse(res['start_location']
.toString()
.split(',')[1]),
),
LatLng(
double.parse(res['end_location']
.toString()
.split(',')[0]),
double.parse(res['end_location']
.toString()
.split(',')[1]),
)
],
color: AppColor.primaryColor,
width: 5,
),
},
),
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Order ID'.tr} ${res['id']}',
style: AppStyle.title,
),
Text(
res['date'].toString(),
style: AppStyle.title,
),
],
),
],
),
),
const SizedBox(
height: 10,
),
Row(
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.greenColor, width: 2)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Order ID'.tr} ${res['id']}',
'${'Price is'.tr} ${res['price_for_driver']}',
style: AppStyle.title,
),
Text(
res['date'].toString(),
'${'Distance is'.tr} ${res['distance']} KM',
style: AppStyle.title,
),
],
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.greenColor, width: 2)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Price is'.tr} ${res['price_for_driver']}',
style: AppStyle.title,
),
Text(
'${'Distance is'.tr} ${res['distance']} KM',
style: AppStyle.title,
),
],
),
),
const SizedBox(
height: 10,
),
Text(
'Times of Trip'.tr,
style: AppStyle.title,
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.redColor, width: 2)),
child: Column(
children: [
Text(
'${'Time to Passenger is'.tr} ${res['DriverIsGoingToPassenger']}',
style: AppStyle.title,
),
Text(
'${'TimeStart is'.tr} ${res['rideTimeStart']}',
style: AppStyle.title,
),
Text(
'${'Time Finish is'.tr} ${res['rideTimeFinish']}',
style: AppStyle.title,
),
],
),
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.greenColor, width: 2)),
child: Center(
child: Text(
'${'Passenger Name is'.tr} ${res['first_name']} ${res['last_name']} ',
),
const SizedBox(
height: 10,
),
Text(
'Times of Trip'.tr,
style: AppStyle.title,
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.redColor, width: 2)),
child: Column(
children: [
Text(
'${'Time to Passenger is'.tr} ${res['DriverIsGoingToPassenger']}',
style: AppStyle.title,
),
),
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.yellowColor, width: 2)),
child: Center(
child: Text(
'${'Status is'.tr} ${res['status']}',
Text(
'${'TimeStart is'.tr} ${res['rideTimeStart']}',
style: AppStyle.title,
),
Text(
'${'Time Finish is'.tr} ${res['rideTimeFinish']}',
style: AppStyle.title,
),
],
),
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.greenColor, width: 2)),
child: Center(
child: Text(
'${'Passenger Name is'.tr} ${res['first_name']} ${res['last_name']} ',
style: AppStyle.title,
),
),
],
),
));
),
const SizedBox(
height: 10,
),
Container(
width: Get.width * .8,
decoration: BoxDecoration(
border: Border.all(
color: AppColor.yellowColor, width: 2)),
child: Center(
child: Text(
'${'Status is'.tr} ${res['status']}',
style: AppStyle.title,
),
),
),
],
),
),
);
})
],
isleading: true,

View File

@@ -1,5 +1,6 @@
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/controller/profile/setting_controller.dart';
import 'package:SEFER/views/home/profile/passenger_profile_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
@@ -25,13 +26,30 @@ class SettingsCaptain extends StatelessWidget {
'Language'.tr,
style: AppStyle.headTitle2,
),
subtitle: Text('ou can change the language of the app'.tr),
subtitle: Text('You can change the language of the app'.tr),
onTap: () => Get.to(const Language()),
),
const Divider(
endIndent: 44,
indent: 44,
),
ListTile(
leading: const Icon(Icons.place_outlined),
title: Text(
'Change Country'.tr,
style: AppStyle.headTitle2,
),
subtitle:
Text('You can change the Country to get all features'.tr),
onTap: () => Get.to(MyScafolld(
title: 'Change Country'.tr,
body: [CountryPickerFromSetting()],
isleading: true)),
),
const Divider(
endIndent: 44,
indent: 44,
),
ListTile(
leading: const Icon(
MaterialCommunityIcons.map_marker_radius,

View File

@@ -5,6 +5,8 @@ import 'package:SEFER/constant/style.dart';
import 'package:SEFER/views/lang/languages.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'profile/passenger_profile_page.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@@ -16,47 +18,57 @@ class HomePage extends StatelessWidget {
body: [
Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: ListTile(
title: Text(
'Settings'.tr,
style: AppStyle.title,
),
subtitle: Text('To change some Settings'.tr),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 30,
color: AppColor.primaryColor,
),
leading: const Icon(
Icons.settings,
color: AppColor.primaryColor,
),
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
// child: ListTile(
// title: Text(
// 'Settings'.tr,
// style: AppStyle.headTitle2,
// ),
// subtitle: Text('To change some Settings'.tr),
// trailing: const Icon(
// Icons.arrow_forward_ios,
// size: 30,
// color: AppColor.primaryColor,
// ),
// leading: const Icon(
// Icons.settings,
// color: AppColor.primaryColor,
// ),
// ),
// ),
ListTile(
onTap: () {
Get.to(() => const Language());
},
title: Text(
'Language'.tr,
style: AppStyle.headTitle2,
),
subtitle: Text('To change Language the App'.tr),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 30,
color: AppColor.primaryColor,
),
leading: const Icon(
Icons.language_sharp,
color: AppColor.primaryColor,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: ListTile(
onTap: () {
Get.to(() => const Language());
},
title: Text(
'Language'.tr,
style: AppStyle.title,
),
subtitle: Text('To change Languge the App'.tr),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 30,
color: AppColor.primaryColor,
),
leading: const Icon(
Icons.language_sharp,
color: AppColor.primaryColor,
),
ListTile(
leading: const Icon(Icons.place_outlined),
title: Text(
'Change Country'.tr,
style: AppStyle.headTitle2,
),
)
subtitle:
Text('You can change the Country to get all features'.tr),
onTap: () => Get.to(MyScafolld(
title: 'Change Country'.tr,
body: [CountryPickerFromSetting()],
isleading: true)),
),
],
),
],

View File

@@ -113,7 +113,7 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
borderRadius: BorderRadius.circular(15)),
child: IconButton(
onPressed: () async {
// await PaymobManager().payWithPayMob(100, 'EGP');
await PaymobManager().payWithPayMob(100, 'EGP');
// await Get.find<PaymentController>()
// .payWithPayMob(context, '1100', 'EGP');
// Initiates a payment with a card using the FlutterPaymob instance

View File

@@ -82,52 +82,55 @@ class CardSeferWallet extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Get.width * .85,
height: Get.height * .3,
decoration: BoxDecoration(
color: AppColor.deepPurpleAccent,
borderRadius: const BorderRadius.all(Radius.circular(12)),
gradient: const LinearGradient(
colors: [AppColor.blueColor, AppColor.primaryColor]),
return GetBuilder<PaymentController>(builder: (paymentController) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Get.width * .85,
height: Get.height * .3,
decoration: BoxDecoration(
color: AppColor.deepPurpleAccent,
borderRadius: const BorderRadius.all(Radius.circular(12)),
gradient: const LinearGradient(
colors: [AppColor.blueColor, AppColor.primaryColor]),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Text(
'${AppInformation.appName} Wallet',
style: AppStyle.headTitle
.copyWith(color: AppColor.primaryColor),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${box.read(BoxName.passengerWalletTotal)} \$' ??
'0.0 \$',
style: AppStyle.headTitle2,
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
box.read(BoxName.name),
style: AppStyle.title,
)
],
)
],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Text(
'${AppInformation.appName} Wallet',
style: AppStyle.headTitle
.copyWith(color: AppColor.primaryColor),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${box.read(BoxName.passengerWalletTotal)} \$' ?? '0.0 \$',
style: AppStyle.headTitle2,
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
box.read(BoxName.name),
style: AppStyle.title,
)
],
)
],
),
),
],
);
],
);
});
}
}

View File

@@ -64,7 +64,7 @@ class PassengerWalletDialoge extends StatelessWidget {
Text(
box.read(BoxName.countryCode) == 'Egypt'
? '100 ${'LE'.tr}'.tr
: '10\$ and get 3% discount',
: '10 ${'JOD'.tr}'.tr,
style: AppStyle.title,
),
],

View File

@@ -37,26 +37,29 @@ class OrderHistory extends StatelessWidget {
itemCount: orderHistoryController
.orderHistoryListPassenger.length,
itemBuilder: (BuildContext context, int index) {
final rides = orderHistoryController
.orderHistoryListPassenger[index];
// Use integer index here
final rides =
orderHistoryController.orderHistoryListPassenger[
index]; // Access data using index
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
String mapUrl =
'https://www.google.com/maps/dir/${rides['start_location']}/${rides['end_location']}/';
// print(mapUrl);
showInBrowser(mapUrl);
},
child: SizedBox(
child: InkWell(
onTap: () {
String mapUrl =
'https://www.google.com/maps/dir/${rides['start_location']}/${rides['end_location']}/';
// print(mapUrl);
showInBrowser(mapUrl);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SizedBox(
height: Get.height * .2,
width: Get.width * .75,
child: GoogleMap(
@@ -66,6 +69,8 @@ class OrderHistory extends StatelessWidget {
.passengerLocation, // Assuming passenger location is available
zoom: 15,
),
zoomControlsEnabled: true,
liteModeEnabled: true,
polylines: {
Polyline(
zIndex: 2,
@@ -78,15 +83,25 @@ class OrderHistory extends StatelessWidget {
const PolylineId('route'),
points: [
LatLng(
rides['start_location']
['latitude'],
rides['start_location']
['longitude']),
double.parse(
rides['start_location']
.toString()
.split(',')[0]),
double.parse(
rides['start_location']
.toString()
.split(',')[1]),
),
LatLng(
rides['end_location']
['latitude'],
rides['end_location']
['longitude']),
double.parse(
rides['end_location']
.toString()
.split(',')[0]),
double.parse(
rides['end_location']
.toString()
.split(',')[1]),
)
],
color: AppColor.primaryColor,
width: 5,
@@ -94,32 +109,35 @@ class OrderHistory extends StatelessWidget {
},
),
),
),
Column(
children: [
Text(
rides['date'],
style: AppStyle.subtitle,
),
Text(
rides['time'],
style: AppStyle.subtitle,
),
Text(
rides['status'],
style: rides['status'] != 'Canceled'.tr
? AppStyle.subtitle.copyWith(
color: AppColor.greenColor)
: AppStyle.subtitle.copyWith(
color: AppColor.redColor),
),
Text(
'${'Price is'.tr} ${rides['price']}',
style: AppStyle.subtitle,
),
],
),
],
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
rides['date'],
style: AppStyle.subtitle,
),
Text(
rides['time'],
style: AppStyle.subtitle,
),
Text(
rides['status'],
style: rides['status'] !=
'Canceled'.tr
? AppStyle.subtitle.copyWith(
color: AppColor.greenColor)
: AppStyle.subtitle.copyWith(
color: AppColor.redColor),
),
Text(
'${'Price is'.tr} ${rides['price']}',
style: AppStyle.subtitle,
),
],
),
],
),
),
),
),

View File

@@ -363,8 +363,10 @@ class CountryPicker extends StatelessWidget {
Get.find<LoginController>().saveCountryCode(controller
.selectedCountry
.toString()); // No conversion needed
box.write(BoxName.countryCode,
box.write(
BoxName.countryCode, //
controller.selectedCountry); // Already saved in English
Get.snackbar(controller.selectedCountry.toString().tr, '');
Get.off(LoginPage());
},
)
@@ -373,3 +375,80 @@ class CountryPicker extends StatelessWidget {
});
}
}
class CountryPickerFromSetting extends StatelessWidget {
final ProfileController controller = Get.put(ProfileController());
final LoginController loginController = Get.put(LoginController());
final List<String> countryOptions = [
'Jordan',
'USA',
'Egypt',
'Turkey',
'Saudi Arabia',
'Qatar',
'Bahrain',
'Kuwait',
];
CountryPickerFromSetting({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetBuilder<ProfileController>(builder: (controller) {
return ListView(
children: [
const SizedBox(
height: 20,
),
Text("Select Your Country".tr),
// const SizedBox(
// height: 20,
// ),
Padding(
padding: const EdgeInsets.all(10),
child: Text(
"To ensure you receive the most accurate information for your location, please select your country below. This will help tailor the app experience and content to your country."
.tr),
),
SizedBox(
height: 200,
child: CupertinoPicker(
itemExtent: 32,
onSelectedItemChanged: (int index) {
controller.setCountry(countryOptions[index]);
box.write(BoxName.countryCode,
countryOptions[index]); // Save in English
},
children: List.generate(
countryOptions.length,
(index) => Center(
child: Text(
countryOptions[index]
.tr, // Display translated if not English
style: AppStyle.title,
),
),
),
),
),
MyElevatedButton(
title: 'Select Country'.tr, // Use translated text for button
onPressed: () async {
loginController.saveCountryCode(controller.selectedCountry
.toString()); // No conversion needed
box.write(
BoxName.countryCode, //
controller.selectedCountry); // Already saved in English
Get.snackbar(controller.selectedCountry.toString().tr, '',
backgroundColor: AppColor.greenColor);
// Get.back();//
// Get.back();
},
)
],
);
});
}
}