added profil and kurir page in pengirim, added pengiriman page at kurir, sort the api, design the ui back
This commit is contained in:
@ -4,10 +4,12 @@ import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kurir/controller/after_login/kurir/pengaturanController.dart';
|
||||
|
||||
import 'package:socket_io_client/socket_io_client.dart';
|
||||
|
||||
import 'pengaturanController.dart';
|
||||
import 'pengirimanController.dart';
|
||||
|
||||
class KurirIndexController extends GetxController {
|
||||
late Socket socket;
|
||||
|
||||
@ -27,6 +29,15 @@ class KurirIndexController extends GetxController {
|
||||
|
||||
// Get.put(PengaturanKurirController());
|
||||
|
||||
break;
|
||||
case 1:
|
||||
final ctrl = Get.put<PengirimanKurirController>(
|
||||
PengirimanKurirController(),
|
||||
);
|
||||
ctrl.onInit();
|
||||
|
||||
// Get.put(PengaturanKurirController());
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@ -63,7 +74,8 @@ class KurirIndexController extends GetxController {
|
||||
),
|
||||
],
|
||||
currentIndex: _indexTap.value,
|
||||
selectedItemColor: const Color.fromARGB(255, 148, 183, 229),
|
||||
selectedItemColor: const Color.fromARGB(255, 2, 72, 72),
|
||||
unselectedItemColor: const Color.fromARGB(255, 199, 214, 234),
|
||||
onTap: (index) => _onItemTapped(index, context),
|
||||
);
|
||||
}
|
||||
|
||||
415
lib/controller/after_login/kurir/pengirimanController.dart
Normal file
415
lib/controller/after_login/kurir/pengirimanController.dart
Normal file
@ -0,0 +1,415 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
import 'dart:developer' as dev;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:kurir/function/allFunction.dart';
|
||||
|
||||
import '../../../api/kurirApi.dart';
|
||||
import '../../../api/pengirimApi.dart';
|
||||
import '../../../models/pengirimimanModel.dart';
|
||||
|
||||
import 'package:kurir/globals.dart' as globals;
|
||||
|
||||
class PengirimanKurirController extends GetxController {
|
||||
RxList pengirimanModelList = [].obs;
|
||||
RxInt loadPengiriman = 0.obs;
|
||||
|
||||
late GoogleMapController mapController;
|
||||
final Set<Marker> markers = {};
|
||||
final Set<Polyline> polylines = {};
|
||||
List<LatLng> _polylineCoordinates = [];
|
||||
final PolylinePoints _polylinePoints = PolylinePoints();
|
||||
final String _googleAPiKey = globals.api_key;
|
||||
|
||||
List<LatLng>? _listLatLng;
|
||||
|
||||
// late GoogleMapController mapController;
|
||||
final _initialCameraPosition = const CameraPosition(
|
||||
target: LatLng(-3.5621854706823193, 119.7612856634139),
|
||||
zoom: 12.5,
|
||||
);
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
dev.log("sini on ready pengiriman");
|
||||
pengirimanAll();
|
||||
}
|
||||
|
||||
pengirimanAll() async {
|
||||
loadPengiriman.value = 0;
|
||||
pengirimanModelList.value = [];
|
||||
Map<String, dynamic> _data =
|
||||
await KurirApi.getAllPengirimanDalamPengesahanKurir();
|
||||
|
||||
if (_data['status'] == 200) {
|
||||
if (_data['data'].length > 0) {
|
||||
pengirimanModelList.value =
|
||||
_data['data'].map((e) => PengirimanModel.fromJson(e)).toList();
|
||||
} else {
|
||||
pengirimanModelList.value = [];
|
||||
}
|
||||
loadPengiriman.value = 1;
|
||||
} else {
|
||||
pengirimanModelList.value = [];
|
||||
loadPengiriman.value = 2;
|
||||
}
|
||||
}
|
||||
|
||||
String timeZoneAdd8(time) {
|
||||
// add 8 hours to timezone
|
||||
// createdAt.add(Duration(hours: 8));
|
||||
// dev.log(createdAt.toString());
|
||||
var _time = DateTime.parse(time).add(const Duration(hours: 8));
|
||||
// dev.log(_time.toString());
|
||||
// seperate date and time
|
||||
var _date = _time.toString().split(" ")[0];
|
||||
var _time2 = _time.toString().split(" ")[1];
|
||||
// only take the hour and minute
|
||||
_time2 = _time2.split(":")[0] + ":" + _time2.split(":")[1];
|
||||
// if the hour is less than 10, add 0 before
|
||||
if (_time2.split(":")[0].length == 1) {
|
||||
_time2 = "0" + _time2;
|
||||
}
|
||||
// if the minute is less than 10, add 0 before
|
||||
if (_time2.split(":")[1].length == 1) {
|
||||
_time2 = _time2 + "0";
|
||||
}
|
||||
// if past 12:00, add "PM"
|
||||
if (int.parse(_time2.split(":")[0]) >= 12) {
|
||||
_time2 = _time2 + " PM";
|
||||
} else {
|
||||
_time2 = _time2 + " AM";
|
||||
}
|
||||
|
||||
return _date + " | " + _time2;
|
||||
}
|
||||
|
||||
String cekHarga(
|
||||
double distance, int biayaMinimal, int biayaMaksimal, int biayaPerKilo) {
|
||||
//
|
||||
double hargaPerKiloTotal = biayaPerKilo * distance;
|
||||
double hargaTotalMinimal = hargaPerKiloTotal + biayaMinimal;
|
||||
double hargaTotalMaksimal = hargaPerKiloTotal + biayaMaksimal;
|
||||
|
||||
return "Rp. " +
|
||||
AllFunction.thousandSeperatorDouble(hargaTotalMinimal) +
|
||||
" - Rp. " +
|
||||
AllFunction.thousandSeperatorDouble(hargaTotalMaksimal);
|
||||
}
|
||||
|
||||
cekDistance(LatLng latLngPengiriman, LatLng latLngPermulaan) async {
|
||||
dev.log("sini dia berlaku");
|
||||
PolylineResult _result = await _polylinePoints.getRouteBetweenCoordinates(
|
||||
_googleAPiKey,
|
||||
PointLatLng(latLngPermulaan.latitude, latLngPermulaan.longitude),
|
||||
PointLatLng(latLngPengiriman.latitude, latLngPengiriman.longitude),
|
||||
travelMode: TravelMode.driving,
|
||||
// travelMode: TravelMode.driving,
|
||||
);
|
||||
|
||||
// log(_result.points.toString() + "ini dia");
|
||||
if (_result.points.isNotEmpty) {
|
||||
double distance = await PengirimApi.jarak_route(
|
||||
latLngPermulaan.latitude,
|
||||
latLngPermulaan.longitude,
|
||||
latLngPengiriman.latitude,
|
||||
latLngPengiriman.longitude,
|
||||
);
|
||||
|
||||
dev.log(distance.toString() + "ini dia");
|
||||
|
||||
return distance;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void showMapDialog(BuildContext context, PengirimanModel data) async {
|
||||
await EasyLoading.show(
|
||||
status: 'Loading Peta...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
markers.clear();
|
||||
polylines.clear();
|
||||
_polylineCoordinates = [];
|
||||
_listLatLng = null;
|
||||
// _polylinePoints.clear();
|
||||
|
||||
LatLng _latLng_pengiriman = LatLng(
|
||||
double.parse(data.kordinatPengiriman!.lat!),
|
||||
double.parse(data.kordinatPengiriman!.lng!),
|
||||
);
|
||||
|
||||
LatLng _latLng_permulaan = LatLng(
|
||||
double.parse(data.kordinatPermulaan!.lat!),
|
||||
double.parse(data.kordinatPermulaan!.lng!),
|
||||
);
|
||||
|
||||
await setPolylines(
|
||||
_latLng_pengiriman,
|
||||
_latLng_permulaan,
|
||||
);
|
||||
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("permulaan"),
|
||||
position: LatLng(double.parse(data.kordinatPermulaan!.lat!),
|
||||
double.parse(data.kordinatPermulaan!.lng!)),
|
||||
infoWindow: const InfoWindow(
|
||||
title: "Lokasi Permulaan",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("pengiriman"),
|
||||
position: LatLng(double.parse(data.kordinatPengiriman!.lat!),
|
||||
double.parse(data.kordinatPengiriman!.lng!)),
|
||||
infoWindow: const InfoWindow(
|
||||
title: "LokasiPengiriman",
|
||||
),
|
||||
),
|
||||
);
|
||||
// await 1 sec
|
||||
// await Future.delayed(Duration(seconds: 1));
|
||||
Get.dialog(_MapDialogBox(
|
||||
data: data,
|
||||
onBounds: onBounds,
|
||||
markers: markers,
|
||||
polylines: polylines,
|
||||
initialCameraPosition: _initialCameraPosition,
|
||||
cekDistance: cekDistance,
|
||||
));
|
||||
|
||||
await EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
setPolylines(LatLng latLng_pengiriman, LatLng latLng_permulaan) async {
|
||||
PolylineResult _result = await _polylinePoints.getRouteBetweenCoordinates(
|
||||
_googleAPiKey,
|
||||
PointLatLng(latLng_permulaan.latitude, latLng_permulaan.longitude),
|
||||
PointLatLng(latLng_pengiriman.latitude, latLng_pengiriman.longitude),
|
||||
travelMode: TravelMode.driving,
|
||||
// travelMode: TravelMode.driving,
|
||||
);
|
||||
|
||||
// log(_result.points.toString() + "ini dia");
|
||||
if (_result.points.isNotEmpty) {
|
||||
// loop through all PointLatLng points and convert them
|
||||
// to a list of LatLng, required by the Polyline
|
||||
_listLatLng = [latLng_permulaan];
|
||||
for (var point in _result.points) {
|
||||
_polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
_listLatLng!.add(LatLng(point.latitude, point.longitude));
|
||||
}
|
||||
_listLatLng!.add(latLng_pengiriman);
|
||||
|
||||
Polyline polyline = Polyline(
|
||||
polylineId: const PolylineId("poly"),
|
||||
color: const Color.fromARGB(255, 40, 122, 198),
|
||||
points: _polylineCoordinates,
|
||||
width: 3,
|
||||
);
|
||||
polylines.add(polyline);
|
||||
}
|
||||
}
|
||||
|
||||
void onBounds(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
mapController.animateCamera(
|
||||
CameraUpdate.newLatLngBounds(
|
||||
AllFunction.computeBounds(_listLatLng!),
|
||||
15,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
lihat_foto_kiriman(BuildContext context, String fotoPengiriman) {
|
||||
if (fotoPengiriman != "") {
|
||||
Get.dialog(
|
||||
_FotoPengirimanDialogBox(
|
||||
fotoPengiriman: fotoPengiriman,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"Info",
|
||||
"Foto Barang Pengiriman Masih Dalam Proses Upload",
|
||||
icon: const Icon(
|
||||
Icons.info_outline_rounded,
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor: const Color.fromARGB(255, 71, 203, 240),
|
||||
duration: const Duration(seconds: 3),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _MapDialogBox extends StatelessWidget {
|
||||
const _MapDialogBox(
|
||||
{Key? key,
|
||||
required this.markers,
|
||||
required this.polylines,
|
||||
required this.onBounds,
|
||||
required this.initialCameraPosition,
|
||||
required this.cekDistance,
|
||||
required this.data})
|
||||
: super(key: key);
|
||||
|
||||
final Set<Marker> markers;
|
||||
final Set<Polyline> polylines;
|
||||
final void Function(GoogleMapController controller) onBounds;
|
||||
final CameraPosition initialCameraPosition;
|
||||
final PengirimanModel data;
|
||||
final Function cekDistance;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Color.fromARGB(255, 104, 164, 164),
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
child: GoogleMap(
|
||||
mapType: MapType.normal,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
markers: markers,
|
||||
polylines: polylines,
|
||||
// liteModeEnabled: true,
|
||||
initialCameraPosition: initialCameraPosition,
|
||||
onMapCreated: onBounds,
|
||||
// onCameraMove: _onCameraMove,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const SizedBox(),
|
||||
FutureBuilder(
|
||||
future: cekDistance(
|
||||
LatLng(double.parse(data.kordinatPengiriman!.lat!),
|
||||
double.parse(data.kordinatPengiriman!.lng!)),
|
||||
LatLng(double.parse(data.kordinatPermulaan!.lat!),
|
||||
double.parse(data.kordinatPermulaan!.lng!))),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Container(
|
||||
width: 200,
|
||||
child: TextFormField(
|
||||
enabled: false,
|
||||
style: TextStyle(color: Colors.white),
|
||||
initialValue: snapshot.data.toString() + " km",
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Jarak Pengiriman',
|
||||
labelStyle: TextStyle(color: Colors.white),
|
||||
filled: true,
|
||||
fillColor: Colors.transparent,
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.white,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(
|
||||
"Error mengambil data",
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.white,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox()
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FotoPengirimanDialogBox extends StatelessWidget {
|
||||
const _FotoPengirimanDialogBox({Key? key, required this.fotoPengiriman})
|
||||
: super(key: key);
|
||||
|
||||
final String fotoPengiriman;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: Color.fromARGB(255, 104, 164, 164),
|
||||
title: const Text(
|
||||
"Foto Pengiriman",
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
width: Get.width * 0.6,
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(20),
|
||||
),
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
spreadRadius: 1,
|
||||
blurRadius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(fotoPengiriman),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kurir/controller/after_login/pengirim/kirimBarangController.dart';
|
||||
import 'package:kurir/controller/after_login/pengirim/listKurirController.dart';
|
||||
import 'package:kurir/controller/after_login/pengirim/logKirimanController.dart';
|
||||
|
||||
class PengirimIndexController extends GetxController {
|
||||
@ -26,6 +27,12 @@ class PengirimIndexController extends GetxController {
|
||||
_init.onInit();
|
||||
}
|
||||
|
||||
if (index == 2) {
|
||||
// Get.lazyPut<KirimBarangController>(() => KirimBarangController());
|
||||
var _init = Get.put(ListKurirController());
|
||||
_init.onReady();
|
||||
}
|
||||
|
||||
_indexTap.value = index;
|
||||
}
|
||||
|
||||
@ -60,7 +67,7 @@ class PengirimIndexController extends GetxController {
|
||||
),
|
||||
],
|
||||
currentIndex: _indexTap.value,
|
||||
selectedItemColor: const Color.fromARGB(255, 148, 183, 229),
|
||||
selectedItemColor: const Color.fromARGB(255, 2, 72, 72),
|
||||
onTap: (index) => _onItemTapped(index, context),
|
||||
);
|
||||
}
|
||||
@ -68,7 +75,7 @@ class PengirimIndexController extends GetxController {
|
||||
_onItemTapped(int index, BuildContext context) {
|
||||
log("sini on item tapped");
|
||||
if (index == 3) {
|
||||
Get.offAllNamed('/profilePengirim');
|
||||
Get.offAndToNamed('/pengirimIndex/profilePengirim');
|
||||
}
|
||||
|
||||
_indexTap.value = index;
|
||||
|
||||
@ -0,0 +1,374 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names
|
||||
|
||||
import 'dart:developer' as dev;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:kurir/api/pengirimApi.dart';
|
||||
import 'package:kurir/function/allFunction.dart';
|
||||
import 'package:kurir/globals.dart' as globals;
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:kurir/models/pengirimimanModel.dart';
|
||||
|
||||
class InfoPengirimanController extends GetxController {
|
||||
final dynamic _argumicData = Get.arguments;
|
||||
late PengirimanModel pengirimanModel;
|
||||
// late String jumlah_pembayaran;
|
||||
String dummyTest = "heheheheh";
|
||||
|
||||
late GoogleMapController mapController;
|
||||
final _initialCameraPosition = const CameraPosition(
|
||||
target: LatLng(-3.5621854706823193, 119.7612856634139),
|
||||
zoom: 12.5,
|
||||
);
|
||||
final Set<Marker> _markers = {};
|
||||
final Set<Polyline> _polylines = {};
|
||||
final List<LatLng> _polylineCoordinates = [];
|
||||
final PolylinePoints _polylinePoints = PolylinePoints();
|
||||
final String _googleAPiKey = globals.api_key;
|
||||
|
||||
List<LatLng>? _listLatLng;
|
||||
TextEditingController distance_travel_controller = TextEditingController();
|
||||
TextEditingController price_controller = TextEditingController();
|
||||
|
||||
RxBool loadingMaps = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// ignore: todo
|
||||
// TODO: implement onInit
|
||||
pengirimanModel = _argumicData['pengiriman_model'];
|
||||
dev.log(" ini idnya ${pengirimanModel.fotoPengiriman}");
|
||||
distance_travel_controller.text = "loading...";
|
||||
price_controller.text = "loading...";
|
||||
set_the_maps(pengirimanModel.kordinatPengiriman!,
|
||||
pengirimanModel.kordinatPermulaan!);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
set_the_maps(KordinatPengiriman kordinat_pengiriman,
|
||||
KordinatPermulaan kordinat_permulaan) async {
|
||||
LatLng _latLng_pengiriman = LatLng(
|
||||
double.parse(kordinat_pengiriman.lat!),
|
||||
double.parse(kordinat_pengiriman.lng!),
|
||||
);
|
||||
|
||||
LatLng _latLng_permulaan = LatLng(
|
||||
double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!),
|
||||
);
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("permulaan"),
|
||||
position: LatLng(double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!)),
|
||||
infoWindow: const InfoWindow(
|
||||
title: "Lokasi Permulaan",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("pengiriman"),
|
||||
position: LatLng(double.parse(kordinat_pengiriman.lat!),
|
||||
double.parse(kordinat_pengiriman.lng!)),
|
||||
infoWindow: const InfoWindow(
|
||||
title: "LokasiPengiriman",
|
||||
),
|
||||
),
|
||||
);
|
||||
await setPolylines(
|
||||
_latLng_pengiriman,
|
||||
_latLng_permulaan,
|
||||
);
|
||||
}
|
||||
|
||||
setPolylines(LatLng latLng_pengiriman, LatLng latLng_permulaan) async {
|
||||
// dev.log("sini dia berlaku");
|
||||
PolylineResult _result = await _polylinePoints.getRouteBetweenCoordinates(
|
||||
_googleAPiKey,
|
||||
PointLatLng(latLng_permulaan.latitude, latLng_permulaan.longitude),
|
||||
PointLatLng(latLng_pengiriman.latitude, latLng_pengiriman.longitude),
|
||||
travelMode: TravelMode.driving,
|
||||
// travelMode: TravelMode.driving,
|
||||
);
|
||||
|
||||
// log(_result.points.toString() + "ini dia");
|
||||
if (_result.points.isNotEmpty) {
|
||||
// loop through all PointLatLng points and convert them
|
||||
// to a list of LatLng, required by the Polyline
|
||||
_listLatLng = [latLng_permulaan];
|
||||
for (var point in _result.points) {
|
||||
_polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
_listLatLng!.add(LatLng(point.latitude, point.longitude));
|
||||
}
|
||||
_listLatLng!.add(latLng_pengiriman);
|
||||
loadingMaps.value = true;
|
||||
// GoogleMapController _controller2;
|
||||
// _onBounds(_controller2);
|
||||
|
||||
Polyline polyline = Polyline(
|
||||
polylineId: const PolylineId("poly"),
|
||||
color: const Color.fromARGB(255, 40, 122, 198),
|
||||
points: _polylineCoordinates,
|
||||
width: 3,
|
||||
);
|
||||
_polylines.add(polyline);
|
||||
|
||||
double distance = await PengirimApi.jarak_route(
|
||||
latLng_permulaan.latitude,
|
||||
latLng_permulaan.longitude,
|
||||
latLng_pengiriman.latitude,
|
||||
latLng_pengiriman.longitude,
|
||||
);
|
||||
|
||||
// dev.log(distance.toString() + "ini dia");
|
||||
distance_travel_controller.text = "$distance km";
|
||||
double _min_price = distance * pengirimanModel.biaya!.biayaPerKilo! +
|
||||
pengirimanModel.biaya!.biayaMinimal!;
|
||||
// rounded to the nearest 1000
|
||||
_min_price = (_min_price / 1000).round() * 1000;
|
||||
double _max_price = distance * pengirimanModel.biaya!.biayaPerKilo! +
|
||||
pengirimanModel.biaya!.biayaMaksimal!;
|
||||
// rounded to the nearest 1000
|
||||
_max_price = (_max_price / 1000).round() * 1000;
|
||||
price_controller.text =
|
||||
"Rp. ${AllFunction.thousandSeperatorDouble(_min_price)} - Rp. ${AllFunction.thousandSeperatorDouble(_max_price)}";
|
||||
loadingMaps.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
show_maps_dialog() async {
|
||||
await EasyLoading.show(
|
||||
status: 'Loading Peta',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text("Rute Pengiriman"),
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
decoration: const BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
blurRadius: 10,
|
||||
spreadRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 200,
|
||||
maxHeight: 300,
|
||||
minWidth: 300,
|
||||
maxWidth: 500,
|
||||
),
|
||||
child: googleMaps(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
Widget googleMaps() {
|
||||
return GoogleMap(
|
||||
mapType: MapType.normal,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
markers: _markers,
|
||||
polylines: _polylines,
|
||||
// liteModeEnabled: true,
|
||||
initialCameraPosition: _initialCameraPosition,
|
||||
onMapCreated: _onBounds,
|
||||
// onCameraMove: _onCameraMove,
|
||||
);
|
||||
}
|
||||
|
||||
void _onBounds(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
if (_listLatLng != null)
|
||||
// ignore: curly_braces_in_flow_control_structures
|
||||
mapController.animateCamera(
|
||||
CameraUpdate.newLatLngBounds(
|
||||
AllFunction.computeBounds(_listLatLng!),
|
||||
15,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
show_kurir_dialog() {
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text("Detail Kurir"),
|
||||
content: SizedBox(
|
||||
height: Get.height * 0.5,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
blurRadius: 10, color: Colors.grey, spreadRadius: 5)
|
||||
],
|
||||
),
|
||||
child: CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundImage: const AssetImage('assets/loading.gif'),
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 50.0,
|
||||
backgroundImage: NetworkImage(
|
||||
pengirimanModel.kurir!.photo_url ??
|
||||
'https://via.placeholder.com/150'),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
spreadRadius: 1,
|
||||
blurRadius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
color: Colors.white,
|
||||
),
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: Image.network(
|
||||
pengirimanModel.kurir!.kenderaan_url ??
|
||||
"https://via.placeholder.com/150",
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
initialValue: "Rp. " +
|
||||
AllFunction.thousandsSeperator(
|
||||
pengirimanModel.biaya!.biayaMinimal!),
|
||||
// maxLength: 13,
|
||||
decoration: InputDecoration(
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.blue,
|
||||
),
|
||||
labelText: 'Harga Minimal',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
initialValue: "Rp. " +
|
||||
AllFunction.thousandsSeperator(
|
||||
pengirimanModel.biaya!.biayaMaksimal!),
|
||||
// maxLength: 13,
|
||||
decoration: InputDecoration(
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.blue,
|
||||
),
|
||||
labelText: 'Harga Maksimal',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
initialValue: "Rp. " +
|
||||
AllFunction.thousandsSeperator(
|
||||
pengirimanModel.biaya!.biayaPerKilo!),
|
||||
// maxLength: 13,
|
||||
decoration: InputDecoration(
|
||||
labelStyle: const TextStyle(
|
||||
color: Colors.blue,
|
||||
),
|
||||
labelText: 'Biaya Per Kilometer',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
show_foto_pengiriman() {
|
||||
Get.bottomSheet(
|
||||
SingleChildScrollView(
|
||||
child: Container(
|
||||
height: Get.height * 0.5,
|
||||
decoration: const BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(blurRadius: 10, color: Colors.grey, spreadRadius: 5)
|
||||
],
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(100),
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(pengirimanModel.fotoPengiriman ??
|
||||
"https://via.placeholder.com/150"),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names, invalid_use_of_protected_member
|
||||
// ignore_for_file: file_names, non_constant_identifier_names, invalid_use_of_protected_member, prefer_const_constructors
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
@ -28,6 +28,8 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../../../widgets/appbar.dart';
|
||||
|
||||
class KirimBarangController extends GetxController {
|
||||
//////// begin of marking delivery location ///////
|
||||
List<String> kelurahan_desa_list = []; //list for kelurahan desa
|
||||
@ -412,15 +414,19 @@ class KirimBarangController extends GetxController {
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
title: const Text('Pin Lokasi Pengiriman'),
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
],
|
||||
PreferredSize(
|
||||
preferredSize: Size.fromHeight(
|
||||
MediaQuery.of(context).size.height * 0.08),
|
||||
child: AppBarWidget(
|
||||
header: "Pin Lokasi Pengiriman",
|
||||
autoLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
SizedBox(
|
||||
@ -556,7 +562,7 @@ class KirimBarangController extends GetxController {
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
} else {
|
||||
WidgetsBinding.instance?.focusManager.primaryFocus
|
||||
WidgetsBinding.instance!.focusManager.primaryFocus
|
||||
?.unfocus();
|
||||
konfirmKelurahanDesaIndex = _pilihanKelurahanDesa;
|
||||
konfirmMarker = _markerPosition;
|
||||
@ -579,7 +585,10 @@ class KirimBarangController extends GetxController {
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: (_pilihanKelurahanDesa == 0)
|
||||
? Colors.grey
|
||||
: Colors.blue,
|
||||
: Color.fromARGB(255, 104, 164, 164),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -1373,7 +1382,7 @@ class KirimBarangController extends GetxController {
|
||||
ElevatedButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
WidgetsBinding.instance?.focusManager.primaryFocus?.unfocus();
|
||||
WidgetsBinding.instance!.focusManager.primaryFocus?.unfocus();
|
||||
|
||||
selectedKurirNama = kurirModel.nama!;
|
||||
kurirOutroTextController.text = kurirModel.nama!;
|
||||
@ -1716,15 +1725,19 @@ class KirimBarangController extends GetxController {
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
title: const Text('Pin Lokasi Permulaan'),
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
],
|
||||
PreferredSize(
|
||||
preferredSize: Size.fromHeight(
|
||||
MediaQuery.of(context).size.height * 0.08),
|
||||
child: AppBarWidget(
|
||||
header: "Pin Lokasi Permulaan",
|
||||
autoLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
SizedBox(
|
||||
@ -1821,26 +1834,26 @@ class KirimBarangController extends GetxController {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10),
|
||||
),
|
||||
child: Obx(
|
||||
() => GoogleMap(
|
||||
mapType:
|
||||
mapTypenya.value ? MapType.normal : MapType.hybrid,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
polygons: _polygons,
|
||||
markers: _markers,
|
||||
// liteModeEnabled: true,
|
||||
initialCameraPosition: _initialCameraPosition,
|
||||
onMapCreated: _onBounds,
|
||||
// onCameraMove: _onCameraMove,
|
||||
child: SizedBox(
|
||||
width: 400,
|
||||
height: 250,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Obx(
|
||||
() => GoogleMap(
|
||||
mapType: mapTypenya.value
|
||||
? MapType.normal
|
||||
: MapType.hybrid,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
polygons: _polygons,
|
||||
markers: _markers,
|
||||
// liteModeEnabled: true,
|
||||
initialCameraPosition: _initialCameraPosition,
|
||||
onMapCreated: _onBounds,
|
||||
// onCameraMove: _onCameraMove,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -1856,7 +1869,10 @@ class KirimBarangController extends GetxController {
|
||||
},
|
||||
child: const Text('Lokasi Sekarang'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.blue,
|
||||
primary: Color.fromARGB(255, 4, 103, 103),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@ -1873,7 +1889,7 @@ class KirimBarangController extends GetxController {
|
||||
_pilihanKelurahanDesa;
|
||||
}
|
||||
konfirmMarkerLokasiPermulaan = _markerPosition;
|
||||
WidgetsBinding.instance?.focusManager.primaryFocus
|
||||
WidgetsBinding.instance!.focusManager.primaryFocus
|
||||
?.unfocus();
|
||||
_check_jarak_tempuh();
|
||||
Get.back();
|
||||
@ -1912,7 +1928,10 @@ class KirimBarangController extends GetxController {
|
||||
primary: (_markerPosition == null &&
|
||||
konfirmMarkerLokasiPermulaan == null)
|
||||
? Colors.grey
|
||||
: Colors.blue,
|
||||
: Color.fromARGB(255, 104, 164, 164),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
37
lib/controller/after_login/pengirim/listKurirController.dart
Normal file
37
lib/controller/after_login/pengirim/listKurirController.dart
Normal file
@ -0,0 +1,37 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../api/pengirimApi.dart';
|
||||
import '../../../models/usersModel.dart';
|
||||
|
||||
class ListKurirController extends GetxController {
|
||||
RxList kurirModelList = [].obs;
|
||||
RxInt loadKurir = 0.obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
kurirAll();
|
||||
}
|
||||
|
||||
kurirAll() async {
|
||||
loadKurir.value = 0;
|
||||
kurirModelList.value = [];
|
||||
Map<String, dynamic> _data = await PengirimApi.getAllKurir();
|
||||
// dev.log(_data.toString());
|
||||
|
||||
if (_data['status'] == 200) {
|
||||
if (_data['data'].length > 0) {
|
||||
kurirModelList.value =
|
||||
_data['data'].map((e) => KurirModel.fromJson(e)).toList();
|
||||
} else {
|
||||
kurirModelList.value = [];
|
||||
}
|
||||
loadKurir.value = 1;
|
||||
} else {
|
||||
kurirModelList.value = [];
|
||||
loadKurir.value = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names
|
||||
// ignore_for_file: file_names, non_constant_identifier_names, sized_box_for_whitespace
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -22,13 +23,14 @@ class LogKirimanController extends GetxController {
|
||||
RxBool isPortrait = true.obs;
|
||||
|
||||
late GoogleMapController mapController;
|
||||
Set<Marker> _markers = {};
|
||||
Set<Polyline> _polylines = {};
|
||||
final Set<Marker> _markers = {};
|
||||
final Set<Polyline> _polylines = {};
|
||||
List<LatLng> _polylineCoordinates = [];
|
||||
PolylinePoints _polylinePoints = PolylinePoints();
|
||||
String _googleAPiKey = globals.api_key;
|
||||
final PolylinePoints _polylinePoints = PolylinePoints();
|
||||
final String _googleAPiKey = globals.api_key;
|
||||
|
||||
List<LatLng>? _listLatLng;
|
||||
double? _distance_travel;
|
||||
|
||||
// late GoogleMapController mapController;
|
||||
final _initialCameraPosition = const CameraPosition(
|
||||
@ -59,7 +61,7 @@ class LogKirimanController extends GetxController {
|
||||
|
||||
checkAllLogKiriman() async {
|
||||
Map<String, dynamic> _data = await PengirimApi.getLogKiriman();
|
||||
log(_data.toString());
|
||||
// log(_data.toString());
|
||||
// await 4 sec
|
||||
widgetLogKiriman.value = const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
@ -70,7 +72,7 @@ class LogKirimanController extends GetxController {
|
||||
|
||||
for (var item in _data['data']) {
|
||||
PengirimanModel? _pengirimanModel = PengirimanModel.fromJson(item);
|
||||
// log(_pengiriman.kurir!.id.toString());
|
||||
log(_pengirimanModel.createdAt.toString());
|
||||
_listWidget.add(_widgetLogKiriman(_pengirimanModel));
|
||||
|
||||
// _listWidget.add(_widgetLogKiriman());
|
||||
@ -102,8 +104,9 @@ class LogKirimanController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
_widgetLogKiriman(PengirimanModel? _pengirimanModel) {
|
||||
var _createdAtPlus8 = DateTime.parse(_pengirimanModel!.createdAt!)
|
||||
Widget _widgetLogKiriman(PengirimanModel _pengirimanModel) {
|
||||
log(_pengirimanModel.kurir.toString());
|
||||
var _createdAtPlus8 = DateTime.parse(_pengirimanModel.createdAt!)
|
||||
.add(const Duration(hours: 8));
|
||||
|
||||
String _tanggal = DateFormat('dd-MM-yyyy').format(_createdAtPlus8);
|
||||
@ -112,6 +115,7 @@ class LogKirimanController extends GetxController {
|
||||
String _jam = DateFormat('HH:mm:ss').format(_createdAtPlus8);
|
||||
|
||||
String _nama_kurir = _pengirimanModel.kurir!.nama!;
|
||||
// String _nama_kurir = "Nama";
|
||||
|
||||
String _status = _pengirimanModel.statusPengiriman!;
|
||||
|
||||
@ -132,8 +136,15 @@ class LogKirimanController extends GetxController {
|
||||
children: [
|
||||
SlidableAction(
|
||||
flex: 2,
|
||||
onPressed: (context) {},
|
||||
backgroundColor: const Color.fromARGB(255, 70, 192, 232),
|
||||
onPressed: (context) {
|
||||
Get.offAndToNamed(
|
||||
'/pengirimIndex/infoPengiriman',
|
||||
arguments: {
|
||||
'pengiriman_model': _pengirimanModel,
|
||||
},
|
||||
);
|
||||
},
|
||||
backgroundColor: const Color.fromARGB(255, 104, 164, 164),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.info_outline_rounded,
|
||||
label: 'Info',
|
||||
@ -143,7 +154,7 @@ class LogKirimanController extends GetxController {
|
||||
onPressed: (context) {
|
||||
_lihat_foto_kiriman(context, _foto_pengiriman);
|
||||
},
|
||||
backgroundColor: const Color.fromARGB(255, 71, 92, 250),
|
||||
backgroundColor: const Color.fromARGB(255, 4, 103, 103),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.photo_rounded,
|
||||
label: 'Barang Kiriman',
|
||||
@ -159,7 +170,7 @@ class LogKirimanController extends GetxController {
|
||||
_lihat_rute_pengiriman(
|
||||
context, _kordinat_pengiriman, _kordinat_permulaan);
|
||||
},
|
||||
backgroundColor: Color.fromARGB(255, 242, 78, 23),
|
||||
backgroundColor: const Color.fromARGB(255, 2, 72, 72),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.maps_home_work_rounded,
|
||||
label: "Rute Pengiriman",
|
||||
@ -234,7 +245,7 @@ class LogKirimanController extends GetxController {
|
||||
|
||||
_lihat_foto_kiriman(BuildContext context, String foto_pengiriman) {
|
||||
log(foto_pengiriman);
|
||||
if (foto_pengiriman != null && foto_pengiriman != "") {
|
||||
if (foto_pengiriman != "") {
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text("Foto Pengiriman"),
|
||||
@ -253,7 +264,7 @@ class LogKirimanController extends GetxController {
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
fit: BoxFit.cover,
|
||||
@ -276,12 +287,12 @@ class LogKirimanController extends GetxController {
|
||||
Get.snackbar(
|
||||
"Info",
|
||||
"Foto Barang Pengiriman Masih Dalam Proses Upload",
|
||||
icon: Icon(
|
||||
icon: const Icon(
|
||||
Icons.info_outline_rounded,
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor: Color.fromARGB(255, 71, 203, 240),
|
||||
duration: Duration(seconds: 3),
|
||||
backgroundColor: const Color.fromARGB(255, 71, 203, 240),
|
||||
duration: const Duration(seconds: 3),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
@ -291,6 +302,10 @@ class LogKirimanController extends GetxController {
|
||||
BuildContext context,
|
||||
KordinatPengiriman kordinat_pengiriman,
|
||||
KordinatPermulaan kordinat_permulaan) async {
|
||||
await EasyLoading.show(
|
||||
status: 'Loading Peta...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
_markers.clear();
|
||||
_polylines.clear();
|
||||
_polylineCoordinates = [];
|
||||
@ -306,16 +321,16 @@ class LogKirimanController extends GetxController {
|
||||
double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!),
|
||||
);
|
||||
_listLatLng = [
|
||||
LatLng(
|
||||
double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!),
|
||||
),
|
||||
LatLng(
|
||||
double.parse(kordinat_pengiriman.lat!),
|
||||
double.parse(kordinat_pengiriman.lng!),
|
||||
),
|
||||
];
|
||||
// _listLatLng = [
|
||||
// LatLng(
|
||||
// double.parse(kordinat_permulaan.lat!),
|
||||
// double.parse(kordinat_permulaan.lng!),
|
||||
// ),
|
||||
// LatLng(
|
||||
// double.parse(kordinat_pengiriman.lat!),
|
||||
// double.parse(kordinat_pengiriman.lng!),
|
||||
// ),
|
||||
// ];
|
||||
|
||||
await setPolylines(
|
||||
_latLng_pengiriman,
|
||||
@ -327,7 +342,7 @@ class LogKirimanController extends GetxController {
|
||||
markerId: const MarkerId("permulaan"),
|
||||
position: LatLng(double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!)),
|
||||
infoWindow: InfoWindow(
|
||||
infoWindow: const InfoWindow(
|
||||
title: "Lokasi Permulaan",
|
||||
),
|
||||
),
|
||||
@ -338,19 +353,19 @@ class LogKirimanController extends GetxController {
|
||||
markerId: const MarkerId("pengiriman"),
|
||||
position: LatLng(double.parse(kordinat_pengiriman.lat!),
|
||||
double.parse(kordinat_pengiriman.lng!)),
|
||||
infoWindow: InfoWindow(
|
||||
infoWindow: const InfoWindow(
|
||||
title: "LokasiPengiriman",
|
||||
),
|
||||
),
|
||||
);
|
||||
// await 1 sec
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
// await Future.delayed(Duration(seconds: 1));
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
child: GoogleMap(
|
||||
mapType: MapType.hybrid,
|
||||
mapType: MapType.normal,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
@ -362,8 +377,37 @@ class LogKirimanController extends GetxController {
|
||||
// onCameraMove: _onCameraMove,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const SizedBox(),
|
||||
Container(
|
||||
width: 200,
|
||||
child: TextFormField(
|
||||
initialValue: _distance_travel.toString() + " km",
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Jarak Pengiriman',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox()
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
await EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
setPolylines(LatLng latLng_pengiriman, LatLng latLng_permulaan) async {
|
||||
@ -375,17 +419,21 @@ class LogKirimanController extends GetxController {
|
||||
travelMode: TravelMode.driving,
|
||||
// travelMode: TravelMode.driving,
|
||||
);
|
||||
|
||||
// log(_result.points.toString() + "ini dia");
|
||||
if (_result.points.isNotEmpty) {
|
||||
// loop through all PointLatLng points and convert them
|
||||
// to a list of LatLng, required by the Polyline
|
||||
_result.points.forEach((PointLatLng point) {
|
||||
_listLatLng = [latLng_permulaan];
|
||||
for (var point in _result.points) {
|
||||
_polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
});
|
||||
_listLatLng!.add(LatLng(point.latitude, point.longitude));
|
||||
}
|
||||
_listLatLng!.add(latLng_pengiriman);
|
||||
|
||||
Polyline polyline = Polyline(
|
||||
polylineId: PolylineId("poly"),
|
||||
color: Color.fromARGB(255, 40, 122, 198),
|
||||
polylineId: const PolylineId("poly"),
|
||||
color: const Color.fromARGB(255, 40, 122, 198),
|
||||
points: _polylineCoordinates,
|
||||
width: 3,
|
||||
);
|
||||
@ -399,6 +447,7 @@ class LogKirimanController extends GetxController {
|
||||
);
|
||||
|
||||
log(distance.toString() + "ini dia");
|
||||
_distance_travel = distance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
// ignore: unused_import
|
||||
import 'dart:developer' as dev;
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kurir/api/beforeLoginAPI.dart';
|
||||
|
||||
class PengirimProfileController extends GetxController {
|
||||
String headerText = "Profil Pengirim";
|
||||
@override
|
||||
void onInit() {
|
||||
dev.log("sini on init profile pengirim");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
logout() async {
|
||||
await EasyLoading.show(
|
||||
status: 'Logout',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
|
||||
await BeforeLoginApi.logout();
|
||||
await EasyLoading.dismiss();
|
||||
Get.offAllNamed(
|
||||
'/index',
|
||||
arguments: {
|
||||
"tap": 0,
|
||||
"history": [0],
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user