11/1/9
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'dart:async';
|
||||
|
||||
@@ -15,13 +16,24 @@ class HomeCaptainController extends GetxController {
|
||||
Duration activeDuration = Duration.zero;
|
||||
Timer? activeTimer;
|
||||
Map data = {};
|
||||
bool isLoading = true;
|
||||
String totalMoneyToday = '0';
|
||||
String totalMoneyInSEFER = '0';
|
||||
String totalDurationToday = '0';
|
||||
Timer? timer;
|
||||
bool mapType = false;
|
||||
bool mapTrafficON = false;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
// Inject the LocationController class
|
||||
final locationController = Get.find<LocationController>();
|
||||
final locationController = Get.put(LocationController());
|
||||
String formatDuration(Duration duration) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, "0");
|
||||
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
|
||||
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
|
||||
return "${duration.inHours}:$twoDigitMinutes:$twoDigitSeconds";
|
||||
}
|
||||
|
||||
String stringActiveDuration = '';
|
||||
void onButtonSelected() {
|
||||
isActive = !isActive;
|
||||
if (isActive) {
|
||||
@@ -29,6 +41,7 @@ class HomeCaptainController extends GetxController {
|
||||
activeStartTime = DateTime.now();
|
||||
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
activeDuration = DateTime.now().difference(activeStartTime!);
|
||||
stringActiveDuration = formatDuration(activeDuration);
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
@@ -42,6 +55,27 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void changeMapType() {
|
||||
mapType = !mapType;
|
||||
// heightButtomSheetShown = isButtomSheetShown == true ? 240 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void changeMapTraffic() {
|
||||
mapTrafficON = !mapTrafficON;
|
||||
update();
|
||||
}
|
||||
|
||||
GoogleMapController? mapHomeCaptaiController;
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptaiController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(locationController.myLocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
final periods = box.read<List<dynamic>>(BoxName.periods) ?? [];
|
||||
periods.add(period.inSeconds);
|
||||
@@ -72,7 +106,9 @@ class HomeCaptainController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
addToken();
|
||||
onButtonSelected();
|
||||
getPaymentToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
super.onInit();
|
||||
}
|
||||
@@ -91,6 +127,16 @@ class HomeCaptainController extends GetxController {
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
totalMoneyToday = data['message'][0]['todayAmount'];
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
getAllPayment() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getAllPayment,
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
|
||||
totalMoneyInSEFER = data['message'][0]['total_amount'];
|
||||
update();
|
||||
}
|
||||
|
||||
75
lib/controller/home/captin/widget/left_menu_map_captain.dart
Normal file
75
lib/controller/home/captin/widget/left_menu_map_captain.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
|
||||
import '../../../../constant/colors.dart';
|
||||
import '../../../../views/Rate/ride_calculate_driver.dart';
|
||||
|
||||
GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
return GetBuilder<HomeCaptainController>(
|
||||
builder: (controller) => Positioned(
|
||||
bottom: Get.height * .17,
|
||||
left: 6,
|
||||
child: Column(
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
controller.changeMapType();
|
||||
// Toast.show(context, 'This is a toast message!');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.satellite_alt,
|
||||
size: 29,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
controller.changeMapTraffic();
|
||||
// Toast.show(context, 'This is a toast message!');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.streetview_sharp,
|
||||
size: 29,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Get.to(() => const RideCalculateDriver());
|
||||
},
|
||||
icon: const Icon(FontAwesome5.chart_bar),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class SplashScreenController extends GetxController
|
||||
: box.read(BoxName.emailDriver) == null
|
||||
? Get.off(() => LoginPage())
|
||||
: box.read(BoxName.emailDriver) != null
|
||||
? Get.off(() => const HomeCaptain())
|
||||
? Get.off(() => HomeCaptain())
|
||||
: Get.off(() => LoginCaptin());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user