151 lines
7.4 KiB
Dart
151 lines
7.4 KiB
Dart
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/views/widgets/my_scafold.dart';
|
|
import 'package:SEFER/views/widgets/mycircular.dart';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
import '../../../constant/colors.dart';
|
|
import '../../../controller/functions/launch.dart';
|
|
import '../../../controller/home/profile/order_history_controller.dart';
|
|
|
|
class OrderHistory extends StatelessWidget {
|
|
const OrderHistory({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Instantiate the OrderHistoryController class
|
|
Get.put(OrderHistoryController());
|
|
|
|
return MyScafolld(
|
|
title: 'Order History'.tr,
|
|
isleading: true,
|
|
body: [
|
|
GetBuilder<OrderHistoryController>(
|
|
builder: (orderHistoryController) => orderHistoryController.isloading
|
|
? const MyCircularProgressIndicator()
|
|
: orderHistoryController.orderHistoryListPassenger.isEmpty
|
|
? Center(
|
|
child: Text(
|
|
'No trip yet found'.tr,
|
|
style: AppStyle.headTitle2,
|
|
),
|
|
)
|
|
: ListView.builder(
|
|
itemCount: orderHistoryController
|
|
.orderHistoryListPassenger.length,
|
|
itemBuilder: (BuildContext context, int 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: 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(
|
|
initialCameraPosition: CameraPosition(
|
|
target: Get.find<
|
|
MapPassengerController>()
|
|
.passengerLocation, // Assuming passenger location is available
|
|
zoom: 15,
|
|
),
|
|
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(
|
|
rides['start_location']
|
|
.toString()
|
|
.split(',')[0]),
|
|
double.parse(
|
|
rides['start_location']
|
|
.toString()
|
|
.split(',')[1]),
|
|
),
|
|
LatLng(
|
|
double.parse(
|
|
rides['end_location']
|
|
.toString()
|
|
.split(',')[0]),
|
|
double.parse(
|
|
rides['end_location']
|
|
.toString()
|
|
.split(',')[1]),
|
|
)
|
|
],
|
|
color: AppColor.primaryColor,
|
|
width: 5,
|
|
),
|
|
},
|
|
),
|
|
),
|
|
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,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|