diff --git a/lib/api/kurirApi.dart b/lib/api/kurirApi.dart index c5978aa..3b3399a 100644 --- a/lib/api/kurirApi.dart +++ b/lib/api/kurirApi.dart @@ -15,6 +15,12 @@ import '../globals.dart' as globals; class KurirApi { static var client = http.Client(); + static var storage = GetStorage(); + + static var username = storage.read("username"); + static var password = storage.read("password"); + static var id = storage.read("id"); + static clientClose(http.Client client) { client.close(); } @@ -28,10 +34,6 @@ class KurirApi { bool _cek_jaringan = await cek_jaringan(client); log("cek jaringan : " + _cek_jaringan.toString()); - var storage = GetStorage(); - var username = storage.read("username"); - var password = storage.read("password"); - var id = storage.read("id"); if (!_cek_jaringan) { result = { @@ -88,10 +90,6 @@ class KurirApi { bool _cek_jaringan = await cek_jaringan(client); log("cek jaringan : " + _cek_jaringan.toString()); - var storage = GetStorage(); - var username = storage.read("username"); - var password = storage.read("password"); - var id = storage.read("id"); if (!_cek_jaringan) { result = { @@ -152,10 +150,6 @@ class KurirApi { bool _cek_jaringan = await cek_jaringan(client); log("cek jaringan : " + _cek_jaringan.toString()); - var storage = GetStorage(); - var username = storage.read("username"); - var password = storage.read("password"); - var id = storage.read("id"); if (!_cek_jaringan) { result = { 'status': 500, @@ -206,6 +200,180 @@ class KurirApi { return result; } + // terima pengiriman kurir dan ubah status ke 'Pengiriman Disahkan kurir' + static Future> sahkanPengiriman( + String? idPengiriman) async { + client = http.Client(); + late Map result; + bool _cek_jaringan = await cek_jaringan(client); + + // log("cek jaringan : " + _cek_jaringan.toString()); + + if (!_cek_jaringan) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } else { + // wait for 3 sec + // await Future.delayed(Duration(seconds: 3)); + // result = {'status': 200, 'message': "sini dia"}; + + try { + var response = await client.post( + Uri.parse( + "${globals.http_to_server}api/kurir/sahkan_pengiriman?username=$username&password=$password&id=$id"), + headers: { + "Accept": "application/json", + // "authorization": + // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}", + "crossDomain": "true" + }, + body: { + "id_pengiriman": idPengiriman + }).timeout(const Duration(seconds: 60)); + final data = jsonDecode(response.body); + // log(data.toString()); + // log("ini status : " + response.statusCode.toString()); + if (response.statusCode == 200) { + result = { + 'status': 200, + 'message': data['message'], + 'data': data['data'] + }; + } else { + result = { + 'status': response.statusCode, + 'message': data['message'], + 'data': data + }; + } + } catch (e) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } + } + + return result; + } + + static Future> detailPengiriman( + String idPengiriman) async { + client = http.Client(); + late Map result; + bool _cek_jaringan = await cek_jaringan(client); + if (!_cek_jaringan) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } else { + // wait for 3 sec + // await Future.delayed(Duration(seconds: 3)); + // result = {'status': 200, 'message': "sini dia"}; + try { + var response = await client.get( + Uri.parse( + "${globals.http_to_server}api/kurir/detail_pengiriman?username=$username&password=$password&id=$id&id_pengiriman=$idPengiriman"), + headers: { + "Accept": "application/json", + // "authorization": + // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}", + "crossDomain": "true" + }).timeout(const Duration(seconds: 60)); + final data = jsonDecode(response.body); + // log(data.toString()); + // log("ini status : " + response.statusCode.toString()); + if (response.statusCode == 200) { + result = { + 'status': 200, + 'message': data['message'], + 'data': data['data'] + }; + } else { + result = { + 'status': response.statusCode, + 'message': data['message'], + 'data': data + }; + } + } catch (e) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } + } + + return result; + } + + static Future> mengambilPaketPengiriman( + String? idPengiriman) async { + client = http.Client(); + late Map result; + bool _cek_jaringan = await cek_jaringan(client); + + // log("cek jaringan : " + _cek_jaringan.toString()); + + if (!_cek_jaringan) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } else { + // wait for 3 sec + // await Future.delayed(Duration(seconds: 3)); + // result = {'status': 200, 'message': "sini dia"}; + + try { + var response = await client.post( + Uri.parse( + "${globals.http_to_server}api/kurir/mengambil_paket_pengiriman?username=$username&password=$password&id=$id"), + headers: { + "Accept": "application/json", + // "authorization": + // "Basic ${base64Encode(utf8.encode("Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73"))}", + "crossDomain": "true" + }, + body: { + "id_pengiriman": idPengiriman + }).timeout(const Duration(seconds: 60)); + final data = jsonDecode(response.body); + // log(data.toString()); + // log("ini status : " + response.statusCode.toString()); + if (response.statusCode == 200) { + result = { + 'status': 200, + 'message': data['message'], + 'data': data['data'] + }; + } else { + result = { + 'status': response.statusCode, + 'message': data['message'], + 'data': data + }; + } + } catch (e) { + result = { + 'status': 500, + 'message': + "Tidak dapat terhubung ke server, Sila periksa koneksi internet anda" + }; + } + } + + return result; + } + // checking connection to server static Future cek_jaringan(http.Client client) async { late bool result; diff --git a/lib/binding/progressPenghantaranKurirBinding.dart b/lib/binding/progressPenghantaranKurirBinding.dart new file mode 100644 index 0000000..e9c9037 --- /dev/null +++ b/lib/binding/progressPenghantaranKurirBinding.dart @@ -0,0 +1,12 @@ +// ignore_for_file: file_names + +import 'package:get/get.dart'; + +import '../controller/after_login/kurir/progressPenghantaranController.dart'; + +class ProgressPenghantaranKurirBinding extends Bindings { + @override + void dependencies() { + Get.put(ProgressPenghantaranControllerKurir()); + } +} diff --git a/lib/controller/after_login/kurir/indexController.dart b/lib/controller/after_login/kurir/indexController.dart index 551c658..122cc47 100644 --- a/lib/controller/after_login/kurir/indexController.dart +++ b/lib/controller/after_login/kurir/indexController.dart @@ -84,7 +84,7 @@ class KurirIndexController extends GetxController { log("sini on item tapped"); _indexTap.value = index; if (index == 3) { - Get.offAllNamed('/profileKurir'); + Get.offAllNamed('/kurirIndex/profileKurir'); } FocusScope.of(context).unfocus(); // Get.delete(); diff --git a/lib/controller/after_login/kurir/pengirimanController.dart b/lib/controller/after_login/kurir/pengirimanController.dart index 17c1a75..e495faa 100644 --- a/lib/controller/after_login/kurir/pengirimanController.dart +++ b/lib/controller/after_login/kurir/pengirimanController.dart @@ -37,10 +37,18 @@ class PengirimanKurirController extends GetxController { @override void onReady() { super.onReady(); - dev.log("sini on ready pengiriman"); pengirimanAll(); } + @override + void dispose() { + super.dispose(); + mapController.dispose(); + _polylineCoordinates.clear(); + markers.clear(); + polylines.clear(); + } + pengirimanAll() async { loadPengiriman.value = 0; pengirimanModelList.value = []; @@ -61,35 +69,6 @@ class PengirimanKurirController extends GetxController { } } - 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) { // @@ -104,30 +83,16 @@ class PengirimanKurirController extends GetxController { } 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, + double distance = await PengirimApi.jarak_route( + latLngPermulaan.latitude, + latLngPermulaan.longitude, + latLngPengiriman.latitude, + latLngPengiriman.longitude, ); - // 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"); - dev.log(distance.toString() + "ini dia"); - - return distance; - } else { - return 0; - } + return distance; } void showMapDialog(BuildContext context, PengirimanModel data) async { @@ -141,19 +106,19 @@ class PengirimanKurirController extends GetxController { _listLatLng = null; // _polylinePoints.clear(); - LatLng _latLng_pengiriman = LatLng( + LatLng latLngPengiriman = LatLng( double.parse(data.kordinatPengiriman!.lat!), double.parse(data.kordinatPengiriman!.lng!), ); - LatLng _latLng_permulaan = LatLng( + LatLng latLngPermulaan = LatLng( double.parse(data.kordinatPermulaan!.lat!), double.parse(data.kordinatPermulaan!.lng!), ); await setPolylines( - _latLng_pengiriman, - _latLng_permulaan, + latLngPengiriman, + latLngPermulaan, ); markers.add( @@ -191,11 +156,11 @@ class PengirimanKurirController extends GetxController { await EasyLoading.dismiss(); } - setPolylines(LatLng latLng_pengiriman, LatLng latLng_permulaan) async { + setPolylines(LatLng latLngPengiriman, LatLng latLngPermulaan) async { PolylineResult _result = await _polylinePoints.getRouteBetweenCoordinates( _googleAPiKey, - PointLatLng(latLng_permulaan.latitude, latLng_permulaan.longitude), - PointLatLng(latLng_pengiriman.latitude, latLng_pengiriman.longitude), + PointLatLng(latLngPermulaan.latitude, latLngPermulaan.longitude), + PointLatLng(latLngPengiriman.latitude, latLngPengiriman.longitude), travelMode: TravelMode.driving, // travelMode: TravelMode.driving, ); @@ -204,12 +169,12 @@ class PengirimanKurirController extends GetxController { if (_result.points.isNotEmpty) { // loop through all PointLatLng points and convert them // to a list of LatLng, required by the Polyline - _listLatLng = [latLng_permulaan]; + _listLatLng = [latLngPermulaan]; for (var point in _result.points) { _polylineCoordinates.add(LatLng(point.latitude, point.longitude)); _listLatLng!.add(LatLng(point.latitude, point.longitude)); } - _listLatLng!.add(latLng_pengiriman); + _listLatLng!.add(latLngPengiriman); Polyline polyline = Polyline( polylineId: const PolylineId("poly"), @@ -231,7 +196,7 @@ class PengirimanKurirController extends GetxController { ); } - lihat_foto_kiriman(BuildContext context, String fotoPengiriman) { + lihatFotoKiriman(BuildContext context, String fotoPengiriman) { if (fotoPengiriman != "") { Get.dialog( _FotoPengirimanDialogBox( @@ -252,6 +217,257 @@ class PengirimanKurirController extends GetxController { ); } } + + void terimaPengiriman(String? sId) { + // dev.log("terima pengiriman"); + // create get alert dialog + Get.dialog( + _TerimaBatalPengiriman( + text: "terima", + id: sId, + ), + ); + } + + // coba() { + // loadPengiriman.value = 0; + // pengirimanModelList.clear(); + // dev.log(loadPengiriman.value.toString()); + // dev.log(pengirimanModelList.toString()); + // } + + konfirmTerimaPengiriman(String? id) async { + // dev.log("konfirm terima pengiriman $id"); + // coba(); + await EasyLoading.show( + status: 'Loading...', + maskType: EasyLoadingMaskType.black, + ); + Map _data = await KurirApi.sahkanPengiriman(id); + if (_data['status'] == 200) { + // loadPengiriman.value = 0; + Get.snackbar( + "Info", + "Pengiriman Disahkan Oleh Anda\nBisa Klik 'Mengambil Paket' jika ingin mengambil paket", + icon: const Icon( + Icons.info_outline_rounded, + color: Color.fromARGB(255, 2, 72, 72), + ), + backgroundColor: Colors.white, + duration: const Duration(seconds: 3), + snackPosition: SnackPosition.TOP, + ); + + // Get.back(); + // futre 1 sec + // await Future.delayed(Duration(seconds: 1)); + // loadPengiriman.value = 0; + // pengirimanModelList.value = []; + // await pengirimanAll(); + // onReady(); + final ctrl = Get.put( + PengirimanKurirController(), + ); + ctrl.onReady(); + } else { + Get.snackbar( + "Info", + _data['message'], + icon: const Icon( + Icons.info_outline_rounded, + color: Colors.red, + ), + backgroundColor: const Color.fromARGB(255, 199, 214, 234), + duration: const Duration(seconds: 3), + snackPosition: SnackPosition.TOP, + ); + } + + await EasyLoading.dismiss(); + } + + void batalkanPengiriman(String? sId) { + // Get + Get.dialog( + _TerimaBatalPengiriman( + text: "batalkan", + id: sId, + ), + ); + } + + void konfirmBatalPengiriman(String? id) { + dev.log("konfirm batal pengiriman $id"); + } + + void mengambilPaket(String? sId) { + // Get + Get.dialog( + _TerimaBatalPengiriman(id: sId, text: 'mengambil' // mengambil paket + ), + ); + } + + void konfirmasiMengambilPaket(String? id) async { + // dev.log("konfirm terima pengiriman $id"); + // coba(); + await EasyLoading.show( + status: 'Loading...', + maskType: EasyLoadingMaskType.black, + ); + Map _data = await KurirApi.mengambilPaketPengiriman(id); + if (_data['status'] == 200) { + // loadPengiriman.value = 0; + Get.snackbar( + "Info", + "Pengiriman Disahkan Oleh Anda\nBisa Klik 'Mengambil Paket' jika ingin mengambil paket", + icon: const Icon( + Icons.info_outline_rounded, + color: Color.fromARGB(255, 2, 72, 72), + ), + backgroundColor: Colors.white, + duration: const Duration(seconds: 3), + snackPosition: SnackPosition.TOP, + ); + + // Get.back(); + // futre 1 sec + // await Future.delayed(Duration(seconds: 1)); + // loadPengiriman.value = 0; + // pengirimanModelList.value = []; + // await pengirimanAll(); + // onReady(); + final ctrl = Get.put( + PengirimanKurirController(), + ); + ctrl.onReady(); + } else { + Get.snackbar( + "Info", + _data['message'], + icon: const Icon( + Icons.info_outline_rounded, + color: Colors.red, + ), + backgroundColor: const Color.fromARGB(255, 199, 214, 234), + duration: const Duration(seconds: 3), + snackPosition: SnackPosition.TOP, + ); + } + + await EasyLoading.dismiss(); + } +} + +class _TerimaBatalPengiriman extends StatelessWidget { + _TerimaBatalPengiriman({ + Key? key, + this.id, + required this.text, + }) : super(key: key); + + final PengirimanKurirController controller = PengirimanKurirController(); + final String? id; + final String text; + + @override + Widget build(BuildContext context) { + late String _text; + switch (text) { + case "terima": + _text = "Anda akan menyetujui permintaan pengiriman ini"; + break; + case "batalkan": + _text = "Anda akan membatalkan permintaan pengiriman ini"; + break; + case "mengambil": + _text = "Anda akan mengambil paket pengiriman ini?"; + break; + } + + return AlertDialog( + content: Container( + height: MediaQuery.of(context).size.height * 0.2, + alignment: Alignment.topCenter, + padding: const EdgeInsets.only(left: 10, right: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Text( + "Info", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox( + height: 10, + ), + Text( + _text, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 15, + ), + ), + const SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + SizedBox( + width: 75, + height: 40, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: (text != 'batalkan') + ? const Color.fromARGB(255, 2, 72, 72) + : Colors.red, + ), + onPressed: () { + Get.back(); + switch (text) { + case "terima": + controller.konfirmTerimaPengiriman(id); + break; + case "batalkan": + controller.konfirmBatalPengiriman(id); + break; + case "mengambil": + controller.konfirmasiMengambilPaket(id); + break; + } + + // if (text == 'terima') { + // controller.konfirmTerimaPengiriman(id); + // } else { + // controller.konfirmBatalPengiriman(id); + // } + }, + child: const Text("Ya"), + ), + ), + SizedBox( + width: 75, + height: 40, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: const Color.fromARGB(255, 104, 164, 164), + ), + onPressed: () { + Get.back(); + }, + child: const Text("Tidak"), + ), + ), + ], + ), + ], + ), + ), + ); + } } class _MapDialogBox extends StatelessWidget { @@ -275,8 +491,8 @@ class _MapDialogBox extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( - backgroundColor: Color.fromARGB(255, 104, 164, 164), - content: Container( + backgroundColor: const Color.fromARGB(255, 104, 164, 164), + content: SizedBox( height: Get.height * 0.5, child: GoogleMap( mapType: MapType.normal, @@ -304,15 +520,15 @@ class _MapDialogBox extends StatelessWidget { double.parse(data.kordinatPermulaan!.lng!))), builder: (context, snapshot) { if (snapshot.hasData) { - return Container( + return SizedBox( width: 200, child: TextFormField( enabled: false, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), initialValue: snapshot.data.toString() + " km", decoration: InputDecoration( labelText: 'Jarak Pengiriman', - labelStyle: TextStyle(color: Colors.white), + labelStyle: const TextStyle(color: Colors.white), filled: true, fillColor: Colors.transparent, disabledBorder: OutlineInputBorder( @@ -330,16 +546,16 @@ class _MapDialogBox extends StatelessWidget { ), ); } else if (snapshot.hasError) { - return Text( + return const Text( "Error mengambil data", - style: const TextStyle( + style: TextStyle( fontSize: 15, color: Colors.white, overflow: TextOverflow.ellipsis, ), ); } else { - return Center( + return const Center( child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation( Colors.white, @@ -369,7 +585,7 @@ class _FotoPengirimanDialogBox extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( - backgroundColor: Color.fromARGB(255, 104, 164, 164), + backgroundColor: const Color.fromARGB(255, 104, 164, 164), title: const Text( "Foto Pengiriman", style: TextStyle(color: Colors.white), @@ -399,13 +615,25 @@ class _FotoPengirimanDialogBox extends StatelessWidget { fit: BoxFit.cover, ), ), - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(fotoPengiriman), - fit: BoxFit.cover, - ), - ), + // child: Container( + // decoration: BoxDecoration( + // image: DecorationImage( + // image: NetworkImage(fotoPengiriman), + // fit: BoxFit.cover, + // ), + // ), + // ), + child: Image.network( + fotoPengiriman, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return const Center( + child: Icon( + Icons.error, + color: Colors.black, + ), + ); + }, ), ), ), diff --git a/lib/controller/after_login/kurir/progressPenghantaranController.dart b/lib/controller/after_login/kurir/progressPenghantaranController.dart new file mode 100644 index 0000000..a376316 --- /dev/null +++ b/lib/controller/after_login/kurir/progressPenghantaranController.dart @@ -0,0 +1,281 @@ +// ignore_for_file: file_names + +import 'dart:developer' as dev; + +import 'package:enhance_stepper/enhance_stepper.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:kurir/function/allFunction.dart'; +import 'package:kurir/models/pengirimimanModel.dart'; + +import '../../../api/kurirApi.dart'; + +class ProgressPenghantaranControllerKurir extends GetxController { + Rx text = "heheh".obs; + String id = Get.arguments; + Rx enhanceStepContainer = Container( + height: Get.height * 0.6, + width: double.infinity, + color: Colors.transparent, + child: const Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation(Colors.white), + ), + ), + ).obs; + RxInt currentStep = 0.obs; + + @override + void onInit() { + super.onInit(); + // text.value = "heheh222"; + dev.log("disini progress penghantaran bagian kurir berlaku"); + + // future 3 sec + getData(); + } + + void getData() async { + Map _data = await KurirApi.detailPengiriman(id); + if (_data["status"] == 200) { + final PengirimanModel _pengiriman = + PengirimanModel.fromJson(_data["data"]); + List _step = []; + var _history = _data["data"]["history"]; + currentStep.value = _history.length - 1; + for (var i = 0; i < _history.length; i++) { + final History _historyItem = History.fromJson(_history[i]); + _step.add( + _enhanceStepChild(_historyItem, _pengiriman), + ); + } + + enhanceStepContainer.value = Container( + height: Get.height * 0.6, + width: double.infinity, + color: Colors.transparent, + child: _EnhanceStepper(step: _step, currentStep: currentStep), + ); + } + } + + EnhanceStep _enhanceStepChild(History data, PengirimanModel pengiriman) { + late Icon _icon; + late Widget _title, _content; + Widget _subtitle = Text( + AllFunction.timeZoneAdd8(data.waktu), + style: const TextStyle( + color: Colors.white, + fontSize: 15, + ), + ); + switch (data.statusPengiriman) { + case "Dalam Pengesahan Kurir": + _icon = const Icon( + Icons.info_outline, + color: Colors.white, + size: 30, + ); + _title = const Text( + "Dalam Pengesahan Kurir", + style: TextStyle( + color: Colors.white, + fontSize: 20, + ), + ); + _content = Text( + "Pengirim melakukan pengiriman dan menunggu pengesahan kurir pada waktu ${AllFunction.timeZoneAdd8(data.waktu)}", + style: const TextStyle( + color: Colors.white, + fontSize: 15, + ), + ); + break; + case "Disahkan Kurir": + _icon = const Icon( + Icons.check_box, + color: Colors.white, + size: 30, + ); + _title = const Text( + "Disahkan Kurir", + style: TextStyle( + color: Colors.white, + fontSize: 20, + ), + ); + _content = Text( + "Kurir mengkonfirmasi pengiriman pada waktu ${AllFunction.timeZoneAdd8(data.waktu)}", + style: const TextStyle( + color: Colors.white, + fontSize: 15, + ), + ); + break; + case "Mengambil Paket Pengiriman Dari Pengirim": + _icon = const Icon( + Icons.motorcycle_outlined, + color: Colors.white, + size: 30, + ); + _title = const Text( + "Mengambil Paket Pengiriman Dari Pengirim", + style: TextStyle( + color: Colors.white, + fontSize: 20, + ), + ); + _content = const _MengambilPaketKirimanRichtext(); + break; + } + + return EnhanceStep( + icon: _icon, + title: _title, + subtitle: _subtitle, + content: _content, + isActive: true, + ); + } +} + +class _MengambilPaketKirimanRichtext extends StatelessWidget { + const _MengambilPaketKirimanRichtext({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + RichText( + textAlign: TextAlign.justify, + text: const TextSpan( + style: TextStyle( + color: Colors.white, + fontSize: 15, + ), + children: [ + TextSpan( + text: + "Dalam perjalanan mengambail paker dari pengirim. Klik "), + TextSpan( + text: "'Terima Paket Pengiriman' ", + style: TextStyle( + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + TextSpan(text: "jika sampai ke lokasi pengirim & scan "), + TextSpan( + text: "QRcode ", + style: TextStyle( + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + TextSpan(text: "yang ada pada aplikasi pengirim. Klik "), + TextSpan( + text: "'Rute Lokasi' ", + style: TextStyle( + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + TextSpan(text: "untuk melihat rute lokasi pengirim."), + ], + ), + ), + const SizedBox( + height: 10, + ), + SizedBox( + width: double.infinity, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + _ExpandedButton(flex: 2, text: 'Terima Paket\nPengiriman'), + Expanded(flex: 1, child: SizedBox()), + _ExpandedButton(flex: 2, text: 'Rute Lokasi'), + ], + ), + ), + ], + ); + } +} + +class _ExpandedButton extends StatelessWidget { + const _ExpandedButton({ + Key? key, + required this.text, + required this.flex, + }) : super(key: key); + + final String text; + final int flex; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: flex, + child: FittedBox( + child: SizedBox( + width: 100, + height: 35, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + ), + onPressed: () {}, + child: FittedBox( + child: Text( + text, + textAlign: TextAlign.center, + style: const TextStyle( + color: Color.fromARGB(255, 2, 72, 72), + ), + ), + ), + ), + ), + ), + ); + } +} + +class _EnhanceStepper extends StatelessWidget { + const _EnhanceStepper({ + Key? key, + required List step, + required this.currentStep, + }) : _step = step, + super(key: key); + + final List _step; + final RxInt currentStep; + + @override + Widget build(BuildContext context) { + return GetX( + init: ProgressPenghantaranControllerKurir(), + builder: (c) { + return EnhanceStepper( + stepIconSize: 30, + controlsBuilder: (BuildContext context, ControlsDetails details) { + return const SizedBox(); + }, + type: StepperType.vertical, + steps: _step, + currentStep: c.currentStep.value, + onStepTapped: (int index) { + c.currentStep.value = index; + }, + ); + }, + ); + } +} diff --git a/lib/controller/after_login/pengirim/infoPengirimanController.dart b/lib/controller/after_login/pengirim/infoPengirimanController.dart index 7936818..8ea061b 100644 --- a/lib/controller/after_login/pengirim/infoPengirimanController.dart +++ b/lib/controller/after_login/pengirim/infoPengirimanController.dart @@ -231,10 +231,26 @@ class InfoPengirimanController extends GetxController { backgroundColor: Colors.white, child: CircleAvatar( radius: 50.0, - backgroundImage: NetworkImage( - pengirimanModel.kurir!.photo_url ?? - 'https://via.placeholder.com/150'), + // backgroundImage: NetworkImage( + // pengirimanModel.kurir!.photo_url ?? + // 'https://via.placeholder.com/150'), backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + pengirimanModel.kurir!.photo_url ?? + 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, url, error) { + return const Center( + child: Icon( + Icons.error, + size: 20, + )); + }, + ), + ), ), ), ), @@ -265,6 +281,13 @@ class InfoPengirimanController extends GetxController { pengirimanModel.kurir!.kenderaan_url ?? "https://via.placeholder.com/150", fit: BoxFit.cover, + errorBuilder: (context, url, error) { + return const Center( + child: Icon( + Icons.error, + size: 20, + )); + }, ), ), ), @@ -357,16 +380,27 @@ class InfoPengirimanController extends GetxController { 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, - ), - ), + child: Image.network( + pengirimanModel.fotoPengiriman ?? "https://via.placeholder.com/150", + fit: BoxFit.cover, + errorBuilder: (context, url, error) { + return const Center( + child: Icon( + Icons.error, + size: 20, + )); + }, ), + // child: Container( + // decoration: BoxDecoration( + // // borderRadius: BorderRadius.circular(100), + // image: DecorationImage( + // image: NetworkImage(pengirimanModel.fotoPengiriman ?? + // "https://via.placeholder.com/150"), + // fit: BoxFit.fill, + // ), + // ), + // ), ), ), ); diff --git a/lib/controller/after_login/pengirim/kirimBarangController.dart b/lib/controller/after_login/pengirim/kirimBarangController.dart index aa92370..78cba07 100644 --- a/lib/controller/after_login/pengirim/kirimBarangController.dart +++ b/lib/controller/after_login/pengirim/kirimBarangController.dart @@ -768,9 +768,30 @@ class KirimBarangController extends GetxController { backgroundColor: Colors.white, child: CircleAvatar( radius: 40.0, - backgroundImage: NetworkImage(kurirModel.photo_url ?? - 'https://via.placeholder.com/150'), + // backgroundImage: NetworkImage( + // kurirModel.photo_url ?? + // 'https://via.placeholder.com/150', + + // ), backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + kurirModel.photo_url ?? + 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, error, stackTrace) { + return Center( + child: const Icon( + Icons.error, + color: Colors.grey, + size: 20, + ), + ); + }, + ), + ), ), ), ), @@ -1184,9 +1205,26 @@ class KirimBarangController extends GetxController { backgroundColor: Colors.white, child: CircleAvatar( radius: 50.0, - backgroundImage: NetworkImage(kurirModel.photo_url ?? - 'https://via.placeholder.com/150'), + // backgroundImage: NetworkImage(kurirModel.photo_url ?? + // 'https://via.placeholder.com/150'), backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + kurirModel.photo_url ?? + 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, url, error) { + return Center( + child: const Icon( + Icons.error, + size: 20, + ), + ); + }, + ), + ), ), ), ), @@ -1216,6 +1254,15 @@ class KirimBarangController extends GetxController { child: Image.network( kurirModel.kenderaan_url.toString(), fit: BoxFit.cover, + width: 100, + errorBuilder: (context, url, error) { + return Center( + child: const Icon( + Icons.error, + size: 20, + ), + ); + }, ), ), ), @@ -1342,9 +1389,25 @@ class KirimBarangController extends GetxController { backgroundColor: Colors.white, child: CircleAvatar( radius: 50.0, - backgroundImage: NetworkImage(kurirModel.photo_url ?? - 'https://via.placeholder.com/150'), + // backgroundImage: NetworkImage(kurirModel.photo_url ?? + // 'https://via.placeholder.com/150'), backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + kurirModel.photo_url ?? 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, url, error) { + return Center( + child: const Icon( + Icons.error, + size: 20, + ), + ); + }, + ), + ), ), ), ), diff --git a/lib/controller/after_login/pengirim/logKirimanController.dart b/lib/controller/after_login/pengirim/logKirimanController.dart index 5456810..b5bbb42 100644 --- a/lib/controller/after_login/pengirim/logKirimanController.dart +++ b/lib/controller/after_login/pengirim/logKirimanController.dart @@ -119,7 +119,7 @@ class LogKirimanController extends GetxController { String _status = _pengirimanModel.statusPengiriman!; - String _foto_pengiriman = _pengirimanModel.fotoPengiriman!; + String _foto_pengiriman = _pengirimanModel.fotoPengiriman ?? ''; // log(_foto_pengiriman + " foto pengiriman"); var _kordinat_pengiriman = _pengirimanModel.kordinatPengiriman!; @@ -270,14 +270,26 @@ class LogKirimanController extends GetxController { fit: BoxFit.cover, ), ), - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(foto_pengiriman), - fit: BoxFit.cover, - ), - ), + child: Image.network( + foto_pengiriman, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return const Center( + child: Icon( + Icons.error, + size: 20, + ), + ); + }, ), + // child: Container( + // decoration: BoxDecoration( + // image: DecorationImage( + // image: NetworkImage(foto_pengiriman), + // fit: BoxFit.cover, + // ), + // ), + // ), ), ), ), diff --git a/lib/function/allFunction.dart b/lib/function/allFunction.dart index 28f4e06..63b11e2 100644 --- a/lib/function/allFunction.dart +++ b/lib/function/allFunction.dart @@ -97,4 +97,35 @@ class AllFunction { cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) * p)) / 2; return 12742 * asin(sqrt(a)); } + + + static 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; + } + } diff --git a/lib/models/pengirimimanModel.dart b/lib/models/pengirimimanModel.dart index 441d6a1..c460f2a 100644 --- a/lib/models/pengirimimanModel.dart +++ b/lib/models/pengirimimanModel.dart @@ -17,22 +17,25 @@ class PengirimanModel { String? updatedAt; int? iV; String? fotoPengiriman; + List? history; - PengirimanModel( - {this.kordinatPengiriman, - this.kordinatPermulaan, - this.biaya, - this.sId, - this.namaPenerima, - this.noTelponPenerima, - this.alamatPenerima, - this.statusPengiriman, - this.kurir, - this.pengirim, - this.createdAt, - this.updatedAt, - this.iV, - this.fotoPengiriman}); + PengirimanModel({ + this.kordinatPengiriman, + this.kordinatPermulaan, + this.biaya, + this.sId, + this.namaPenerima, + this.noTelponPenerima, + this.alamatPenerima, + this.statusPengiriman, + this.kurir, + this.pengirim, + this.createdAt, + this.updatedAt, + this.iV, + this.fotoPengiriman, + this.history, + }); PengirimanModel.fromJson(Map json) { kordinatPengiriman = json['kordinat_pengiriman'] != null @@ -55,6 +58,12 @@ class PengirimanModel { updatedAt = json['updated_at']; iV = json['__v']; fotoPengiriman = json['foto_pengiriman']; + if (json['history'] != null) { + history = []; + json['history'].forEach((v) { + history!.add(History.fromJson(v)); + }); + } } Map toJson() { @@ -83,6 +92,9 @@ class PengirimanModel { data['updated_at'] = updatedAt; data['__v'] = iV; data['foto_pengiriman'] = fotoPengiriman; + if (history != null) { + data['history'] = history!.map((v) => v.toJson()).toList(); + } return data; } } @@ -149,3 +161,22 @@ class Biaya { return data; } } + +class History { + String? statusPengiriman; + String? waktu; + + History({this.statusPengiriman, this.waktu}); + + History.fromJson(Map json) { + statusPengiriman = json['status_pengiriman']; + waktu = json['waktu']; + } + + Map toJson() { + final Map data = {}; + data['status_pengiriman'] = statusPengiriman; + data['waktu'] = waktu; + return data; + } +} diff --git a/lib/pages/after_login/kurir/pengirimanPage.dart b/lib/pages/after_login/kurir/pengirimanPage.dart index 76673f9..5c901ae 100644 --- a/lib/pages/after_login/kurir/pengirimanPage.dart +++ b/lib/pages/after_login/kurir/pengirimanPage.dart @@ -1,9 +1,11 @@ // ignore_for_file: file_names +import 'dart:developer' as dev; import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:get/get.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:kurir/function/allFunction.dart'; import '../../../controller/after_login/kurir/pengirimanController.dart'; import '../../../models/pengirimimanModel.dart'; @@ -66,8 +68,8 @@ class _MainWidget extends StatelessWidget { _SlidableWidget(data: data, controller: controller), if (controller.loadPengiriman.value == 1 && controller.pengirimanModelList.isEmpty) - Center( - child: const TiadaDataWIdget( + const Center( + child: TiadaDataWIdget( text: "Tiada data pengiriman\ndalam proses pengesahan")), if (controller.loadPengiriman.value == 2) const ErrorLoadDataWidget(), @@ -90,6 +92,25 @@ class _SlidableWidget extends StatelessWidget { @override Widget build(BuildContext context) { + late String _text; + late IconData _icon; + + switch (data.statusPengiriman) { + case "Dalam Pengesahan Kurir": + _text = "Terima Pengiriman"; + _icon = Icons.check_box; + break; + case "Disahkan Kurir": + _text = "Mengambil Paket\nKiriman"; + _icon = Icons.motorcycle_outlined; + break; + case "Mengambil Paket Pengiriman Dari Pengirim": + _text = "Paket Diterima\nDari Pengirim"; + _icon = Icons.handshake_outlined; + break; + default: + } + return Padding( padding: const EdgeInsets.only(bottom: 10), child: Slidable( @@ -102,22 +123,21 @@ class _SlidableWidget extends StatelessWidget { SlidableAction( flex: 5, onPressed: (context) { - // Get.offAndToNamed( - // '/pengirimIndex/infoPengiriman', - // arguments: { - // 'pengiriman_model': _pengirimanModel, - // }, - // ); + if (data.statusPengiriman == "Dalam Pengesahan Kurir") { + controller.terimaPengiriman(data.sId); + } else if (data.statusPengiriman == "Disahkan Kurir") { + controller.mengambilPaket(data.sId); + } }, backgroundColor: const Color.fromARGB(255, 104, 164, 164), foregroundColor: Colors.white, - icon: Icons.check_box, - label: 'Terima Pengiriman', + icon: _icon, + label: _text, ), SlidableAction( flex: 5, onPressed: (context) { - controller.lihat_foto_kiriman(context, data.fotoPengiriman!); + controller.lihatFotoKiriman(context, data.fotoPengiriman!); }, backgroundColor: const Color.fromARGB(255, 4, 103, 103), foregroundColor: Colors.white, @@ -128,18 +148,19 @@ class _SlidableWidget extends StatelessWidget { ), endActionPane: ActionPane( motion: const DrawerMotion(), - extentRatio: 0.5, + extentRatio: + (data.statusPengiriman == "Dalam Pengesahan Kurir") ? 0.5 : 0.01, children: [ - SlidableAction( - onPressed: (context) { - // _lihat_rute_pengiriman( - // context, _kordinat_pengiriman, _kordinat_permulaan); - }, - backgroundColor: Colors.red, - foregroundColor: Colors.white, - icon: Icons.cancel_rounded, - label: "Batalkan Permintaan\nPengirim", - ), + if (data.statusPengiriman == 'Dalam Pengesahan Kurir') + SlidableAction( + onPressed: (context) { + controller.batalkanPengiriman(data.sId); + }, + backgroundColor: Colors.red, + foregroundColor: Colors.white, + icon: Icons.cancel_rounded, + label: "Batalkan Permintaan\nPengirim", + ), ], ), child: _MainChild(data: data, controller: controller), @@ -162,7 +183,7 @@ class _MainChild extends StatelessWidget { Widget build(BuildContext context) { return Container( width: double.infinity, - height: 115, + height: 132, padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.white, @@ -200,13 +221,32 @@ class _MainChild extends StatelessWidget { fit: BoxFit.fitHeight, ), ), - child: CircleAvatar( - radius: 30.0, - backgroundImage: NetworkImage( - data.pengirim!.photoUrl ?? 'https://via.placeholder.com/150', - scale: 0.5, + child: Center( + child: CircleAvatar( + radius: 30.0, + // backgroundImage: NetworkImage( + // data.pengirim!.photoUrl ?? 'https://via.placeholder.com/150', + // scale: 0.5, + // ), + backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + data.pengirim!.photoUrl ?? + 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, error, stackTrace) { + return const Center( + child: Icon( + Icons.error, + size: 20, + ), + ); + }, + ), + ), ), - backgroundColor: Colors.transparent, ), ), ), @@ -214,67 +254,83 @@ class _MainChild extends StatelessWidget { flex: 4, child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ - const SizedBox(height: 10), - Text( - controller.timeZoneAdd8(data.createdAt), - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - overflow: TextOverflow.ellipsis, + FittedBox( + child: Text( + AllFunction.timeZoneAdd8(data.createdAt), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + ), ), ), - Text( - data.pengirim!.nama!, - style: const TextStyle( - fontSize: 15, - color: Colors.grey, - overflow: TextOverflow.ellipsis, + FittedBox( + child: Text( + data.pengirim!.nama!, + style: const TextStyle( + fontSize: 15, + color: Colors.grey, + overflow: TextOverflow.ellipsis, + ), ), ), // Coba(data:data,controller:controller) - _FutureBuilderHargaJarak( - controller: controller, - data: data, + FittedBox( + child: _FutureBuilderHargaJarak( + controller: controller, + data: data, + ), ), - Text( - data.statusPengiriman!, - style: const TextStyle( - fontSize: 15, - color: Colors.grey, - overflow: TextOverflow.ellipsis, + FittedBox( + child: Text( + data.statusPengiriman!, + style: const TextStyle( + fontSize: 15, + color: Colors.grey, + overflow: TextOverflow.ellipsis, + ), ), ), ], ), ), Expanded( - flex: 1, - child: Container( - padding: const EdgeInsets.all(2), - width: 50, - height: 50, - decoration: BoxDecoration( - color: Color.fromARGB(255, 2, 72, 72), - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - color: const Color.fromARGB(255, 104, 164, 164) - .withOpacity(0.5), - blurRadius: 10, - spreadRadius: 5, + flex: 2, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + // crossAxisAlignment: CrossAxisAlignment.end, + + children: [ + _IconContainer( + icon: const Icon( + Icons.turn_sharp_right_outlined, + color: Color.fromARGB(255, 199, 214, 234), ), - ], - ), - child: IconButton( - onPressed: () { - controller.showMapDialog(context, data); - }, - icon: Icon( - Icons.turn_sharp_right_outlined, - color: Color.fromARGB(255, 199, 214, 234), + color: const Color.fromARGB(255, 2, 72, 72), + shadowColor: const Color.fromARGB(255, 104, 164, 164), + onPressed: () { + controller.showMapDialog(context, data); + // dev.log("ini ditekan"); + }, ), - ), + if (data.statusPengiriman != "Dalam Pengesahan Kurir") + _IconContainer( + icon: const Icon( + Icons.info_outlined, + color: Colors.white, + ), + color: const Color.fromARGB(255, 104, 164, 164), + shadowColor: const Color.fromARGB(255, 199, 214, 234), + onPressed: () { + // controller.showMapDialog(context, data); + Get.toNamed('/kurirIndex/progressPenghantaran', + arguments: data.sId); + dev.log("ini ditekan"); + }, + ), + ], ), ), ], @@ -283,6 +339,45 @@ class _MainChild extends StatelessWidget { } } +class _IconContainer extends StatelessWidget { + const _IconContainer({ + Key? key, + required this.icon, + required this.color, + required this.shadowColor, + required this.onPressed, + }) : super(key: key); + + final Icon icon; + final Color color; + final Color shadowColor; + final VoidCallback onPressed; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(2), + width: 50, + height: 50, + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: shadowColor.withOpacity(0.5), + blurRadius: 10, + spreadRadius: 5, + ), + ], + ), + child: IconButton( + onPressed: onPressed, + icon: icon, + ), + ); + } +} + class TopSeachInput extends StatelessWidget { const TopSeachInput({ Key? key, @@ -390,16 +485,16 @@ class _FutureBuilderHargaJarak extends StatelessWidget { ], ); } else if (snapshot.hasError) { - return Text( + return const Text( "Error mengambil data", - style: const TextStyle( + style: TextStyle( fontSize: 15, color: Colors.grey, overflow: TextOverflow.ellipsis, ), ); } else { - return Center( + return const Center( child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation( Color.fromARGB( diff --git a/lib/pages/after_login/kurir/profilePage.dart b/lib/pages/after_login/kurir/profilePage.dart index 12d67d8..db5370d 100644 --- a/lib/pages/after_login/kurir/profilePage.dart +++ b/lib/pages/after_login/kurir/profilePage.dart @@ -33,7 +33,7 @@ class ProfileKurirPage extends GetView { ElevatedButton( child: const Text('Yes'), style: ElevatedButton.styleFrom( - primary: Color.fromARGB( + primary: const Color.fromARGB( 255, 104, 164, 164), //background color // onPrimary: Colors.black, //ripple color ), @@ -46,8 +46,8 @@ class ProfileKurirPage extends GetView { ElevatedButton( child: const Text('No'), style: ElevatedButton.styleFrom( - primary: - Color.fromARGB(255, 2, 72, 72), //background color + primary: const Color.fromARGB( + 255, 2, 72, 72), //background color // onPrimary: Colors.black, //ripple color ), onPressed: () { @@ -69,8 +69,8 @@ class ProfileKurirPage extends GetView { ); return false; }, - child: BoxBackgroundDecoration( - child: const Center( + child: const BoxBackgroundDecoration( + child: Center( child: Text('Profile'), ), ), diff --git a/lib/pages/after_login/kurir/progressPenghantaranPage.dart b/lib/pages/after_login/kurir/progressPenghantaranPage.dart new file mode 100644 index 0000000..0d76462 --- /dev/null +++ b/lib/pages/after_login/kurir/progressPenghantaranPage.dart @@ -0,0 +1,30 @@ +// ignore_for_file: file_names + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../controller/after_login/kurir/progressPenghantaranController.dart'; +import '../../../widgets/appbar.dart'; +import '../../../widgets/boxBackgroundDecoration.dart'; + +class ProgressPenghantaranPage + extends GetView { + const ProgressPenghantaranPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: PreferredSize( + preferredSize: + Size.fromHeight(MediaQuery.of(context).size.height * 0.08), + child: const AppBarWidget( + header: "Progress Penghantaran", + autoLeading: true, + ), + ), + body: BoxBackgroundDecoration( + child: Obx(() => controller.enhanceStepContainer.value), + ), + ); + } +} diff --git a/lib/pages/after_login/pengirim/infoPengirimanPage.dart b/lib/pages/after_login/pengirim/infoPengirimanPage.dart index e6aeb26..7003916 100644 --- a/lib/pages/after_login/pengirim/infoPengirimanPage.dart +++ b/lib/pages/after_login/pengirim/infoPengirimanPage.dart @@ -83,17 +83,21 @@ class InfoPengirimanPage extends GetView { fit: BoxFit.fill, ), ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - image: DecorationImage( - image: NetworkImage( - controller.pengirimanModel.fotoPengiriman!, - ), - fit: BoxFit.fill, - ), - ), - ), + child: (controller.pengirimanModel.fotoPengiriman != + null) + ? Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + image: DecorationImage( + image: NetworkImage( + controller + .pengirimanModel.fotoPengiriman!, + ), + fit: BoxFit.fill, + ), + ), + ) + : const SizedBox(), ), ), ), diff --git a/lib/pages/after_login/pengirim/listKurirPage.dart b/lib/pages/after_login/pengirim/listKurirPage.dart index 201b77e..888171b 100644 --- a/lib/pages/after_login/pengirim/listKurirPage.dart +++ b/lib/pages/after_login/pengirim/listKurirPage.dart @@ -30,7 +30,7 @@ class ListKurirPage extends GetView { ), ), ), - _TopSearchInputField(), + const _TopSearchInputField(), ], ), ); @@ -168,33 +168,32 @@ class _KurirDetailBox extends StatelessWidget { children: [ Expanded( flex: 2, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - color: const Color.fromARGB(255, 165, 163, 163) - .withOpacity(0.5), - blurRadius: 10, - spreadRadius: 5, + child: Center( + child: Container( + width: 70, + height: 70, + decoration: const BoxDecoration( + shape: BoxShape.circle, + ), + child: CircleAvatar( + radius: 50.0, + // backgroundImage: NetworkImage( + // pengirimanModel.kurir!.photo_url ?? + // 'https://via.placeholder.com/150'), + backgroundColor: Colors.transparent, + child: ClipOval( + child: Image.network( + data.photo_url ?? 'https://via.placeholder.com/150', + fit: BoxFit.cover, + width: 100, + height: 100, + errorBuilder: (context, url, error) { + return const Icon(Icons.error); + }, + ), ), - ], - image: const DecorationImage( - image: AssetImage('assets/loading.gif'), - fit: BoxFit.fitHeight, ), ), - child: CircleAvatar( - radius: 30.0, - backgroundImage: NetworkImage( - data.photo_url ?? 'https://via.placeholder.com/150', - scale: 0.5, - ), - backgroundColor: Colors.transparent, - ), ), ), Expanded( diff --git a/lib/routes/routes.dart b/lib/routes/routes.dart index 876a071..2275a4f 100644 --- a/lib/routes/routes.dart +++ b/lib/routes/routes.dart @@ -1,26 +1,27 @@ import 'package:flutter/animation.dart'; import 'package:get/get.dart'; -import 'package:kurir/binding/beforeEnterBinding.dart'; -import 'package:kurir/binding/infoPengirimanBinding.dart'; -import 'package:kurir/binding/kurirIndexBinding.dart'; -import 'package:kurir/binding/kurirProfileBinding.dart'; -// import 'package:kurir/binding/indexBinding.dart'; -import 'package:kurir/binding/pendaftaranKurirBinding.dart'; -import 'package:kurir/binding/pengirimIndexBinding.dart'; -import 'package:kurir/binding/pengirimProfileBinding.dart'; -import 'package:kurir/pages/after_login/before_enter.dart'; -import 'package:kurir/pages/after_login/kurir/profilePage.dart'; -import 'package:kurir/pages/after_login/pengirim/infoPengirimanPage.dart'; -import 'package:kurir/pages/after_login/pengirim/pengirimProfilePage.dart'; -import 'package:kurir/pages/before_login/daftar.dart'; -import 'package:kurir/pages/before_login/login.dart'; +import '../binding/beforeEnterBinding.dart'; +import '../binding/infoPengirimanBinding.dart'; +import '../binding/kurirIndexBinding.dart'; +import '../binding/kurirProfileBinding.dart'; import '../binding/loginBinding.dart'; +import '../binding/pendaftaranKurirBinding.dart'; import '../binding/pendaftaranPengirim.dart'; +import '../binding/pengirimIndexBinding.dart'; +import '../binding/pengirimProfileBinding.dart'; +import '../binding/progressPenghantaranKurirBinding.dart'; import '../binding/splashBinding.dart'; +import '../pages/after_login/before_enter.dart'; import '../pages/after_login/kurir/indexPage.dart'; +import '../pages/after_login/kurir/profilePage.dart'; +import '../pages/after_login/kurir/progressPenghantaranPage.dart'; import '../pages/after_login/pengirim/indexPage.dart'; +import '../pages/after_login/pengirim/infoPengirimanPage.dart'; +import '../pages/after_login/pengirim/pengirimProfilePage.dart'; +import '../pages/before_login/daftar.dart'; import '../pages/before_login/index.dart'; +import '../pages/before_login/login.dart'; import '../pages/before_login/pendaftaran_kurir.dart'; import '../pages/before_login/pendaftaran_pengirirm.dart'; import '../splashScreen.dart'; @@ -93,14 +94,24 @@ class Routes { transition: Transition.native, transitionDuration: const Duration(seconds: 1), curve: Curves.easeInOut, - ), - GetPage( - name: '/profileKurir', - page: () => const ProfileKurirPage(), - binding: KurirProfileBinding(), - transition: Transition.native, - transitionDuration: const Duration(seconds: 1), - curve: Curves.easeInOut, + children: [ + GetPage( + name: '/progressPenghantaran', + page: () => const ProgressPenghantaranPage(), + binding: ProgressPenghantaranKurirBinding(), + transition: Transition.native, + transitionDuration: const Duration(seconds: 1), + curve: Curves.easeInOut, + ), + GetPage( + name: '/profileKurir', + page: () => const ProfileKurirPage(), + binding: KurirProfileBinding(), + transition: Transition.native, + transitionDuration: const Duration(seconds: 1), + curve: Curves.easeInOut, + ), + ], ), GetPage( name: '/pengirimIndex', diff --git a/lib/widgets/load_data.dart b/lib/widgets/load_data.dart index 76a3490..d871ee9 100644 --- a/lib/widgets/load_data.dart +++ b/lib/widgets/load_data.dart @@ -37,7 +37,7 @@ class TiadaDataWIdget extends StatelessWidget { child: Center( child: Text( text, - style: TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 20, ), diff --git a/pubspec.lock b/pubspec.lock index 71e1be0..e6d39b7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + enhance_stepper: + dependency: "direct main" + description: + name: enhance_stepper + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8e054d2..82f25d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,25 +36,19 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 get: ^4.6.1 - # navigation_history_observer: ^1.1.0 double_back_to_close_app: ^2.0.1 - # back_button_interceptor: ^5.0.2 image_picker: ^0.8.5 path_provider: ^2.0.9 - # flutter_cache_manager: ^3.3.0 - # ensure_visible_when_focused: ^1.0.0+1 http: ^0.13.4 flutter_easyloading: ^3.0.3 crypto: ^3.0.1 # provider: ^6.0.2 get_storage: ^2.0.3 - # dio: ^4.0.6 intl: ^0.17.0 google_maps_flutter: ^2.1.6 maps_toolkit: ^2.0.0 flutter_slidable: socket_io_client: - # geolocator: geocoding: location: ^4.2.0 flutter_polyline_points: @@ -68,6 +62,8 @@ dependencies: flutter_background_service: ^2.1.2 flutter_background_service_android: ^2.0.2 device_info_plus: ^3.2.4 + + enhance_stepper: ^0.1.1 # flutter_background_service_platform_interface: ^0.0.1