Files
tripz/lib/views/home/map_widget.dart/ride_begin_passenger.dart
Hamza Aleghwairyeen 88b671c112 4/10/2
2024-04-10 02:42:17 +03:00

250 lines
9.9 KiB
Dart

import 'package:SEFER/views/home/profile/feed_back_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/profile/profile_controller.dart';
import 'package:SEFER/main.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
import '../../../controller/functions/audio_recorder_controller.dart';
import '../../../controller/home/map_passenger_controller.dart';
class RideBeginPassenger extends StatelessWidget {
const RideBeginPassenger({
super.key,
});
@override
Widget build(BuildContext context) {
ProfileController profileController = Get.put(ProfileController());
AudioController audioController = Get.put(AudioController());
return GetBuilder<MapPassengerController>(builder: (controller) {
if ( //controller.rideTimerBegin ||
controller.statusRide == 'Begin' && !controller.statusRideFromStart) {
return Positioned(
left: 10,
right: 10,
bottom: 4,
child: Container(
decoration: AppStyle.boxDecoration,
height: controller.rideTimerBegin ? Get.height * .3 : 0,
// width: 100,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
width: Get.width * .15,
decoration: AppStyle.boxDecoration1,
child: Column(
children: [
Text(
'⏱️',
style: AppStyle.title,
),
Text(
controller.arrivalTime,
style: AppStyle.title,
),
],
),
),
Container(
width: Get.width * .15,
decoration: AppStyle.boxDecoration1,
child: Column(
children: [
Text(
'💵 ',
style: AppStyle.title,
),
Text(
controller.totalPassenger.toStringAsFixed(2),
style: AppStyle.title,
),
],
),
),
IconButton(
onPressed: () => Get.to(
() => FeedBackPage(),
transition: Transition.downToUp,
),
icon: const Icon(
Icons.note_add,
color: AppColor.redColor,
),
tooltip: ' Add Note', // Optional tooltip for clarity
),
audioController.isRecording == false
? IconButton(
onPressed: () async {
await audioController.startRecording();
},
icon: const Icon(
Icons.play_circle_fill_outlined,
color: AppColor.greenColor,
),
tooltip:
' Add Note', // Optional tooltip for clarity
)
: IconButton(
onPressed: () async {
await audioController.stopRecording();
},
icon: const Icon(
Icons.stop_circle,
color: AppColor.greenColor,
),
tooltip:
' Add Note', // Optional tooltip for clarity
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 30,
backgroundImage: NetworkImage(
'https://ride.mobile-app.store/portrate_captain_image/${controller.driverId}.jpg'),
),
Text(
controller.firstName,
style: AppStyle.title,
),
Column(
children: [
Text(
'${controller.driverRate} 📈',
style: AppStyle.title,
),
],
),
],
),
Stack(
children: [
// StreamCounter(),
LinearProgressIndicator(
backgroundColor: AppColor.accentColor,
color: controller.remainingTimeTimerRideBegin < 60
? AppColor.redColor
: AppColor.greenColor,
minHeight: 25,
borderRadius: BorderRadius.circular(15),
value: controller.progressTimerRideBegin.toDouble(),
),
Center(
child: Text(
controller.stringRemainingTimeRideBegin,
style: AppStyle.title,
),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconButton(
onPressed: () async {
if (box.read(BoxName.sosPhonePassenger) == null) {
{
await profileController.updatField(
'sosPhone', TextInputType.phone);
box.write(BoxName.sosPhonePassenger,
profileController.prfoileData['sosPhone']);
}
} else {
controller
.sendSMS(box.read(BoxName.sosPhonePassenger));
}
},
icon: const Icon(
Icons.sos_rounded,
color: AppColor.redColor,
),
),
IconButton(
onPressed: () async {
print(box.read(BoxName.sosPhonePassenger));
if (box.read(BoxName.sosPhonePassenger) == null ||
box.read(BoxName.sosPhonePassenger) == 'sos') {
{
await profileController.updatField(
'sosPhone', TextInputType.phone);
box.write(BoxName.sosPhonePassenger,
profileController.prfoileData['sosPhone']);
}
} else {
String phoneNumber =
box.read(BoxName.sosPhonePassenger).toString();
// phoneNumber = phoneNumber.replaceAll('0', '');
print(phoneNumber); // Output: 798583061
var phone =
// '+${box.read(BoxName.countryCode)}${box.read(BoxName.sosPhonePassenger)}';
'+20${box.read(BoxName.sosPhonePassenger)}';
controller.sendWhatsapp(phone);
}
},
icon: const Icon(
FontAwesome.whatsapp,
color: AppColor.greenColor,
),
),
],
)
],
),
),
),
);
} else {
return const SizedBox();
}
});
}
}
class StreamCounter extends StatelessWidget {
const StreamCounter({Key? key}) : super(key: key);
@override
// Build the UI based on the timer value
Widget build(BuildContext context) {
Get.put(MapPassengerController());
return GetBuilder<MapPassengerController>(builder: (controller) {
return StreamBuilder<int>(
initialData: 0,
stream: controller.timerController.stream,
builder: (context, snapshot) {
// Calculate the remaining time based on the current tick
final remainingTime = controller.durationToRide - snapshot.data!;
// Format the remaining time as a string
final formattedRemainingTime =
'${(remainingTime / 60).floor()}:${(remainingTime % 60).toString().padLeft(2, '0')}';
// Return the UI widgets based on the remaining time
return Column(
children: [
Text(formattedRemainingTime),
// ElevatedButton(
// onPressed: () {
// // Handle button press here
// },
// ),
],
);
},
);
});
}
}