207 lines
10 KiB
Dart
207 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:SEFER/constant/colors.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/controller/admin/passenger_admin_controller.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
import 'package:SEFER/views/widgets/my_scafold.dart';
|
|
import 'package:SEFER/views/widgets/my_textField.dart';
|
|
import 'package:SEFER/views/widgets/mycircular.dart';
|
|
|
|
import 'form_passenger.dart';
|
|
import 'passenger_details_page.dart';
|
|
|
|
class Passengrs extends StatelessWidget {
|
|
Passengrs({super.key});
|
|
final PassengerAdminController passengerAdminController =
|
|
Get.put(PassengerAdminController());
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MyScafolld(
|
|
title: 'Passengrs'.tr,
|
|
isleading: true,
|
|
body: [
|
|
GetBuilder<PassengerAdminController>(
|
|
builder: (passengerAdminController) => Column(
|
|
children: [
|
|
passengerAdminController.isLoading
|
|
? const MyCircularProgressIndicator()
|
|
: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(5),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
passengerAdmin(
|
|
passengerAdminController,
|
|
'Passengers Count',
|
|
'countPassenger',
|
|
),
|
|
MyElevatedButton(
|
|
title: 'Add Prize to Gold Passengers',
|
|
onPressed: () {
|
|
var date = DateTime.now();
|
|
var day = date.weekday;
|
|
|
|
if (day == 6) {
|
|
// Saturday is 6
|
|
print(day);
|
|
Get.defaultDialog(
|
|
title:
|
|
'Add Prize to Gold Passengers',
|
|
titleStyle: AppStyle.title,
|
|
content: Column(
|
|
children: [
|
|
Text(
|
|
'Add Points to their wallet as prize'
|
|
.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
Form(
|
|
key:
|
|
passengerAdminController
|
|
.formPrizeKey,
|
|
child: MyTextForm(
|
|
controller:
|
|
passengerAdminController
|
|
.passengerPrizeController,
|
|
label:
|
|
'Count of prize'
|
|
.tr,
|
|
hint: 'Count of prize'
|
|
.tr,
|
|
type: TextInputType
|
|
.number))
|
|
],
|
|
),
|
|
confirm: MyElevatedButton(
|
|
title: 'Add',
|
|
onPressed: () async {
|
|
if (passengerAdminController
|
|
.formPrizeKey
|
|
.currentState!
|
|
.validate()) {
|
|
passengerAdminController
|
|
.addPassengerPrizeToWalletSecure();
|
|
}
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
Get.defaultDialog(
|
|
title:
|
|
'This day is not allowed',
|
|
titleStyle: AppStyle.title,
|
|
middleText:
|
|
'Saturday only Allowed day',
|
|
middleTextStyle: AppStyle.title,
|
|
confirm: MyElevatedButton(
|
|
title: 'Ok'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
}));
|
|
}
|
|
})
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 10,
|
|
),
|
|
formSearchPassengers(),
|
|
SizedBox(
|
|
height: Get.height * .5,
|
|
child: ListView.builder(
|
|
itemCount: passengerAdminController
|
|
.passengersData['message'].length,
|
|
itemBuilder: (context, index) {
|
|
final user = passengerAdminController
|
|
.passengersData['message'][index];
|
|
|
|
return InkWell(
|
|
onTap: () {
|
|
Get.to(const PassengerDetailsPage(),
|
|
arguments: {
|
|
'data': user,
|
|
});
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(3),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(width: 2)),
|
|
child: ListTile(
|
|
title: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Name : ${user['first_name']} ${user['last_name']}',
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
'Rating : ${user['ratingPassenger']}',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
subtitle: Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Count Trip : ${user['countPassengerRide']}',
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
'Count Driver Rate : ${user['countDriverRate']}',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))
|
|
],
|
|
);
|
|
}
|
|
|
|
Container passengerAdmin(PassengerAdminController passengerAdminController,
|
|
String title, String jsonField) {
|
|
return Container(
|
|
height: Get.height * .1,
|
|
decoration: BoxDecoration(border: Border.all(width: 2)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: GestureDetector(
|
|
onTap: () {},
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
title.tr,
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
passengerAdminController.passengersData['message'][0][jsonField]
|
|
.toString(),
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|