Files
tripz/lib/views/home/profile/order_history.dart
Hamza-Ayed 1352fc8b36 6/22/2
2024-06-22 13:30:50 +03:00

182 lines
9.6 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']}/';
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: LatLng(
(double.parse(
rides['start_location']
.toString()
.split(',')[0]) +
double.parse(
rides['end_location']
.toString()
.split(',')[0])) /
2,
(double.parse(
rides['start_location']
.toString()
.split(',')[1]) +
double.parse(
rides['end_location']
.toString()
.split(',')[1])) /
2,
),
zoom: 12,
),
// bounds: LatLngBounds(
// northeast: LatLng(
// double.parse(rides['end_location'].toString().split(',')[0]),
// double.parse(rides['end_location'].toString().split(',')[1]),
// ),
// southwest: LatLng(
// double.parse(rides['start_location'].toString().split(',')[0]),
// double.parse(rides['start_location'].toString().split(',')[1]),
// ),
// ),
zoomControlsEnabled: 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,
),
},
mapType: MapType.normal,
),
),
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.redColor)
: rides['status'] == 'Finished'.tr
? AppStyle.subtitle.copyWith(
color:
AppColor.greenColor)
: AppStyle.subtitle.copyWith(
color:
AppColor.yellowColor),
),
Text(
'${'Price is'.tr} ${rides['price']}',
style: AppStyle.subtitle,
),
],
),
],
),
),
),
),
);
},
),
)
],
);
}
}