another commit
This commit is contained in:
97
lib/controller/after_login/beforeEnterController.dart
Normal file
97
lib/controller/after_login/beforeEnterController.dart
Normal file
@ -0,0 +1,97 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
|
||||
import '../../api/beforeLoginAPI.dart';
|
||||
|
||||
class BeforeEnterController extends GetxController {
|
||||
final storage = GetStorage();
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
await EasyLoading.show(
|
||||
status: 'Loading...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
// wait 3 sec
|
||||
// await Future.delayed(const Duration(seconds: 3));
|
||||
// await EasyLoading.dismiss();
|
||||
log("sini on init before enter");
|
||||
cek_login();
|
||||
|
||||
// log(storage.read('role') + "ini role nya");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void cek_login() async {
|
||||
final _username =
|
||||
(storage.read('username') != null) ? storage.read('username') : "";
|
||||
final _password =
|
||||
(storage.read('password') != null) ? storage.read('password') : "";
|
||||
final _role = (storage.read('role') != null) ? storage.read('role') : "";
|
||||
|
||||
final _id = (storage.read('id') != null) ? storage.read('id') : "";
|
||||
|
||||
late bool _wrongPassword;
|
||||
|
||||
Map<String, dynamic> _data = await BeforeLoginApi.log_in_user(
|
||||
_username, _password, _role.toLowerCase());
|
||||
|
||||
switch (_data['status']) {
|
||||
case 200:
|
||||
_wrongPassword = true;
|
||||
break;
|
||||
case 400:
|
||||
_wrongPassword = false;
|
||||
break;
|
||||
default:
|
||||
_wrongPassword = false;
|
||||
break;
|
||||
}
|
||||
|
||||
log(_username.toString() + " ini usernamenya");
|
||||
log(_password.toString() + " ini passwordnya");
|
||||
log(_role.toString() + " ini role nya");
|
||||
log(_id.toString() + " ini id nya");
|
||||
|
||||
// await Future.delayed(const Duration(seconds: 3));
|
||||
await EasyLoading.dismiss();
|
||||
|
||||
if (!_wrongPassword) {
|
||||
storage.remove('username');
|
||||
storage.remove('password');
|
||||
storage.remove('role');
|
||||
|
||||
Get.offAllNamed(
|
||||
'/index',
|
||||
arguments: {
|
||||
"tap": 0,
|
||||
"history": [0],
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_role.toLowerCase() == "kurir") {
|
||||
Get.offAllNamed(
|
||||
'/kurirIndex',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_role.toLowerCase() == "pengirim") {
|
||||
Get.offAllNamed(
|
||||
'pengirimIndex',
|
||||
arguments: {
|
||||
"tap": 1,
|
||||
// "history": _historyIndex.value,
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
115
lib/controller/after_login/kurir/indexController.dart
Normal file
115
lib/controller/after_login/kurir/indexController.dart
Normal file
@ -0,0 +1,115 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
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';
|
||||
|
||||
class KurirIndexController extends GetxController {
|
||||
late Socket socket;
|
||||
|
||||
final Rx<int> _indexTap = 0.obs; // bottom navigation index tap
|
||||
|
||||
PageController pageController =
|
||||
PageController(initialPage: 0, keepPage: true);
|
||||
|
||||
pageChanged(int index) async {
|
||||
_indexTap.value = index;
|
||||
switch (index) {
|
||||
case 0:
|
||||
final ctrl = Get.put<PengaturanKurirController>(
|
||||
PengaturanKurirController(),
|
||||
);
|
||||
ctrl.onInit();
|
||||
|
||||
// Get.put(PengaturanKurirController());
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
log('KurirIndexController onInit');
|
||||
// final ctrl = Get.put(PengaturanKurirController());
|
||||
// ctrl.onInit();
|
||||
connectToServer();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
BottomNavigationBar bottomNavigationBar(context) {
|
||||
return BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Pengaturan',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.login),
|
||||
label: 'Pengiriman',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.app_registration),
|
||||
label: 'Log History',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Profile',
|
||||
),
|
||||
],
|
||||
currentIndex: _indexTap.value,
|
||||
selectedItemColor: const Color.fromARGB(255, 148, 183, 229),
|
||||
onTap: (index) => _onItemTapped(index, context),
|
||||
);
|
||||
}
|
||||
|
||||
_onItemTapped(int index, BuildContext context) {
|
||||
log("sini on item tapped");
|
||||
_indexTap.value = index;
|
||||
if (index == 3) {
|
||||
Get.offAllNamed('/profileKurir');
|
||||
}
|
||||
FocusScope.of(context).unfocus();
|
||||
// Get.delete<PengaturanKurirController>();
|
||||
|
||||
pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.ease);
|
||||
}
|
||||
|
||||
void connectToServer() async {
|
||||
log("sini connect to socket io");
|
||||
try {
|
||||
// Configure socket transports must be sepecified
|
||||
socket = io('http://192.168.43.125:3001/', <String, dynamic>{
|
||||
'transports': ['websocket'],
|
||||
'autoConnect': true,
|
||||
});
|
||||
|
||||
// Connect to websocket
|
||||
socket.connect();
|
||||
socket.onConnect((_) {
|
||||
log("sini connected");
|
||||
// socket.emit('join', 'kurir');
|
||||
});
|
||||
// Connect to websocket
|
||||
// socket.connect();
|
||||
socket.on('connect', (_) => log('connect asdasdsad: ${socket.id}'));
|
||||
socket.on('coba1', (_) => log(_.toString() + " ini coba2"));
|
||||
|
||||
log(socket.connected.toString());
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
log('tidak connect');
|
||||
}
|
||||
}
|
||||
|
||||
// onWillpop() async {
|
||||
// log("ini onWillpop");
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
114
lib/controller/after_login/kurir/pengaturanController.dart
Normal file
114
lib/controller/after_login/kurir/pengaturanController.dart
Normal file
@ -0,0 +1,114 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:kurir/api/kurirApi.dart';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kurir/models/kurirModel.dart';
|
||||
|
||||
class PengaturanKurirController extends GetxController {
|
||||
final storage = GetStorage();
|
||||
|
||||
var formKey = GlobalKey<FormState>(); // for form validation
|
||||
|
||||
Rx<String> status = ''.obs;
|
||||
|
||||
final minimalBiayaPengirimanController = TextEditingController();
|
||||
final maksimalBiayaPengirimanController = TextEditingController();
|
||||
final biayaPerKiloController = TextEditingController();
|
||||
|
||||
final FocusNode minimalBiayaPengirimanFocusNode = FocusNode();
|
||||
final FocusNode maksimalBiayaPengirimanFocusNode = FocusNode();
|
||||
final FocusNode biayaPerKiloFocusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
log("sini pengaturan controller");
|
||||
minimalBiayaPengirimanController.clear();
|
||||
|
||||
maksimalBiayaPengirimanController.clear();
|
||||
biayaPerKiloController.clear();
|
||||
log('ini idnya ' + storage.read('id'));
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
cek_datanya();
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
cek_datanya() async {
|
||||
await EasyLoading.show(
|
||||
status: 'Loading Data...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final result = await KurirApi.cekPengaturanKurir();
|
||||
|
||||
log(result.toString());
|
||||
if (result['status'] == 200 && result['data'] != null) {
|
||||
final PengaturanBiayaKurirModel pengaturanBiayaKurir =
|
||||
PengaturanBiayaKurirModel.fromJson(result['data']);
|
||||
minimalBiayaPengirimanController.text =
|
||||
thousandsSeperator(pengaturanBiayaKurir.minimalBiayaPengiriman!);
|
||||
maksimalBiayaPengirimanController.text =
|
||||
thousandsSeperator(pengaturanBiayaKurir.maksimalBiayaPengiriman!);
|
||||
biayaPerKiloController.text =
|
||||
thousandsSeperator(pengaturanBiayaKurir.biayaPerKilo!);
|
||||
|
||||
status.value = 'Ubah';
|
||||
} else {
|
||||
status.value = 'Simpan';
|
||||
}
|
||||
|
||||
await EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
simpan() async {
|
||||
// remove "," from text
|
||||
//get alert dialog
|
||||
|
||||
final minimalBiayaPengiriman =
|
||||
minimalBiayaPengirimanController.text.replaceAll(RegExp(r','), '');
|
||||
final maksimalBiayaPengiriman =
|
||||
maksimalBiayaPengirimanController.text.replaceAll(RegExp(r','), '');
|
||||
final biayaPerKilo =
|
||||
biayaPerKiloController.text.replaceAll(RegExp(r','), '');
|
||||
|
||||
// log(minimalBiayaPengiriman + " ini minimal biaya pengiriman");
|
||||
// log(maksimalBiayaPengiriman + " ini maksimal biaya pengiriman");
|
||||
// log(biayaPerKilo + " ini biaya per kilo");
|
||||
await EasyLoading.show(
|
||||
status: 'Pengaturan Biaya...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final result = await KurirApi.pengaturanKurir(
|
||||
minimalBiayaPengiriman, maksimalBiayaPengiriman, biayaPerKilo);
|
||||
|
||||
log(result.toString());
|
||||
onInit();
|
||||
await EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
coba() {
|
||||
log("sini coba terjadi");
|
||||
}
|
||||
|
||||
thousandsSeperator(int number) {
|
||||
final formatter = NumberFormat('#,###');
|
||||
final numbernya = formatter.format(number);
|
||||
// log(numbernya + " ini numbernya");
|
||||
return numbernya;
|
||||
}
|
||||
|
||||
removeComma(String number) {
|
||||
final numbernya = number.replaceAll(RegExp(r','), '');
|
||||
return int.parse(numbernya);
|
||||
}
|
||||
}
|
||||
32
lib/controller/after_login/kurir/profileController.dart
Normal file
32
lib/controller/after_login/kurir/profileController.dart
Normal file
@ -0,0 +1,32 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:kurir/api/beforeLoginAPI.dart';
|
||||
|
||||
class KurirProfileController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
log("sini profile kurir controller oninit");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
logout() async {
|
||||
await EasyLoading.show(
|
||||
status: 'Pengaturan Biaya...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
|
||||
await BeforeLoginApi.logout();
|
||||
await EasyLoading.dismiss();
|
||||
Get.offAllNamed(
|
||||
'/index',
|
||||
arguments: {
|
||||
"tap": 0,
|
||||
"history": [0],
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
82
lib/controller/after_login/pengirim/indexController.dart
Normal file
82
lib/controller/after_login/pengirim/indexController.dart
Normal file
@ -0,0 +1,82 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
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/logKirimanController.dart';
|
||||
|
||||
class PengirimIndexController extends GetxController {
|
||||
dynamic argumicData = Get.arguments;
|
||||
|
||||
final Rx<int> _indexTap = 0.obs; // bottom navigation index tap
|
||||
|
||||
late PageController pageController;
|
||||
|
||||
pageChanged(int index) async {
|
||||
// Get.delete<KirimBarangController>();
|
||||
if (index == 0) {
|
||||
var _init = Get.put(KirimBarangController());
|
||||
_init.onInit();
|
||||
// Get.lazyPut<KirimBarangController>(() => KirimBarangController());
|
||||
}
|
||||
if (index == 1) {
|
||||
var _init = Get.put(LogKirimanController());
|
||||
_init.onInit();
|
||||
}
|
||||
|
||||
_indexTap.value = index;
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
log("sini on init pengirim index");
|
||||
_indexTap.value = argumicData['tap'] ?? 0;
|
||||
pageController =
|
||||
PageController(initialPage: _indexTap.value, keepPage: true);
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
BottomNavigationBar bottomNavigationBar(context) {
|
||||
return BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.motorcycle_rounded),
|
||||
label: 'Kirim Barang',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.list_alt_rounded),
|
||||
label: 'Log Kiriman',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.people_alt_rounded),
|
||||
label: 'List Kurir',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.account_circle),
|
||||
label: 'Profile',
|
||||
),
|
||||
],
|
||||
currentIndex: _indexTap.value,
|
||||
selectedItemColor: const Color.fromARGB(255, 148, 183, 229),
|
||||
onTap: (index) => _onItemTapped(index, context),
|
||||
);
|
||||
}
|
||||
|
||||
_onItemTapped(int index, BuildContext context) {
|
||||
log("sini on item tapped");
|
||||
if (index == 3) {
|
||||
Get.offAllNamed('/profilePengirim');
|
||||
}
|
||||
|
||||
_indexTap.value = index;
|
||||
|
||||
FocusScope.of(context).unfocus();
|
||||
// Get.delete<PengaturanKurirController>();
|
||||
|
||||
pageController.animateToPage(index,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.ease);
|
||||
}
|
||||
}
|
||||
2264
lib/controller/after_login/pengirim/kirimBarangController.dart
Normal file
2264
lib/controller/after_login/pengirim/kirimBarangController.dart
Normal file
File diff suppressed because it is too large
Load Diff
414
lib/controller/after_login/pengirim/logKirimanController.dart
Normal file
414
lib/controller/after_login/pengirim/logKirimanController.dart
Normal file
@ -0,0 +1,414 @@
|
||||
// ignore_for_file: file_names, non_constant_identifier_names
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kurir/api/pengirimApi.dart';
|
||||
import 'package:kurir/function/allFunction.dart';
|
||||
import 'package:kurir/models/pengirimimanModel.dart';
|
||||
|
||||
import 'package:kurir/globals.dart' as globals;
|
||||
|
||||
class LogKirimanController extends GetxController {
|
||||
Rx<Widget> widgetLogKiriman = const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
).obs;
|
||||
|
||||
RxBool isPortrait = true.obs;
|
||||
|
||||
late GoogleMapController mapController;
|
||||
Set<Marker> _markers = {};
|
||||
Set<Polyline> _polylines = {};
|
||||
List<LatLng> _polylineCoordinates = [];
|
||||
PolylinePoints _polylinePoints = PolylinePoints();
|
||||
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 onInit() {
|
||||
// ignore: todo
|
||||
// TODO: implement onInit
|
||||
log("sini on init log kiriman");
|
||||
|
||||
checkAllLogKiriman();
|
||||
// BuildContext? context;
|
||||
log(Get.context!.isLandscape.toString() + " is landscape");
|
||||
log(Get.context!.isPortrait.toString() + " is potret");
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
checkScreenOrientation() {
|
||||
if (Get.context!.isLandscape) {
|
||||
isPortrait.value = false;
|
||||
} else {
|
||||
isPortrait.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
checkAllLogKiriman() async {
|
||||
Map<String, dynamic> _data = await PengirimApi.getLogKiriman();
|
||||
log(_data.toString());
|
||||
// await 4 sec
|
||||
widgetLogKiriman.value = const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
|
||||
if (_data['data'].length > 0) {
|
||||
List<Widget> _listWidget = [];
|
||||
|
||||
for (var item in _data['data']) {
|
||||
PengirimanModel? _pengirimanModel = PengirimanModel.fromJson(item);
|
||||
// log(_pengiriman.kurir!.id.toString());
|
||||
_listWidget.add(_widgetLogKiriman(_pengirimanModel));
|
||||
|
||||
// _listWidget.add(_widgetLogKiriman());
|
||||
}
|
||||
Widget _listview = Column(
|
||||
children: [
|
||||
..._listWidget,
|
||||
],
|
||||
);
|
||||
|
||||
widgetLogKiriman.value = Center(
|
||||
child: Obx(
|
||||
() => Container(
|
||||
constraints: BoxConstraints(
|
||||
// maxHeight: Get.height * 0.65,
|
||||
maxHeight:
|
||||
(isPortrait.value) ? Get.height * 0.62 : Get.height * 0.42,
|
||||
|
||||
minHeight: Get.context!.height * 0.42,
|
||||
),
|
||||
child: SingleChildScrollView(child: _listview),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
widgetLogKiriman.value = const Center(
|
||||
child: Text("Tidak ada log kiriman"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_widgetLogKiriman(PengirimanModel? _pengirimanModel) {
|
||||
var _createdAtPlus8 = DateTime.parse(_pengirimanModel!.createdAt!)
|
||||
.add(const Duration(hours: 8));
|
||||
|
||||
String _tanggal = DateFormat('dd-MM-yyyy').format(_createdAtPlus8);
|
||||
|
||||
// add am/pm to jam
|
||||
String _jam = DateFormat('HH:mm:ss').format(_createdAtPlus8);
|
||||
|
||||
String _nama_kurir = _pengirimanModel.kurir!.nama!;
|
||||
|
||||
String _status = _pengirimanModel.statusPengiriman!;
|
||||
|
||||
String _foto_pengiriman = _pengirimanModel.fotoPengiriman!;
|
||||
// log(_foto_pengiriman + " foto pengiriman");
|
||||
|
||||
var _kordinat_pengiriman = _pengirimanModel.kordinatPengiriman!;
|
||||
var _kordinat_permulaan = _pengirimanModel.kordinatPermulaan!;
|
||||
|
||||
Widget _listTilenya = Card(
|
||||
elevation: 2,
|
||||
child: Slidable(
|
||||
key: const ValueKey(1),
|
||||
startActionPane: ActionPane(
|
||||
motion: const DrawerMotion(),
|
||||
extentRatio: 0.80,
|
||||
// dismissible: DismissiblePane(onDismissed: () {}),
|
||||
children: [
|
||||
SlidableAction(
|
||||
flex: 2,
|
||||
onPressed: (context) {},
|
||||
backgroundColor: const Color.fromARGB(255, 70, 192, 232),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.info_outline_rounded,
|
||||
label: 'Info',
|
||||
),
|
||||
SlidableAction(
|
||||
flex: 3,
|
||||
onPressed: (context) {
|
||||
_lihat_foto_kiriman(context, _foto_pengiriman);
|
||||
},
|
||||
backgroundColor: const Color.fromARGB(255, 71, 92, 250),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.photo_rounded,
|
||||
label: 'Barang Kiriman',
|
||||
),
|
||||
],
|
||||
),
|
||||
endActionPane: ActionPane(
|
||||
motion: const DrawerMotion(),
|
||||
extentRatio: 0.5,
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (context) {
|
||||
_lihat_rute_pengiriman(
|
||||
context, _kordinat_pengiriman, _kordinat_permulaan);
|
||||
},
|
||||
backgroundColor: Color.fromARGB(255, 242, 78, 23),
|
||||
foregroundColor: Colors.white,
|
||||
icon: Icons.maps_home_work_rounded,
|
||||
label: "Rute Pengiriman",
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
" $_tanggal",
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
" $_jam",
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
_nama_kurir,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
_status,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
// fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return _listTilenya;
|
||||
}
|
||||
|
||||
_lihat_foto_kiriman(BuildContext context, String foto_pengiriman) {
|
||||
log(foto_pengiriman);
|
||||
if (foto_pengiriman != null && foto_pengiriman != "") {
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text("Foto Pengiriman"),
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
width: Get.width * 0.6,
|
||||
decoration: const BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey,
|
||||
spreadRadius: 1,
|
||||
blurRadius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/loading.gif'),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(foto_pengiriman),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"Info",
|
||||
"Foto Barang Pengiriman Masih Dalam Proses Upload",
|
||||
icon: Icon(
|
||||
Icons.info_outline_rounded,
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor: Color.fromARGB(255, 71, 203, 240),
|
||||
duration: Duration(seconds: 3),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_lihat_rute_pengiriman(
|
||||
BuildContext context,
|
||||
KordinatPengiriman kordinat_pengiriman,
|
||||
KordinatPermulaan kordinat_permulaan) async {
|
||||
_markers.clear();
|
||||
_polylines.clear();
|
||||
_polylineCoordinates = [];
|
||||
_listLatLng = null;
|
||||
// _polylinePoints.clear();
|
||||
|
||||
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!),
|
||||
);
|
||||
_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,
|
||||
_latLng_permulaan,
|
||||
);
|
||||
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("permulaan"),
|
||||
position: LatLng(double.parse(kordinat_permulaan.lat!),
|
||||
double.parse(kordinat_permulaan.lng!)),
|
||||
infoWindow: InfoWindow(
|
||||
title: "Lokasi Permulaan",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
_markers.add(
|
||||
Marker(
|
||||
markerId: const MarkerId("pengiriman"),
|
||||
position: LatLng(double.parse(kordinat_pengiriman.lat!),
|
||||
double.parse(kordinat_pengiriman.lng!)),
|
||||
infoWindow: InfoWindow(
|
||||
title: "LokasiPengiriman",
|
||||
),
|
||||
),
|
||||
);
|
||||
// await 1 sec
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
content: Container(
|
||||
height: Get.height * 0.5,
|
||||
child: GoogleMap(
|
||||
mapType: MapType.hybrid,
|
||||
mapToolbarEnabled: true,
|
||||
rotateGesturesEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
markers: _markers,
|
||||
polylines: _polylines,
|
||||
// liteModeEnabled: true,
|
||||
initialCameraPosition: _initialCameraPosition,
|
||||
onMapCreated: _onBounds,
|
||||
// onCameraMove: _onCameraMove,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
setPolylines(LatLng latLng_pengiriman, LatLng latLng_permulaan) async {
|
||||
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
|
||||
_result.points.forEach((PointLatLng point) {
|
||||
_polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
});
|
||||
|
||||
Polyline polyline = Polyline(
|
||||
polylineId: PolylineId("poly"),
|
||||
color: 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,
|
||||
);
|
||||
|
||||
log(distance.toString() + "ini dia");
|
||||
}
|
||||
}
|
||||
|
||||
void _onBounds(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
mapController.animateCamera(
|
||||
CameraUpdate.newLatLngBounds(
|
||||
AllFunction.computeBounds(_listLatLng!),
|
||||
15,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user