502 lines
20 KiB
Dart
502 lines
20 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:SEFER/constant/box_name.dart';
|
|
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
|
import 'package:SEFER/views/notification/available_rides_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
|
import 'package:SEFER/views/home/Captin/home_captain/drawer_captain.dart';
|
|
import 'package:SEFER/views/widgets/mycircular.dart';
|
|
import 'package:bubble_head/bubble.dart';
|
|
|
|
import '../../../../constant/colors.dart';
|
|
import '../../../../constant/info.dart';
|
|
import '../../../../constant/style.dart';
|
|
import '../../../../controller/functions/location_controller.dart';
|
|
import '../../../../controller/functions/location_permission.dart';
|
|
import '../../../../controller/functions/overlay_permisssion.dart';
|
|
import '../../../../controller/functions/package_info.dart';
|
|
import '../../../../controller/home/captin/home_captain_controller.dart';
|
|
import '../../../../controller/home/captin/order_request_controller.dart';
|
|
import '../../../widgets/circle_container.dart';
|
|
import '../driver_map_page.dart';
|
|
import 'widget/connect.dart';
|
|
import 'widget/left_menu_map_captain.dart';
|
|
import '../../../../controller/home/payment/captain_wallet_controller.dart';
|
|
import '../../../../main.dart';
|
|
|
|
class HomeCaptain extends StatelessWidget {
|
|
HomeCaptain({super.key});
|
|
final LocationController locationController = Get.put(LocationController());
|
|
final HomeCaptainController homeCaptainController =
|
|
Get.put(HomeCaptainController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Get.put(OrderRequestController());
|
|
Get.put(HomeCaptainController());
|
|
Get.put(CaptainWalletController());
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
checkForUpdate(context);
|
|
getPermissionOverlay();
|
|
// getPermissionLocation1();
|
|
_showFirstTimeOfferNotification(context);
|
|
});
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
// backgroundColor: AppColor.accentColor,
|
|
elevation: 1,
|
|
title: Text('Home'.tr),
|
|
actions: [
|
|
GetBuilder<OrderRequestController>(
|
|
builder: (orderRequestController) => MyCircleContainer(
|
|
child: Text(
|
|
orderRequestController.countRefuse.toString(),
|
|
style: AppStyle.title,
|
|
))),
|
|
// IconButton(
|
|
// // onPressed: () => Get.find<OrderRequestController>().getSQL(),
|
|
// onPressed: () => sql.deleteAllData(TableName.driverOrdersRefuse),
|
|
// icon: const Icon(Icons.remove)),
|
|
// GetBuilder<OrderRequestController>(
|
|
// builder: (orderRequestController) => IconButton(
|
|
// onPressed: () =>
|
|
// orderRequestController.getRefusedOrderByCaptain(),
|
|
// icon: const Icon(Icons.get_app)),
|
|
// ),
|
|
],
|
|
),
|
|
drawer: CupertinoDrawerCaptain(),
|
|
body: Stack(
|
|
children: [
|
|
GetBuilder<HomeCaptainController>(
|
|
builder: (controller) => controller.isLoading
|
|
? const MyCircularProgressIndicator()
|
|
: GoogleMap(
|
|
onMapCreated: controller.onMapCreated,
|
|
// cameraTargetBounds: CameraTargetBounds(controller.boundsdata),
|
|
minMaxZoomPreference: const MinMaxZoomPreference(6, 18),
|
|
|
|
initialCameraPosition: CameraPosition(
|
|
target: locationController.myLocation,
|
|
zoom: 15,
|
|
),
|
|
|
|
mapType:
|
|
controller.mapType ? MapType.satellite : MapType.normal,
|
|
myLocationButtonEnabled: true,
|
|
// liteModeEnabled: true, tiltGesturesEnabled: false,
|
|
|
|
// indoorViewEnabled: true,
|
|
trafficEnabled: controller.mapTrafficON,
|
|
buildingsEnabled: true,
|
|
mapToolbarEnabled: true,
|
|
|
|
myLocationEnabled: true,
|
|
// liteModeEnabled: true,
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 10,
|
|
right: Get.width * .1,
|
|
left: Get.width * .1,
|
|
child: const ConnectWidget()),
|
|
Positioned(
|
|
top: 5,
|
|
right: Get.width * .05,
|
|
left: Get.width * .05,
|
|
child: GetBuilder<HomeCaptainController>(
|
|
builder: (homeCaptainController) => Container(
|
|
decoration: AppStyle.boxDecoration,
|
|
width: Get.width * .8,
|
|
height: 104,
|
|
child: Center(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Entypo.wallet,
|
|
color: AppColor.greenColor,
|
|
),
|
|
Text(
|
|
' You Earn today is '.tr +
|
|
homeCaptainController.totalMoneyToday,
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Entypo.wallet,
|
|
color: AppColor.yellowColor,
|
|
),
|
|
Text(
|
|
'${' You Have in'.tr} ${AppInformation.appName} ${homeCaptainController.totalMoneyInSEFER} ',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Text(
|
|
'Total Budget is '.tr +
|
|
Get.find<CaptainWalletController>().totalPoints,
|
|
style: AppStyle.title,
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(6),
|
|
color: int.parse(Get.find<HomeCaptainController>()
|
|
.countRideToday) <
|
|
5
|
|
? AppColor.accentColor
|
|
: int.parse(Get.find<HomeCaptainController>()
|
|
.countRideToday) >
|
|
5 &&
|
|
int.parse(Get.find<
|
|
HomeCaptainController>()
|
|
.countRideToday) <
|
|
10
|
|
? AppColor.yellowColor
|
|
: AppColor.greenColor,
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8, vertical: 2),
|
|
child: Text(
|
|
'Ride Today : '.tr +
|
|
Get.find<HomeCaptainController>()
|
|
.countRideToday,
|
|
style: AppStyle.title
|
|
.copyWith(color: AppColor.secondaryColor),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
))),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 65,
|
|
right: Get.width * .1,
|
|
left: Get.width * .1,
|
|
child: GetBuilder<HomeCaptainController>(
|
|
builder: (homeCaptainController) => Container(
|
|
decoration: AppStyle.boxDecoration,
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
'${'Active Duration:'.tr} ${homeCaptainController.stringActiveDuration} ',
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
'${'Total Connection Duration:'.tr} ${homeCaptainController.totalDurationToday} ',
|
|
style: AppStyle.title,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// Positioned(
|
|
// bottom: Get.height * .17,
|
|
// right: Get.width * .01,
|
|
// child: AnimatedContainer(
|
|
// duration: const Duration(microseconds: 200),
|
|
// width: Get.width * .12,
|
|
// decoration: BoxDecoration(
|
|
// color: AppColor.secondaryColor,
|
|
// border: Border.all(),
|
|
// borderRadius: BorderRadius.circular(15)),
|
|
// child: IconButton(
|
|
// onPressed: () async {
|
|
// CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
|
|
// 'startLocation': Get.find<MapDriverController>()
|
|
// .passengerLocation
|
|
// .toString(),
|
|
// 'endLocation': Get.find<MapDriverController>()
|
|
// .passengerDestination
|
|
// .toString(),
|
|
// 'name': Get.find<MapDriverController>().name.toString(),
|
|
// 'timeOfTrip':
|
|
// Get.find<MapDriverController>().timeOfOrder.toString(),
|
|
// 'fee': Get.find<MapDriverController>()
|
|
// .totalPassenger
|
|
// .toString(),
|
|
// 'duration':
|
|
// Get.find<MapDriverController>().duration.toString(),
|
|
// 'phone': Get.find<MapDriverController>().phone.toString(),
|
|
// 'email': Get.find<MapDriverController>().email.toString(),
|
|
// });
|
|
// },
|
|
// icon: const Icon(
|
|
// MaterialCommunityIcons.map_marker_radius,
|
|
// size: 45,
|
|
// color: AppColor.blueColor,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
Positioned(
|
|
bottom: Get.height * .2,
|
|
right: 6,
|
|
child: Column(
|
|
children: [
|
|
Platform.isAndroid
|
|
? AnimatedContainer(
|
|
duration: const Duration(microseconds: 200),
|
|
width: homeCaptainController.widthMapTypeAndTraffic,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: AppColor.blueColor),
|
|
color: AppColor.secondaryColor,
|
|
borderRadius: BorderRadius.circular(15)),
|
|
child: IconButton(
|
|
onPressed: () async {
|
|
// final Bubble _bubble = Bubble(showCloseButton: false);
|
|
// try {
|
|
// await _bubble.startBubbleHead(
|
|
// sendAppToBackground: false);
|
|
// } on PlatformException {
|
|
// print('Failed to call startBubbleHead');
|
|
// }
|
|
|
|
Bubble().startBubbleHead(sendAppToBackground: true);
|
|
},
|
|
icon: Image.asset(
|
|
'assets/images/logo1.png',
|
|
fit: BoxFit.cover,
|
|
width: 35,
|
|
height: 35,
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox(),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
AnimatedContainer(
|
|
duration: const Duration(microseconds: 200),
|
|
width: homeCaptainController.widthMapTypeAndTraffic,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: AppColor.blueColor),
|
|
color: AppColor.secondaryColor,
|
|
borderRadius: BorderRadius.circular(15)),
|
|
child: IconButton(
|
|
onPressed: () {
|
|
Get.to(() => const AvailableRidesPage());
|
|
},
|
|
icon: const Icon(
|
|
Icons.train_sharp,
|
|
size: 29,
|
|
color: AppColor.blueColor,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
height: 5,
|
|
),
|
|
box.read(BoxName.rideStatus) == 'Applied' ||
|
|
box.read(BoxName.rideStatus) == 'Begin'
|
|
? Positioned(
|
|
bottom: Get.height * .2,
|
|
right: 6,
|
|
child: AnimatedContainer(
|
|
duration: const Duration(microseconds: 200),
|
|
width: homeCaptainController.widthMapTypeAndTraffic,
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: AppColor.blueColor),
|
|
color: AppColor.secondaryColor,
|
|
borderRadius: BorderRadius.circular(15)),
|
|
child: IconButton(
|
|
onPressed: () {
|
|
box.read(BoxName.rideStatus) == 'Applied'
|
|
? {
|
|
Get.to(() => PassengerLocationMapPage(),
|
|
arguments:
|
|
box.read(BoxName.rideArguments)),
|
|
Get.put(MapDriverController())
|
|
.changeRideToBeginToPassenger()
|
|
}
|
|
: {
|
|
Get.to(() => PassengerLocationMapPage(),
|
|
arguments:
|
|
box.read(BoxName.rideArguments)),
|
|
Get.put(MapDriverController())
|
|
.startRideFromStartApp()
|
|
};
|
|
},
|
|
icon: const Icon(
|
|
Icons.rice_bowl,
|
|
size: 29,
|
|
color: AppColor.blueColor,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
: const SizedBox()
|
|
],
|
|
),
|
|
),
|
|
leftMainMenuCaptainIcons(),
|
|
|
|
// callPage(),
|
|
|
|
// Positioned(
|
|
// top: Get.height * .2,
|
|
// // left: 20,
|
|
// // right: 20,
|
|
// bottom: Get.height * .4,
|
|
// child: IconButton(
|
|
// onPressed: () {
|
|
// homeCaptainController.getCountRideToday();
|
|
// },
|
|
// icon: const Icon(Icons.call),
|
|
// ),
|
|
// ),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
void _showFirstTimeOfferNotification(BuildContext context) {
|
|
bool isFirstTime = _checkIfFirstTime();
|
|
|
|
if (isFirstTime) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return Dialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
elevation: 0,
|
|
backgroundColor: Colors.transparent,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.rectangle,
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Colors.black26,
|
|
blurRadius: 10.0,
|
|
offset: Offset(0.0, 10.0),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Text(
|
|
'Welcome Offer!'.tr,
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
const SizedBox(height: 15),
|
|
Text(
|
|
'As a new driver, you\'re eligible for a special offer!'.tr,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(fontSize: 16),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Stack(
|
|
children: <Widget>[
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: Colors.green,
|
|
borderRadius: BorderRadius.circular(15),
|
|
),
|
|
child: Text(
|
|
'3000 LE'.tr,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 25,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
right: -10,
|
|
top: -10,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(5),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.red,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.attach_money,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
Text(
|
|
'for your first registration!'.tr,
|
|
style: const TextStyle(fontSize: 16),
|
|
),
|
|
const SizedBox(height: 20),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.green,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20, vertical: 10),
|
|
child: Text(
|
|
"Get it Now!".tr,
|
|
style:
|
|
const TextStyle(fontSize: 18, color: Colors.white),
|
|
),
|
|
),
|
|
onPressed: () {
|
|
_markAsNotFirstTime();
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
bool _checkIfFirstTime() {
|
|
if (box.read(BoxName.isFirstTime).toString() == '') {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void _markAsNotFirstTime() {
|
|
box.write(BoxName.isFirstTime, 'false');
|
|
}
|