From 8eacfa6dee15876b6671b938fed3f3247e85f5a8 Mon Sep 17 00:00:00 2001 From: kicap Date: Fri, 3 Nov 2023 23:24:23 +0800 Subject: [PATCH] complete admin, mandor and user page --- .env | 4 +- android/app/src/main/AndroidManifest.xml | 40 +-- lib/app/app.dart | 7 +- lib/app/app.locator.dart | 2 - lib/app/app.router.dart | 48 +-- lib/main.dart | 11 + lib/model/rumah_model.dart | 28 +- .../mandor_tracking_index_view.dart | 12 + .../mandor_tracking_index_view_model.dart | 26 ++ .../list_pemilik/list_pemilik_view.dart | 3 +- .../list_pemilik/list_pemilik_view_model.dart | 12 + .../pengembang_home/pengembang_home_view.dart | 117 ++++--- .../pengembang_home_view_model.dart | 6 + .../pengembang_index_view.dart | 12 + .../pengembang_index_view_model.dart | 26 ++ .../pengembang_profil_view.dart | 179 +++++++++- .../pengembang_profil_view_model.dart | 36 +- .../perumahan_detail_view.dart | 80 ++++- .../perumahan_detail_view_model.dart | 39 ++- .../play_video_dialog_view.dart | 98 +++--- .../play_video_dialog_view_model.dart | 11 +- .../splash_screen/splash_screen_view.dart | 2 +- ...mbah_lihat_progress_bottom_sheet_view.dart | 309 ++++++++++++++---- ...ihat_progress_bottom_sheet_view_model.dart | 72 +++- .../user_index/user_home/user_home_view.dart | 69 ---- .../user_home/user_home_view_model.dart | 25 -- lib/ui/views/user_index/user_index_view.dart | 14 +- .../user_index/user_index_view_model.dart | 36 +- .../user_list_pembangunan_page_view.dart | 26 ++ ...user_list_pembangunan_page_view_model.dart | 5 + .../user_list_pembangunan_view.dart | 88 ++--- .../user_list_pembangunan_view_model.dart | 48 ++- .../user_profile/user_profile_view.dart | 198 ++++++----- .../user_profile/user_profile_view_model.dart | 34 +- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- pubspec.lock | 88 +++-- pubspec.yaml | 3 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 41 files changed, 1335 insertions(+), 492 deletions(-) delete mode 100644 lib/ui/views/user_index/user_home/user_home_view.dart delete mode 100644 lib/ui/views/user_index/user_home/user_home_view_model.dart create mode 100644 lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart create mode 100644 lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view_model.dart diff --git a/.env b/.env index cdeef4c..84836a4 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -url = 'http://20.20.20.25/perumahan_backend/' -api_url = 'http://20.20.20.25/perumahan_backend/api/' \ No newline at end of file +url = 'https://my_localhost.kicap-karan.com/perumahan_backend/' +api_url = 'https://my_localhost.kicap-karan.com/perumahan_backend/index.php/api/' \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3c687ed..ff4badc 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,25 +1,11 @@ - - + + - + @@ -27,8 +13,22 @@ - + + + + + + + + + + + + + + + + + diff --git a/lib/app/app.dart b/lib/app/app.dart index 6ee7476..d1c0fe6 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -1,4 +1,5 @@ import 'package:perumahan_bew/ui/views/play_video_dialog/play_video_dialog_view.dart'; +import 'package:perumahan_bew/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart'; import 'package:stacked_services/stacked_services.dart'; import 'package:stacked/stacked_annotations.dart'; @@ -18,7 +19,6 @@ import '../ui/views/pengembang_index/pengembang_profil/pengembang_profil_view.da import '../ui/views/pengembang_index/perumahan_detail/perumahan_detail_view.dart'; import '../ui/views/splash_screen/splash_screen_view.dart'; import '../ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view.dart'; -import '../ui/views/user_index/user_home/user_home_view.dart'; import '../ui/views/user_index/user_index_view.dart'; import '../ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart'; import '../ui/views/user_index/user_profile/user_profile_view.dart'; @@ -30,9 +30,9 @@ import '../ui/views/user_index/user_profile/user_profile_view.dart'; MaterialRoute( page: UserIndexView, children: [ - MaterialRoute(page: UserHomeView, initial: true), + MaterialRoute(page: UserListPembangunanView, initial: true), MaterialRoute(page: UserProfileView), - MaterialRoute(page: UserListPembangunanView), + MaterialRoute(page: UserListPembangunanPageView), ], ), // dibawah untuk admin @@ -60,7 +60,6 @@ import '../ui/views/user_index/user_profile/user_profile_view.dart'; LazySingleton(classType: SnackbarService), LazySingleton(classType: BottomSheetService), // - LazySingleton(classType: UserHomeView), LazySingleton(classType: PengembangHomeView), LazySingleton(classType: MyEasyLoading), LazySingleton(classType: MyHttpServices), diff --git a/lib/app/app.locator.dart b/lib/app/app.locator.dart index c9a9802..af2682a 100644 --- a/lib/app/app.locator.dart +++ b/lib/app/app.locator.dart @@ -18,7 +18,6 @@ import '../services/my_easyloading.dart'; import '../services/other_function.dart'; import '../services/shared_prefs.dart'; import '../ui/views/pengembang_index/pengembang_home/pengembang_home_view.dart'; -import '../ui/views/user_index/user_home/user_home_view.dart'; final locator = StackedLocator.instance; @@ -35,7 +34,6 @@ Future setupLocator({ locator.registerLazySingleton(() => DialogService()); locator.registerLazySingleton(() => SnackbarService()); locator.registerLazySingleton(() => BottomSheetService()); - locator.registerLazySingleton(() => const UserHomeView()); locator.registerLazySingleton(() => const PengembangHomeView()); locator.registerLazySingleton(() => MyEasyLoading()); locator.registerLazySingleton(() => MyHttpServices()); diff --git a/lib/app/app.router.dart b/lib/app/app.router.dart index 103f2fb..70a0422 100644 --- a/lib/app/app.router.dart +++ b/lib/app/app.router.dart @@ -25,11 +25,11 @@ import 'package:perumahan_bew/ui/views/pengembang_index/perumahan_detail/perumah as _i6; import 'package:perumahan_bew/ui/views/splash_screen/splash_screen_view.dart' as _i2; -import 'package:perumahan_bew/ui/views/user_index/user_home/user_home_view.dart' - as _i9; import 'package:perumahan_bew/ui/views/user_index/user_index_view.dart' as _i4; -import 'package:perumahan_bew/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart' +import 'package:perumahan_bew/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart' as _i11; +import 'package:perumahan_bew/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart' + as _i9; import 'package:perumahan_bew/ui/views/user_index/user_profile/user_profile_view.dart' as _i10; import 'package:stacked/stacked.dart' as _i1; @@ -162,39 +162,39 @@ class PerumahanDetailViewArguments { } class UserIndexViewRoutes { - static const userHomeView = ''; + static const userListPembangunanView = ''; static const userProfileView = 'user-profile-view'; - static const userListPembangunanView = 'user-list-pembangunan-view'; + static const userListPembangunanPageView = 'user-list-pembangunan-page-view'; static const all = { - userHomeView, - userProfileView, userListPembangunanView, + userProfileView, + userListPembangunanPageView, }; } class UserIndexViewRouter extends _i1.RouterBase { final _routes = <_i1.RouteDef>[ _i1.RouteDef( - UserIndexViewRoutes.userHomeView, - page: _i9.UserHomeView, + UserIndexViewRoutes.userListPembangunanView, + page: _i9.UserListPembangunanView, ), _i1.RouteDef( UserIndexViewRoutes.userProfileView, page: _i10.UserProfileView, ), _i1.RouteDef( - UserIndexViewRoutes.userListPembangunanView, - page: _i11.UserListPembangunanView, + UserIndexViewRoutes.userListPembangunanPageView, + page: _i11.UserListPembangunanPageView, ), ]; final _pagesMap = { - _i9.UserHomeView: (data) { + _i9.UserListPembangunanView: (data) { return _i8.MaterialPageRoute( - builder: (context) => const _i9.UserHomeView(), + builder: (context) => const _i9.UserListPembangunanView(), settings: data, ); }, @@ -204,9 +204,9 @@ class UserIndexViewRouter extends _i1.RouterBase { settings: data, ); }, - _i11.UserListPembangunanView: (data) { + _i11.UserListPembangunanPageView: (data) { return _i8.MaterialPageRoute( - builder: (context) => const _i11.UserListPembangunanView(), + builder: (context) => const _i11.UserListPembangunanPageView(), settings: data, ); }, @@ -450,14 +450,14 @@ extension NavigatorStateExtension on _i16.NavigationService { transition: transition); } - Future navigateToNestedUserHomeViewInUserIndexViewRouter([ + Future navigateToNestedUserListPembangunanViewInUserIndexViewRouter([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return navigateTo(UserIndexViewRoutes.userHomeView, + return navigateTo(UserIndexViewRoutes.userListPembangunanView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -478,14 +478,15 @@ extension NavigatorStateExtension on _i16.NavigationService { transition: transition); } - Future navigateToNestedUserListPembangunanViewInUserIndexViewRouter([ + Future + navigateToNestedUserListPembangunanPageViewInUserIndexViewRouter([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return navigateTo(UserIndexViewRoutes.userListPembangunanView, + return navigateTo(UserIndexViewRoutes.userListPembangunanPageView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -701,14 +702,15 @@ extension NavigatorStateExtension on _i16.NavigationService { transition: transition); } - Future replaceWithNestedUserHomeViewInUserIndexViewRouter([ + Future + replaceWithNestedUserListPembangunanViewInUserIndexViewRouter([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return replaceWith(UserIndexViewRoutes.userHomeView, + return replaceWith(UserIndexViewRoutes.userListPembangunanView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, @@ -730,14 +732,14 @@ extension NavigatorStateExtension on _i16.NavigationService { } Future - replaceWithNestedUserListPembangunanViewInUserIndexViewRouter([ + replaceWithNestedUserListPembangunanPageViewInUserIndexViewRouter([ int? routerId, bool preventDuplicates = true, Map? parameters, Widget Function(BuildContext, Animation, Animation, Widget)? transition, ]) async { - return replaceWith(UserIndexViewRoutes.userListPembangunanView, + return replaceWith(UserIndexViewRoutes.userListPembangunanPageView, id: routerId, preventDuplicates: preventDuplicates, parameters: parameters, diff --git a/lib/main.dart b/lib/main.dart index 7965553..cab9dd1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -13,6 +14,7 @@ import 'app/themes/app_theme.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); + HttpOverrides.global = MyHttpOverrides(); await dotenv.load(fileName: ".env"); await setupAllLocator(); runApp(const MyApp()); @@ -41,3 +43,12 @@ Future setupAllLocator() async { setupBottomSheetUi(); // setupSnackbarUi(); } + +class MyHttpOverrides extends HttpOverrides { + @override + HttpClient createHttpClient(SecurityContext? context) { + return super.createHttpClient(context) + ..badCertificateCallback = + (X509Certificate cert, String host, int port) => true; + } +} diff --git a/lib/model/rumah_model.dart b/lib/model/rumah_model.dart index 7c369bc..f2beabb 100644 --- a/lib/model/rumah_model.dart +++ b/lib/model/rumah_model.dart @@ -84,6 +84,7 @@ class ProgressModel { String? nama; String? noTelpon; int? no; + String? type; ProgressModel( {this.idProgress, @@ -94,7 +95,8 @@ class ProgressModel { this.idMandor, this.nama, this.noTelpon, - this.no}); + this.no, + this.type}); ProgressModel.fromJson(Map json) { idProgress = json['id_progress']; @@ -106,6 +108,7 @@ class ProgressModel { nama = json['nama']; noTelpon = json['no_telpon']; no = json['no']; + type = json['type']; } Map toJson() { @@ -119,6 +122,29 @@ class ProgressModel { data['nama'] = nama; data['no_telpon'] = noTelpon; data['no'] = no; + data['type'] = type; + return data; + } +} + +class MandorModel { + String? idMandor; + String? nama; + String? noTelpon; + + MandorModel({this.idMandor, this.nama, this.noTelpon}); + + MandorModel.fromJson(Map json) { + idMandor = json['id_mandor']; + nama = json['nama']; + noTelpon = json['no_telpon']; + } + + Map toJson() { + final Map data = {}; + data['id_mandor'] = idMandor; + data['nama'] = nama; + data['no_telpon'] = noTelpon; return data; } } diff --git a/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view.dart b/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view.dart index 2f3cc77..3df5908 100644 --- a/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view.dart +++ b/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view.dart @@ -36,6 +36,18 @@ class MandorTrackingIndexView extends StatelessWidget { backgroundColor: mainColor, elevation: 0, automaticallyImplyLeading: false, + actions: [ + // create logout button + IconButton( + onPressed: () { + model.logout(); + }, + icon: const Icon( + Icons.logout, + color: Colors.white, + ), + ), + ], ), body: ExtendedNavigator( navigatorKey: StackedService.nestedNavigationKey(4), diff --git a/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view_model.dart b/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view_model.dart index 658f9b9..6ce50e4 100644 --- a/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view_model.dart +++ b/lib/ui/views/mandor_tracking_index/mandor_tracking_index_view_model.dart @@ -5,10 +5,14 @@ import 'package:stacked_services/stacked_services.dart'; import '../../../app/app.locator.dart'; import '../../../app/app.logger.dart'; import '../../../app/app.router.dart'; +import '../../../services/shared_prefs.dart'; class MandorTrackingIndexViewModel extends IndexTrackingViewModel { final log = getLogger('MandorTrackingIndexViewModel'); final _navigationService = locator(); + final _mySharedPrefs = locator(); + final _dialogService = locator(); + final _snackbarService = locator(); final _bottomNavBarList = [ {'name': 'List', 'icon': Icons.list_alt_rounded, 'header': 'List Pemilik'}, @@ -43,4 +47,26 @@ class MandorTrackingIndexViewModel extends IndexTrackingViewModel { id: 4, ); } + + logout() { + _dialogService + .showConfirmationDialog( + title: 'Logout', + description: 'Apakah Anda yakin ingin logout?', + cancelTitle: 'Batal', + confirmationTitle: 'Logout', + ) + .then((value) async { + if (value!.confirmed) { + await _mySharedPrefs.clear(); + _navigationService.clearStackAndShow(Routes.loginScreenView); + _snackbarService.showSnackbar( + message: 'Logout berhasil', + duration: const Duration(seconds: 2), + ); + } + }); + // await _mySharedPrefs.clear(); + // _navigationService.clearStackAndShow(Routes.loginScreenView); + } } diff --git a/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view.dart b/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view.dart index 4d12293..9615ba5 100644 --- a/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view.dart +++ b/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view.dart @@ -92,7 +92,8 @@ class ListPemilikView extends StatelessWidget { return Card( child: GestureDetector( onTap: () { - model.log.i('Card $index tapped'); + model.checkProgress( + model.listProgress[index]); }, child: ListTile( title: Text( diff --git a/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view_model.dart b/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view_model.dart index 2ed7918..9d83136 100644 --- a/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view_model.dart +++ b/lib/ui/views/pengembang_index/list_pemilik/list_pemilik_view_model.dart @@ -1,3 +1,4 @@ +import '../../../../app/app.bottomsheets.dart'; import '../../../../app/app.logger.dart'; import '../../../../app/core/custom_base_view_model.dart'; import '../../../../model/my_response_model.dart'; @@ -49,4 +50,15 @@ class ListPemilikViewModel extends CustomBaseViewModel { setBusy(false); } } + + checkProgress(ProgressModel progressModel) async { + await bottomSheetService.showCustomSheet( + variant: BottomSheetType.tambahLihatProgressBottomSheetView, + title: 'Lihat Progress', + data: { + 'idPerumahan': progressModel.idRumah, + 'progressModel': progressModel, + }, + ); + } } diff --git a/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view.dart b/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view.dart index 7fe1c87..80614ef 100644 --- a/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view.dart +++ b/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view.dart @@ -31,52 +31,81 @@ class PengembangHomeView extends StatelessWidget { } return false; }, - child: WebView( - // initialUrl: 'http://192.168.43.125/rekam-medis', - initialUrl: model.url, - javascriptMode: JavascriptMode.unrestricted, - onWebViewCreated: (WebViewController webViewController) { - // _controller.complete(webViewController); - model.webViewControllerCompleter.future - .then((value) => model.webVIewcontroller = value); - model.webViewControllerCompleter.complete(webViewController); - }, - onProgress: (int progress) { - double progressDouble = progress / 100; - LinearProgressIndicator( - value: progressDouble, - ); - // model.myEasyLoading.showProgress(progressDouble, "Loading Denah"); - }, - // javascriptChannels: { - // _toasterJavascriptChannel(context), - // }, - javascriptChannels: { - JavascriptChannel( - name: 'messageHandler', - onMessageReceived: (JavascriptMessage message) { - model.log.d(message.message); - // var data = JsonDecoder().convert(message.message); - // model.log.d(data['status']); - model.goToDetail(message.message); + child: SafeArea( + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (model.progress < 1) + Center( + child: LinearProgressIndicator( + value: model.progress, + ), + ), + Expanded( + child: Visibility( + visible: model.status, + child: WebView( + // initialUrl: 'http://192.168.43.125/rekam-medis', + initialUrl: model.url, + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: + (WebViewController webViewController) { + // _controller.complete(webViewController); + model.webViewControllerCompleter.future.then( + (value) => model.webVIewcontroller = value); + model.webViewControllerCompleter + .complete(webViewController); + }, + onProgress: (int progress) { + double progressDouble = progress / 100; + model.progress = progressDouble; + model.log.d('progress: $progressDouble'); + if (progressDouble == 1) { + model.status = true; + } + model.notifyListeners(); + // LinearProgressIndicator( + // value: progressDouble, + // ); + // model.myEasyLoading.showProgress(progressDouble, "Loading Denah"); + }, + // javascriptChannels: { + // _toasterJavascriptChannel(context), + // }, + javascriptChannels: { + JavascriptChannel( + name: 'messageHandler', + onMessageReceived: (JavascriptMessage message) { + model.log.d(message.message); + // var data = JsonDecoder().convert(message.message); + // model.log.d(data['status']); + model.goToDetail(message.message); - // dev.i("message from the web view=\"${message.message}\""); - // if (message.message == "coba") { - // dev.i("sini untuk coba"); - // controller.runJavascript("coba22('heheheh')"); - // } - }, + // dev.i("message from the web view=\"${message.message}\""); + // if (message.message == "coba") { + // dev.i("sini untuk coba"); + // controller.runJavascript("coba22('heheheh')"); + // } + }, + ), + }, + // navigationDelegate: (NavigationRequest request) async {}, + onPageStarted: (String url) {}, + onPageFinished: (String url) { + // dev.i('Page finished loading: $url'); + model.easyLoading.dismiss(); + }, + + gestureNavigationEnabled: true, + backgroundColor: const Color(0x00000000), + ), + ), + ), + ], ), - }, - // navigationDelegate: (NavigationRequest request) async {}, - onPageStarted: (String url) {}, - onPageFinished: (String url) { - // dev.i('Page finished loading: $url'); - model.easyLoading.dismiss(); - }, - - gestureNavigationEnabled: true, - backgroundColor: const Color(0x00000000), + ), ), ), ); diff --git a/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view_model.dart b/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view_model.dart index d9d1645..9435b32 100644 --- a/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view_model.dart +++ b/lib/ui/views/pengembang_index/pengembang_home/pengembang_home_view_model.dart @@ -15,12 +15,18 @@ class PengembangHomeViewModel extends CustomBaseViewModel { late String url; late String level; + bool status = true; + double progress = 0; late WebViewController webVIewcontroller; final Completer webViewControllerCompleter = Completer(); Future init() async { + // Future.delayed(const Duration(milliseconds: 1), () { + // status = false; + // notifyListeners(); + // }); globalVar.backPressed = "exitApp"; url = dotenv.env['url']!; log.d(url); diff --git a/lib/ui/views/pengembang_index/pengembang_index_view.dart b/lib/ui/views/pengembang_index/pengembang_index_view.dart index de9dc65..80e83cb 100644 --- a/lib/ui/views/pengembang_index/pengembang_index_view.dart +++ b/lib/ui/views/pengembang_index/pengembang_index_view.dart @@ -38,6 +38,18 @@ class PengembangIndexView extends StatelessWidget { backgroundColor: mainColor, elevation: 0, automaticallyImplyLeading: false, + actions: [ + // create logout button + IconButton( + onPressed: () { + model.logout(); + }, + icon: const Icon( + Icons.logout, + color: Colors.white, + ), + ), + ], ), body: ExtendedNavigator( navigatorKey: StackedService.nestedNavigationKey(3), diff --git a/lib/ui/views/pengembang_index/pengembang_index_view_model.dart b/lib/ui/views/pengembang_index/pengembang_index_view_model.dart index 1943152..3be8fd4 100644 --- a/lib/ui/views/pengembang_index/pengembang_index_view_model.dart +++ b/lib/ui/views/pengembang_index/pengembang_index_view_model.dart @@ -5,10 +5,14 @@ import 'package:stacked_services/stacked_services.dart'; import '../../../app/app.locator.dart'; import '../../../app/app.logger.dart'; import '../../../app/app.router.dart'; +import '../../../services/shared_prefs.dart'; class PengembangIndexViewModel extends IndexTrackingViewModel { final log = getLogger('PengembangIndexViewModel'); final _navigationService = locator(); + final _dialogService = locator(); + final _mySharedPrefs = locator(); + final _snackbarService = locator(); final _bottomNavBarList = [ {'name': 'List', 'icon': Icons.list_alt_rounded, 'header': 'List Pemilik'}, @@ -43,4 +47,26 @@ class PengembangIndexViewModel extends IndexTrackingViewModel { id: 3, ); } + + logout() { + _dialogService + .showConfirmationDialog( + title: 'Logout', + description: 'Apakah Anda yakin ingin logout?', + cancelTitle: 'Batal', + confirmationTitle: 'Logout', + ) + .then((value) async { + if (value!.confirmed) { + await _mySharedPrefs.clear(); + _navigationService.clearStackAndShow(Routes.loginScreenView); + _snackbarService.showSnackbar( + message: 'Logout berhasil', + duration: const Duration(seconds: 2), + ); + } + }); + // await _mySharedPrefs.clear(); + // _navigationService.clearStackAndShow(Routes.loginScreenView); + } } diff --git a/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view.dart b/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view.dart index dbedba8..b42d78e 100644 --- a/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view.dart +++ b/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; +import '../../../../app/themes/app_colors.dart'; +import '../../../../app/themes/app_text.dart'; import './pengembang_profil_view_model.dart'; class PengembangProfilView extends StatelessWidget { @@ -18,10 +20,126 @@ class PengembangProfilView extends StatelessWidget { PengembangProfilViewModel model, Widget? child, ) { - return const Scaffold( - body: Center( - child: Text( - 'PengembangProfilView', + return Scaffold( + body: SafeArea( + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Stack( + children: [ + const CircleAvatar( + radius: 50, + backgroundColor: fontParagraphColor, + // child: model.imageBytes == null + // ? const Icon( + // Icons.person, + // size: 50, + // color: Colors.white, + // ) + // : ClipRRect( + // borderRadius: BorderRadius.circular(50), + // child: Image.memory( + // model.imageBytes!, + // width: 100, + // height: 100, + // fit: BoxFit.cover, + // ), + // ), + child: Icon( + Icons.person, + size: 50, + color: Colors.white, + ), + ), + Positioned( + bottom: 0, + right: 0, + child: CircleAvatar( + radius: 15, + backgroundColor: mainColor, + child: IconButton( + onPressed: () { + // model.addImage(); + }, + icon: const Icon( + Icons.add, + color: backgroundColor, + size: 15, + )), + ), + ), + ], + ), + ), + if (model.level == 'Mandor' && + model.mandorModel != null && + !model.isBusy) + Column( + children: [ + const SizedBox(height: 20), + _FirstDetail( + text: model.mandorModel!.nama!, + icon: Icons.person, + ), + const SizedBox(height: 20), + _FirstDetail( + text: model.mandorModel!.noTelpon!, + icon: Icons.phone, + ), + ], + ), + if (model.level != null && model.level == 'Admin') + const Column( + children: [ + SizedBox(height: 20), + _FirstDetail( + text: 'Admin', + icon: Icons.person, + ), + SizedBox(height: 20), + _FirstDetail( + text: + 'Perumahan Mutiara Alga, Kecamatan Suppa, Kabupaten Pinrang, Sulawesi Selatan, 91131', + icon: Icons.phone, + ), + ], + ), + if (model.isBusy) + const Column( + children: [ + SizedBox(height: 20), + Center(child: CircularProgressIndicator()), + ], + ), + ], + ), + ), + + // create rounded edit button at top right + Positioned( + top: 20, + right: 20, + child: CircleAvatar( + radius: 20, + backgroundColor: mainColor, + child: IconButton( + onPressed: () {}, + icon: const Icon( + Icons.edit, + color: backgroundColor, + size: 15, + ), + ), + ), + ), + ], ), ), ); @@ -29,3 +147,56 @@ class PengembangProfilView extends StatelessWidget { ); } } + +class _FirstDetail extends StatelessWidget { + const _FirstDetail({ + Key? key, + required this.text, + required this.icon, + }) : super(key: key); + + final String text; + final IconData icon; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + icon, + color: mainColor, + size: 40, + ), + const SizedBox( + width: 20, + ), + Expanded( + child: Text( + text, + style: regularTextStyle.copyWith( + fontSize: 15, + color: mainGrey, + ), + ), + ), + // created edit button + // Expanded( + // child: Align( + // alignment: Alignment.centerRight, + // child: IconButton( + // onPressed: () {}, + // icon: const Icon( + // Icons.edit, + // color: mainColor, + // ), + // ), + // ), + // ), + ], + ), + ); + } +} diff --git a/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view_model.dart b/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view_model.dart index 93f50eb..ac554ac 100644 --- a/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view_model.dart +++ b/lib/ui/views/pengembang_index/pengembang_profil/pengembang_profil_view_model.dart @@ -1,5 +1,37 @@ -import 'package:perumahan_bew/app/core/custom_base_view_model.dart'; +import 'package:perumahan_bew/model/my_response_model.dart'; +import 'package:perumahan_bew/model/rumah_model.dart'; + +import '../../../../app/app.logger.dart'; +import '../../../../app/core/custom_base_view_model.dart'; class PengembangProfilViewModel extends CustomBaseViewModel { - Future init() async {} + final log = getLogger('PengembangProfilViewModel'); + String? level; + String? id; + MandorModel? mandorModel; + + Future init() async { + level = await mySharedPrefs.getString('level'); + id = await mySharedPrefs.getString('id'); + log.i('level: $level'); + + if (level == 'Mandor') { + await getData(); + } + notifyListeners(); + } + + getData() async { + setBusy(true); + try { + var response = await httpService.get('mandor?id=$id'); + MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data); + mandorModel = MandorModel.fromJson(myResponseModel.data); + log.i('mandorModel: ${mandorModel!.nama}'); + } catch (e) { + log.e('Error: $e'); + } finally { + setBusy(false); + } + } } diff --git a/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view.dart b/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view.dart index 7023fb8..4c79e50 100644 --- a/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view.dart +++ b/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view.dart @@ -24,6 +24,9 @@ class PerumahanDetailView extends StatelessWidget { ) { return Scaffold( appBar: AppBar( + iconTheme: const IconThemeData( + color: backgroundColor, + ), title: Text( 'Perumahan Blok ${model.blok} , No. ${model.idRumah}', style: const TextStyle( @@ -34,15 +37,7 @@ class PerumahanDetailView extends StatelessWidget { backgroundColor: mainColor, elevation: 0, ), - body: WillPopScope( - onWillPop: () async { - if (model.globalVar.backPressed == 'exitApp') { - // model.back(); - return true; - // model.quitApp(context); - } - return false; - }, + body: SafeArea( child: Stack( children: [ Padding( @@ -190,7 +185,8 @@ class PerumahanDetailView extends StatelessWidget { return Card( child: GestureDetector( onTap: () { - model.log.i('Card $index tapped'); + model.checkProgress( + model.progressModel![index]); }, child: ListTile( title: Text( @@ -245,6 +241,70 @@ class PerumahanDetailView extends StatelessWidget { ), ), ), + // create whatsapp button + Positioned( + top: model.level == 'Mandor' ? 80 : 15, + right: 15, + child: Container( + alignment: Alignment.center, + width: 50, + height: 50, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: greenColor, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 7, + offset: const Offset(0, 3), + ), + ], + ), + child: IconButton( + onPressed: () { + model.openWhatsapp(); + }, + icon: const Icon( + Icons.chat_outlined, + color: Colors.white, + size: 30, + ), + ), + ), + ), + // create call button + Positioned( + top: model.level == 'Mandor' ? 145 : 80, + right: 15, + child: Container( + alignment: Alignment.center, + width: 50, + height: 50, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: mainColor, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.5), + spreadRadius: 2, + blurRadius: 7, + offset: const Offset(0, 3), + ), + ], + ), + child: IconButton( + onPressed: () { + model.call(); + }, + icon: const Icon( + Icons.call_outlined, + color: Colors.white, + size: 30, + ), + ), + ), + ), ], ), ), diff --git a/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view_model.dart b/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view_model.dart index 0e5296c..6f41e98 100644 --- a/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view_model.dart +++ b/lib/ui/views/pengembang_index/perumahan_detail/perumahan_detail_view_model.dart @@ -1,3 +1,5 @@ +import 'package:url_launcher/url_launcher.dart'; + import '../../../../app/app.bottomsheets.dart'; import '../../../../app/app.logger.dart'; import '../../../../app/app.router.dart'; @@ -60,7 +62,9 @@ class PerumahanDetailViewModel extends CustomBaseViewModel { var res = await bottomSheetService.showCustomSheet( variant: BottomSheetType.tambahLihatProgressBottomSheetView, title: 'Form Tambah Progress', - data: idPerumahan, + data: { + 'idPerumahan': idPerumahan, + }, ); if (res!.confirmed) { @@ -72,4 +76,37 @@ class PerumahanDetailViewModel extends CustomBaseViewModel { await getData(); } } + + checkProgress(ProgressModel progressModel) async { + await bottomSheetService.showCustomSheet( + variant: BottomSheetType.tambahLihatProgressBottomSheetView, + title: 'Lihat Progress', + data: { + 'idPerumahan': idPerumahan, + 'progressModel': progressModel, + }, + ); + } + + openWhatsapp() async { + // open whatsapp using url + String noTelpon = rumahModel!.noTelpon!; + // convert the number to international format + noTelpon = noTelpon.replaceAll(RegExp(r'[^0-9]'), ''); + noTelpon = '62${noTelpon.substring(1)}'; + + log.i('no_telpon: $noTelpon'); + final url = Uri.parse('https://wa.me/$noTelpon'); + + if (!await launchUrl(url)) { + throw Exception('Could not launch $url'); + } + } + + call() async { + final Uri callUri = Uri(scheme: 'tel', path: rumahModel!.noTelpon!); + if (!await launchUrl(callUri)) { + throw 'Could not launch ${callUri.toString()}'; + } + } } diff --git a/lib/ui/views/play_video_dialog/play_video_dialog_view.dart b/lib/ui/views/play_video_dialog/play_video_dialog_view.dart index 6bac47b..3d599ab 100644 --- a/lib/ui/views/play_video_dialog/play_video_dialog_view.dart +++ b/lib/ui/views/play_video_dialog/play_video_dialog_view.dart @@ -21,7 +21,7 @@ class PlayVideoDialogView extends StatelessWidget { return ViewModelBuilder.reactive( viewModelBuilder: () => PlayVideoDialogViewModel(), onViewModelReady: (PlayVideoDialogViewModel model) async { - await model.init(); + await model.init(request!.data); }, builder: ( BuildContext context, @@ -34,50 +34,58 @@ class PlayVideoDialogView extends StatelessWidget { // height: 450, padding: const EdgeInsets.all(15), child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - AspectRatio( - aspectRatio: 16 / 11, - child: NativeVideoPlayerView( - onViewReady: (controller) async { - final videoSource = await VideoSource.init( - path: request!.data.toString(), - type: VideoSourceType.file, - ); - await controller.loadVideoSource(videoSource); - model.nativeVideoPlayerController = controller; - model.notifyListeners(); - model.nativeVideoPlayerController!.play(); - // loop video - model.nativeVideoPlayerController!.onPlaybackEnded - .addListener(() { - model.nativeVideoPlayerController!.seekTo(0); - model.nativeVideoPlayerController!.play(); - }); - }, - ), - ), - const SizedBox(height: 20), - // create button to play video - SizedBox( - width: 150, - child: MyButton( - onPressed: () { - model.playVideo = !model.playVideo; - if (model.playVideo) { - model.nativeVideoPlayerController!.play(); - } else { - model.nativeVideoPlayerController!.pause(); - } - model.notifyListeners(); - }, - text: model.playVideo ? 'Pause' : 'Play', - ), - ), - ], - ), - ), + child: model.status != null + ? Column( + mainAxisSize: MainAxisSize.min, + children: [ + AspectRatio( + aspectRatio: 16 / 11, + child: NativeVideoPlayerView( + onViewReady: (controller) async { + final videoSource = await VideoSource.init( + path: model.status == 'file' + ? model.path! + : model.url!, + type: model.status == 'file' + ? VideoSourceType.file + : VideoSourceType.network, + ); + await controller.loadVideoSource(videoSource); + model.nativeVideoPlayerController = controller; + model.notifyListeners(); + model.nativeVideoPlayerController!.play(); + // loop video + model.nativeVideoPlayerController! + .onPlaybackEnded + .addListener(() { + model.nativeVideoPlayerController!.seekTo(0); + model.nativeVideoPlayerController!.play(); + }); + }, + ), + ), + const SizedBox(height: 20), + // create button to play video + SizedBox( + width: 150, + child: MyButton( + onPressed: () { + model.playVideo = !model.playVideo; + if (model.playVideo) { + model.nativeVideoPlayerController!.play(); + } else { + model.nativeVideoPlayerController!.pause(); + } + model.notifyListeners(); + }, + text: model.playVideo ? 'Pause' : 'Play', + ), + ), + ], + ) + : const Center( + child: CircularProgressIndicator(), + )), ), ); }, diff --git a/lib/ui/views/play_video_dialog/play_video_dialog_view_model.dart b/lib/ui/views/play_video_dialog/play_video_dialog_view_model.dart index c409485..dc37d28 100644 --- a/lib/ui/views/play_video_dialog/play_video_dialog_view_model.dart +++ b/lib/ui/views/play_video_dialog/play_video_dialog_view_model.dart @@ -4,5 +4,14 @@ import 'package:perumahan_bew/app/core/custom_base_view_model.dart'; class PlayVideoDialogViewModel extends CustomBaseViewModel { NativeVideoPlayerController? nativeVideoPlayerController; bool playVideo = true; - Future init() async {} + + String? status; + String? url; + String? path; + + Future init(data) async { + status = data['status']; + url = data['url']; + path = data['path']; + } } diff --git a/lib/ui/views/splash_screen/splash_screen_view.dart b/lib/ui/views/splash_screen/splash_screen_view.dart index 435d877..f7736a9 100644 --- a/lib/ui/views/splash_screen/splash_screen_view.dart +++ b/lib/ui/views/splash_screen/splash_screen_view.dart @@ -47,7 +47,7 @@ class SplashScreenView extends StatelessWidget { ), const Expanded(child: SizedBox()), Text( - 'Jl. Raya Mutiara Alga No. 1, \nKec. Ciputat, Kota Tangerang Selatan, \nBanten 15412', + 'Kecamatan Suppa, \nKabupaten Pinrang,\nSulawesi Selatan,91131', style: regularTextStyle.copyWith( color: backgroundColor, fontSize: 12, diff --git a/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view.dart b/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view.dart index 3638819..5d9a984 100644 --- a/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view.dart +++ b/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:native_video_player/native_video_player.dart'; import 'package:perumahan_bew/app/themes/app_text.dart'; import 'package:perumahan_bew/ui/widgets/my_button.dart'; import 'package:perumahan_bew/ui/widgets/my_textformfield.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'package:validatorless/validatorless.dart'; import '../../../app/themes/app_colors.dart'; @@ -70,7 +72,7 @@ class TambahLihatProgressBottomSheetView extends StatelessWidget { children: [ Center( child: Text( - '${request!.title!} ${request!.data.toString().toUpperCase()}', + '${request!.title!} ${request!.data['idPerumahan'].toString().toUpperCase()}', style: boldTextStyle, ), ), @@ -94,8 +96,8 @@ class TambahLihatProgressBottomSheetView extends StatelessWidget { borderRadius: BorderRadius.circular(10), child: GestureDetector( - onTap: () => - model.showImage(context), + onTap: () => model.showImage( + context, 'file', null), child: Image.memory( model.imageVideoBytes!, fit: BoxFit.fill, @@ -139,30 +141,123 @@ class TambahLihatProgressBottomSheetView extends StatelessWidget { ), ), )) - : const Icon( - Icons.credit_card_rounded, - color: Colors.white, - size: 50, - ), + : (model.progressModel != null + ? (model.imageVideoType == 'image' + ? ClipRRect( + borderRadius: + BorderRadius.circular(10), + child: GestureDetector( + onTap: () => model.showImage( + context, + 'network', + dotenv.env['url']! + + model.progressModel! + .img!), + child: Image.network( + dotenv.env['url']! + + model.progressModel! + .img!, + fit: BoxFit.fill, + )), + ) + : ClipRRect( + borderRadius: + BorderRadius.circular(10), + child: AspectRatio( + aspectRatio: 16 / 11, + child: NativeVideoPlayerView( + onViewReady: + (controller) async { + final videoSource = + await VideoSource.init( + path: dotenv.env['url']! + + model.progressModel! + .img!, + type: VideoSourceType + .network, + ); + await controller + .loadVideoSource( + videoSource); + model.nativeVideoPlayerController = + controller; + model.notifyListeners(); + model + .nativeVideoPlayerController! + .play(); + // loop video + model + .nativeVideoPlayerController! + .onPlaybackEnded + .addListener(() { + model + .nativeVideoPlayerController! + .seekTo(0); + model + .nativeVideoPlayerController! + .play(); + }); + }, + ), + ), + )) + : const Icon( + Icons.credit_card_rounded, + color: Colors.white, + size: 50, + )), ), - Positioned( - bottom: 0, - right: 0, - child: CircleAvatar( - radius: 15, - backgroundColor: sixthGrey, - child: IconButton( - onPressed: () { - model.pilihImageVideo(); - }, - icon: const Icon( - Icons.add, - color: backgroundColor3, - size: 15, + if (model.progressModel == null) + Positioned( + bottom: 0, + right: 0, + child: CircleAvatar( + radius: 15, + backgroundColor: sixthGrey, + child: IconButton( + onPressed: () { + model.pilihImageVideo(); + }, + icon: const Icon( + Icons.add, + color: backgroundColor3, + size: 15, + ), + ), + ), + ), + if (model.imageVideoType == 'video') + Positioned( + bottom: 0, + left: 0, + top: 0, + right: 0, + child: Container( + alignment: Alignment.center, + child: CircleAvatar( + radius: 15, + backgroundColor: sixthGrey, + child: IconButton( + onPressed: () { + if (model.progressModel != null) { + model.playVideo( + 'network', + dotenv.env['url']! + + model.progressModel!.img!); + } else { + model.playVideo( + 'file', model.imageVideoPath); + } + }, + icon: const Icon( + Icons.play_arrow, + color: backgroundColor3, + size: 15, + ), + ), ), ), ), - ), ], ), ), @@ -174,54 +269,140 @@ class TambahLihatProgressBottomSheetView extends StatelessWidget { controller: model.ketController, validator: Validatorless.required('Keterangan harus diisi'), + readOnly: model.progressModel != null, ), const SizedBox(height: 20), - Center( - child: SizedBox( - width: 250, - child: MyButton( - text: 'Tambah Progress', - onPressed: () { - if (model.imageVideoBytes == null) { - model.snackbarService.showSnackbar( - message: 'Gambar/video harus diisi', - ); - model.pilihImageVideo(); - return; - } + if (model.progressModel != null) + MyTextFormField( + labelText: 'Waktu', + controller: model.waktuController, + readOnly: true, + ), + if (model.progressModel == null) + Center( + child: SizedBox( + width: 250, + child: MyButton( + text: 'Tambah Progress', + onPressed: () { + if (model.imageVideoBytes == null) { + model.snackbarService.showSnackbar( + message: 'Gambar/video harus diisi', + ); + model.pilihImageVideo(); + return; + } - if (model.globalKey.currentState!.validate()) { - model.dialogService - .showDialog( - title: 'Tambah Progress', - description: 'Apakah anda yakin?', - buttonTitle: 'Ya', - cancelTitle: 'Tidak', - ) - .then((value) async { - if (value!.confirmed) { - // stop playing video - model.nativeVideoPlayerController?.pause(); - model.nativeVideoPlayerController - ?.removeListener(() { - // model.nativeVideoPlayerController?.dispose(); + if (model.globalKey.currentState!.validate()) { + model.dialogService + .showDialog( + title: 'Tambah Progress', + description: 'Apakah anda yakin?', + buttonTitle: 'Ya', + cancelTitle: 'Tidak', + ) + .then((value) async { + if (value!.confirmed) { + // stop playing video + model.nativeVideoPlayerController + ?.pause(); + model.nativeVideoPlayerController + ?.removeListener(() { + // model.nativeVideoPlayerController?.dispose(); + model.nativeVideoPlayerController = + null; + }); model.nativeVideoPlayerController = null; - }); - model.nativeVideoPlayerController = null; - // add progress - bool res = await model.tambahProgress(); - model.log.i('res: $res'); - completer!(SheetResponse( - confirmed: true, - )); - } - }); - } - }, + // add progress + bool res = await model.tambahProgress(); + model.log.i('res: $res'); + completer!(SheetResponse( + confirmed: true, + )); + } + }); + } + }, + ), ), ), - ), + if (model.level == 'Pemilik Rumah' && + model.mandorModel != null) + Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox(height: 20), + MyTextFormField( + labelText: 'Mandor', + controller: model.mandorController, + readOnly: true, + ), + const SizedBox(height: 20), + MyTextFormField( + labelText: 'No. Telp Mandor', + controller: model.noHpController, + readOnly: true, + ), + const SizedBox(height: 20), + // create row with 2 rounded icon , one is chat whatsapp , one is call + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircleAvatar( + radius: 15, + backgroundColor: greenColor, + child: IconButton( + onPressed: () async { + // model.openWhatsapp(); + String noTelpon = + model.noHpController!.text; + // convert the number to international format + noTelpon = noTelpon.replaceAll( + RegExp(r'[^0-9]'), ''); + noTelpon = '62${noTelpon.substring(1)}'; + + // log.i('no_telpon: $noTelpon'); + final url = + Uri.parse('https://wa.me/$noTelpon'); + + if (!await launchUrl(url)) { + throw Exception( + 'Could not launch $url'); + } + }, + icon: const Icon( + Icons.chat, + color: backgroundColor3, + size: 15, + ), + ), + ), + const SizedBox(width: 20), + CircleAvatar( + radius: 15, + backgroundColor: mainColor, + child: IconButton( + onPressed: () async { + // model.callPhone(); + final Uri callUri = Uri( + scheme: 'tel', + path: model.noHpController!.text); + if (!await launchUrl(callUri)) { + throw 'Could not launch ${callUri.toString()}'; + } + }, + icon: const Icon( + Icons.call, + color: backgroundColor3, + size: 15, + ), + ), + ), + ], + ), + ], + ), ], ), ), diff --git a/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view_model.dart b/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view_model.dart index 7669420..a5644ad 100644 --- a/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view_model.dart +++ b/lib/ui/views/tambah_lihat_progress_bottom_sheet/tambah_lihat_progress_bottom_sheet_view_model.dart @@ -5,22 +5,31 @@ import 'package:easy_image_viewer/easy_image_viewer.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:native_video_player/native_video_player.dart'; +import 'package:perumahan_bew/model/rumah_model.dart'; import '../../../app/app.dialogs.dart'; import '../../../app/app.logger.dart'; import '../../../app/core/custom_base_view_model.dart'; import '../../../app/themes/app_colors.dart'; +import '../../../model/my_response_model.dart'; class TambahLihatProgressBottomSheetViewModel extends CustomBaseViewModel { final log = getLogger('TambahLihatProgressBottomSheetViewModel'); NativeVideoPlayerController? nativeVideoPlayerController; + String? level; + MandorModel? mandorModel; + TextEditingController? mandorController = TextEditingController(); + TextEditingController? noHpController = TextEditingController(); + String? idPerumahan; + ProgressModel? progressModel; // form variable final globalKey = GlobalKey(); TextEditingController? ketController = TextEditingController(); + TextEditingController? waktuController = TextEditingController(); // image video variable // image picker @@ -29,9 +38,40 @@ class TambahLihatProgressBottomSheetViewModel extends CustomBaseViewModel { XFile? imageVideoFile; Uint8List? imageVideoBytes; String? imageVideoType; - Future init(String data) async { + Future init(data) async { globalVar.backPressed = "exitApp"; - idPerumahan = data; + idPerumahan = data['idPerumahan']; + // log.i(data['progressModel']); + + if (data['progressModel'] != null) { + progressModel = data['progressModel']; + ketController!.text = progressModel!.ket!; + waktuController!.text = progressModel!.createdAt!; + log.i('type: ${progressModel!.type}'); + imageVideoType = progressModel!.type; + } + + level = await mySharedPrefs.getString('level'); + if (level == 'Pemilik Rumah') { + await getData(); + } + } + + getData() async { + setBusy(true); + try { + var response = + await httpService.get('mandor?id=${progressModel!.idMandor}'); + MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data); + mandorModel = MandorModel.fromJson(myResponseModel.data); + log.i('mandorModel: ${mandorModel!.nama}'); + mandorController!.text = mandorModel!.nama!; + noHpController!.text = mandorModel!.noTelpon!; + } catch (e) { + log.e('Error: $e'); + } finally { + setBusy(false); + } } addImage(String type) async { @@ -79,13 +119,20 @@ class TambahLihatProgressBottomSheetViewModel extends CustomBaseViewModel { }); } - playVideo() async { + playVideo(String status, String? url) async { // play video by imageVideoPath + log.i('play video'); + log.i(status); + log.i(url); await dialogService.showCustomDialog( variant: DialogType.playVideoDialogView, title: 'Video', - data: imageVideoPath, + data: { + 'status': status, + 'url': url, + 'path': imageVideoPath, + }, ); } @@ -117,13 +164,20 @@ class TambahLihatProgressBottomSheetViewModel extends CustomBaseViewModel { } } - showImage(BuildContext context) async { + showImage(BuildContext context, String status, String? url) async { + log.i(status); + log.i(url); showImageViewer( context, - Image.memory( - imageVideoBytes!, - fit: BoxFit.fill, - ).image, + status == 'file' + ? Image.memory( + imageVideoBytes!, + fit: BoxFit.fill, + ).image + : Image.network( + url!, + fit: BoxFit.fill, + ).image, swipeDismissible: true, doubleTapZoomable: true, ); diff --git a/lib/ui/views/user_index/user_home/user_home_view.dart b/lib/ui/views/user_index/user_home/user_home_view.dart deleted file mode 100644 index eacf2f3..0000000 --- a/lib/ui/views/user_index/user_home/user_home_view.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stacked/stacked.dart'; -import 'package:webview_flutter/webview_flutter.dart'; - -import './user_home_view_model.dart'; - -class UserHomeView extends StatelessWidget { - const UserHomeView({super.key}); - - @override - Widget build(BuildContext context) { - return ViewModelBuilder.nonReactive( - viewModelBuilder: () => UserHomeViewModel(), - onViewModelReady: (UserHomeViewModel model) async { - await model.init(); - }, - disposeViewModel: false, - fireOnViewModelReadyOnce: true, - builder: ( - BuildContext context, - UserHomeViewModel model, - Widget? child, - ) { - return Scaffold( - body: WebView( - // initialUrl: 'http://192.168.43.125/rekam-medis', - initialUrl: 'http://20.20.20.25/perumahan', - javascriptMode: JavascriptMode.unrestricted, - onWebViewCreated: (WebViewController webViewController) { - // _controller.complete(webViewController); - model.webViewControllerCompleter.future - .then((value) => model.webVIewcontroller = value); - model.webViewControllerCompleter.complete(webViewController); - }, - onProgress: (int progress) { - double progressDouble = progress / 100; - model.myEasyLoading.showProgress(progressDouble, "Loading Denah"); - }, - // javascriptChannels: { - // _toasterJavascriptChannel(context), - // }, - javascriptChannels: { - JavascriptChannel( - name: 'messageHandler', - onMessageReceived: (JavascriptMessage message) { - model.log.d(message.message); - // dev.i("message from the web view=\"${message.message}\""); - // if (message.message == "coba") { - // dev.i("sini untuk coba"); - // controller.runJavascript("coba22('heheheh')"); - // } - }, - ), - }, - // navigationDelegate: (NavigationRequest request) async {}, - onPageStarted: (String url) {}, - onPageFinished: (String url) { - // dev.i('Page finished loading: $url'); - model.myEasyLoading.dismissLoading(); - }, - - gestureNavigationEnabled: true, - backgroundColor: const Color(0x00000000), - ), - ); - }, - ); - } -} diff --git a/lib/ui/views/user_index/user_home/user_home_view_model.dart b/lib/ui/views/user_index/user_home/user_home_view_model.dart deleted file mode 100644 index 7138369..0000000 --- a/lib/ui/views/user_index/user_home/user_home_view_model.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:webview_flutter/webview_flutter.dart'; - -import '../../../../app/app.locator.dart'; -import '../../../../app/app.logger.dart'; -import '../../../../app/core/custom_base_view_model.dart'; -import '../../../../services/my_easyloading.dart'; - -class UserHomeViewModel extends CustomBaseViewModel { - final log = getLogger('UserHomeViewModel'); - final _myEasyLoading = locator(); - - get myEasyLoading => _myEasyLoading; - late WebViewController webVIewcontroller; - final Completer webViewControllerCompleter = - Completer(); - - Future init() async { - if (Platform.isAndroid) { - WebView.platform = SurfaceAndroidWebView(); - } - } -} diff --git a/lib/ui/views/user_index/user_index_view.dart b/lib/ui/views/user_index/user_index_view.dart index ac3813c..9f76bd0 100644 --- a/lib/ui/views/user_index/user_index_view.dart +++ b/lib/ui/views/user_index/user_index_view.dart @@ -38,10 +38,22 @@ class UserIndexView extends StatelessWidget { backgroundColor: mainColor, elevation: 0, automaticallyImplyLeading: false, + actions: [ + // create logout button + IconButton( + onPressed: () { + model.logout(); + }, + icon: const Icon( + Icons.logout, + color: Colors.white, + ), + ), + ], ), // extendBody: true, body: ExtendedNavigator( - navigatorKey: StackedService.nestedNavigationKey(2), + navigatorKey: StackedService.nestedNavigationKey(7), router: UserIndexViewRouter(), ), bottomNavigationBar: StylishBottomBar( diff --git a/lib/ui/views/user_index/user_index_view_model.dart b/lib/ui/views/user_index/user_index_view_model.dart index 2a652ef..750e875 100644 --- a/lib/ui/views/user_index/user_index_view_model.dart +++ b/lib/ui/views/user_index/user_index_view_model.dart @@ -5,10 +5,14 @@ import 'package:stacked_services/stacked_services.dart'; import '../../../app/app.locator.dart'; import '../../../app/app.logger.dart'; import '../../../app/app.router.dart'; +import '../../../services/shared_prefs.dart'; class UserIndexViewModel extends IndexTrackingViewModel { final log = getLogger('UserIndexViewModel'); final _navigationService = locator(); + final _dialogService = locator(); + final _mySharedPrefs = locator(); + final _snackbarService = locator(); final _bottomNavBarList = [ { @@ -16,22 +20,18 @@ class UserIndexViewModel extends IndexTrackingViewModel { 'icon': Icons.list_alt_rounded, 'header': 'List Perumahan' }, - {'name': 'Denah', 'icon': Icons.home_outlined, 'header': 'Denah Perumahan'}, {'name': 'Profil', 'icon': Icons.person_outline, 'header': 'Profil'}, ]; List> get bottomNavBarList => _bottomNavBarList; final List _views = [ - UserIndexViewRoutes.userListPembangunanView, - UserIndexViewRoutes.userHomeView, + UserIndexViewRoutes.userListPembangunanPageView, UserIndexViewRoutes.userProfileView, ]; String header = 'Denah Perumahan'; - Future init() async { - setIndex(1); - } + Future init() async {} void handleNavigation(int index) { log.d("handleNavigation: $index"); @@ -43,7 +43,29 @@ class UserIndexViewModel extends IndexTrackingViewModel { header = _bottomNavBarList[index]['header'] as String; _navigationService.navigateTo( _views[index], - id: 2, + id: 7, ); } + + logout() { + _dialogService + .showConfirmationDialog( + title: 'Logout', + description: 'Apakah Anda yakin ingin logout?', + cancelTitle: 'Batal', + confirmationTitle: 'Logout', + ) + .then((value) async { + if (value!.confirmed) { + await _mySharedPrefs.clear(); + _navigationService.clearStackAndShow(Routes.loginScreenView); + _snackbarService.showSnackbar( + message: 'Logout berhasil', + duration: const Duration(seconds: 2), + ); + } + }); + // await _mySharedPrefs.clear(); + // _navigationService.clearStackAndShow(Routes.loginScreenView); + } } diff --git a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart new file mode 100644 index 0000000..3aec192 --- /dev/null +++ b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:perumahan_bew/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart'; +import 'package:stacked/stacked.dart'; + +import './user_list_pembangunan_page_view_model.dart'; + +class UserListPembangunanPageView extends StatelessWidget { + const UserListPembangunanPageView({super.key}); + + @override + Widget build(BuildContext context) { + return ViewModelBuilder.nonReactive( + viewModelBuilder: () => UserListPembangunanPageViewModel(), + onViewModelReady: (UserListPembangunanPageViewModel model) async { + await model.init(); + }, + builder: ( + BuildContext context, + UserListPembangunanPageViewModel model, + Widget? child, + ) { + return const UserListPembangunanView(); + }, + ); + } +} diff --git a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view_model.dart b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view_model.dart new file mode 100644 index 0000000..03c5565 --- /dev/null +++ b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_page/user_list_pembangunan_page_view_model.dart @@ -0,0 +1,5 @@ +import 'package:perumahan_bew/app/core/custom_base_view_model.dart'; + +class UserListPembangunanPageViewModel extends CustomBaseViewModel { + Future init() async {} +} diff --git a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart index 139f5bd..9ba06a8 100644 --- a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart +++ b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view.dart @@ -25,24 +25,14 @@ class UserListPembangunanView extends StatelessWidget { body: Column( children: [ const SizedBox(height: 20), - const Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - MyTopWidget( - icon: Icons.list_alt_outlined, - title: 'Pembangunan', - subtitle: '15 kali', - // lastUpdate: '31/02/15 - 10.00 am', - ), - MyTopWidget( - icon: Icons.home, - title: 'Progress', - subtitle: '76 %', - // lastUpdate: '31/02/15 - 10.00 am', - ), - ], + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: MyTopWidget( + icon: Icons.list_alt_outlined, + title: 'Pembangunan', + subtitle: + '${model.listProgress != null ? model.listProgress!.length : 0} Progress', + // lastUpdate: '31/02/15 - 10.00 am', ), ), const SizedBox(height: 25), @@ -63,27 +53,47 @@ class UserListPembangunanView extends StatelessWidget { ], ), // create a listview with 20 dummy data on card and scrollable - child: ListView.builder( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 10), - itemCount: 20, - itemBuilder: (context, index) { - return Card( - child: GestureDetector( - onTap: () { - model.log.i('Card $index tapped'); - }, - child: ListTile( - title: Text('1/02/15 - 10.00 am', - style: boldTextStyle.copyWith( - fontSize: 13, color: mainColor)), - subtitle: Text('Progress $index'), - trailing: Text('Pembangunan $index'), - ), - ), - ); - }, - )), + child: model.isBusy + ? const Center(child: CircularProgressIndicator()) + : model.status == false + ? const Center(child: Text('Error Loading Data')) + : model.listProgress!.isEmpty + ? const Center(child: Text('Data Kosong')) + : ListView.builder( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 10), + itemCount: model.listProgress!.length, + itemBuilder: (context, index) { + return Card( + child: ListTile( + title: Text( + model.listProgress![index] + .createdAt!, + style: boldTextStyle.copyWith( + fontSize: 13, + color: mainColor, + ), + ), + subtitle: Text(model + .listProgress![index].ket!), + // create icon show + trailing: CircleAvatar( + backgroundColor: mainColor, + child: IconButton( + icon: const Icon( + Icons.list_alt_outlined, + color: backgroundColor, + ), + onPressed: () { + model.checkProgress(model + .listProgress![index]); + }, + ), + ), + ), + ); + }, + )), ), ), const SizedBox(height: 20), diff --git a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view_model.dart b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view_model.dart index 975e92b..7d2f647 100644 --- a/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view_model.dart +++ b/lib/ui/views/user_index/user_list_pembangunan/user_list_pembangunan_view_model.dart @@ -1,8 +1,52 @@ -import 'package:perumahan_bew/app/core/custom_base_view_model.dart'; +import 'package:perumahan_bew/model/rumah_model.dart'; +import '../../../../app/app.bottomsheets.dart'; import '../../../../app/app.logger.dart'; +import '../../../../app/core/custom_base_view_model.dart'; +import '../../../../model/my_response_model.dart'; class UserListPembangunanViewModel extends CustomBaseViewModel { final log = getLogger('UserListPembangunanViewModel'); - Future init() async {} + bool status = false; + RumahDetailModel? rumahDetailModel; + RumahModel? rumahModel; + List? listProgress; + + Future init() async { + String idRumah = await mySharedPrefs.getString('id') ?? ''; + + if (idRumah.isNotEmpty) { + await getData(idRumah); + } + } + + getData(String idRumah) async { + setBusy(true); + try { + var response = await httpService.get('rumah?id=$idRumah'); + MyResponseModel myResponse = MyResponseModel.fromJson(response.data); + // log.i(myResponse.toJson()); + RumahDetailModel rumahDetailModel = + RumahDetailModel.fromJson(myResponse.data); + listProgress = rumahDetailModel.progressModel; + + status = true; + } catch (e) { + status = false; + log.e(e); + } finally { + setBusy(false); + } + } + + checkProgress(ProgressModel progressModel) async { + await bottomSheetService.showCustomSheet( + variant: BottomSheetType.tambahLihatProgressBottomSheetView, + title: 'Lihat Progress', + data: { + 'idPerumahan': progressModel.idRumah, + 'progressModel': progressModel, + }, + ); + } } diff --git a/lib/ui/views/user_index/user_profile/user_profile_view.dart b/lib/ui/views/user_index/user_profile/user_profile_view.dart index 2b7e5e2..a93e37e 100644 --- a/lib/ui/views/user_index/user_profile/user_profile_view.dart +++ b/lib/ui/views/user_index/user_profile/user_profile_view.dart @@ -21,99 +21,118 @@ class UserProfileView extends StatelessWidget { Widget? child, ) { return Scaffold( - body: Stack( - children: [ - Column( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(20), + child: Stack( children: [ - const SizedBox( - height: 25, - ), - // create a rounded container - Center( - child: Container( - width: 150, - height: 150, - decoration: BoxDecoration( - shape: BoxShape.circle, - image: DecorationImage( - image: const NetworkImage( - 'http://kicap-karan.com/assets/img/me.jpg', - ), - fit: BoxFit.cover, - onError: (exception, stackTrace) { - model.log.e('Error: $exception'); - }, - ), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.5), - spreadRadius: 2, - blurRadius: 7, - offset: const Offset(0, 3), - ), - ], - ), - ), - ), - const SizedBox( - height: 15, - ), - Center( - child: Text( - 'Kicap Karan', - style: boldTextStyle.copyWith( - fontSize: 18, - ), - ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 30, vertical: 10), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + Column( + children: [ + // create a rounded container + Center( + child: Stack( children: [ - for (var i = 0; i < 10; i++) const _DetailChild(), + const CircleAvatar( + radius: 50, + backgroundColor: fontParagraphColor, + // child: model.imageBytes == null + // ? const Icon( + // Icons.person, + // size: 50, + // color: Colors.white, + // ) + // : ClipRRect( + // borderRadius: BorderRadius.circular(50), + // child: Image.memory( + // model.imageBytes!, + // width: 100, + // height: 100, + // fit: BoxFit.cover, + // ), + // ), + child: Icon( + Icons.person, + size: 50, + color: Colors.white, + ), + ), + Positioned( + bottom: 0, + right: 0, + child: CircleAvatar( + radius: 15, + backgroundColor: mainColor, + child: IconButton( + onPressed: () { + // model.addImage(); + }, + icon: const Icon( + Icons.add, + color: fontColor, + size: 15, + )), + ), + ), ], ), ), - ), + if (!model.isBusy && + model.status == true && + model.rumahModel != null) + Expanded( + child: Column( + children: [ + const SizedBox( + height: 15, + ), + _DetailChild( + text: model.rumahModel!.pemilik!, + icon: Icons.person, + ), + _DetailChild( + text: model.rumahModel!.tanggalPembelian!, + icon: Icons.calendar_today_outlined, + ), + _DetailChild( + text: "Rp. ${model.rumahModel!.harga!}", + icon: Icons.attach_money_outlined, + ), + _DetailChild( + text: 'Rp. ${model.rumahModel!.cicilan!}', + icon: Icons.money_outlined, + ), + ], + ), + ), + if (model.isBusy) + const Expanded( + child: Center( + child: CircularProgressIndicator(), + ), + ), + ], ), - const SizedBox( - height: 15, + // create rounded button with edit on top right + Positioned( + top: 0, + right: 0, + child: CircleAvatar( + radius: 15, + backgroundColor: mainColor, + child: IconButton( + onPressed: () { + // model.addImage(); + }, + icon: const Icon( + Icons.edit, + color: fontColor, + size: 15, + )), + ), ), ], ), - Positioned( - top: 15, - right: 65, - child: IconButton( - onPressed: () { - model.log.i('Edit Profile'); - }, - icon: const Icon( - Icons.edit, - color: mainColor, - size: 30, - ), - ), - ), - Positioned( - top: 15, - right: 15, - child: IconButton( - onPressed: () { - model.log.i('Logout'); - model.logout(); - }, - icon: const Icon( - Icons.logout, - color: mainColor, - size: 30, - ), - )), - ], + ), ), ); }, @@ -124,8 +143,13 @@ class UserProfileView extends StatelessWidget { class _DetailChild extends StatelessWidget { const _DetailChild({ Key? key, + required this.text, + required this.icon, }) : super(key: key); + final String text; + final IconData icon; + @override Widget build(BuildContext context) { return Padding( @@ -133,8 +157,8 @@ class _DetailChild extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - const Icon( - Icons.maps_home_work_outlined, + Icon( + icon, color: mainColor, size: 40, ), @@ -142,7 +166,7 @@ class _DetailChild extends StatelessWidget { width: 20, ), Text( - 'Jln 2, Blok C, No 2', + text, style: regularTextStyle.copyWith( fontSize: 15, color: mainGrey, diff --git a/lib/ui/views/user_index/user_profile/user_profile_view_model.dart b/lib/ui/views/user_index/user_profile/user_profile_view_model.dart index 940e3f8..c803fe3 100644 --- a/lib/ui/views/user_index/user_profile/user_profile_view_model.dart +++ b/lib/ui/views/user_index/user_profile/user_profile_view_model.dart @@ -1,11 +1,43 @@ import 'package:perumahan_bew/app/core/custom_base_view_model.dart'; import '../../../../app/app.logger.dart'; +import '../../../../model/my_response_model.dart'; +import '../../../../model/rumah_model.dart'; class UserProfileViewModel extends CustomBaseViewModel { final log = getLogger('UserProfileViewModel'); + RumahDetailModel? rumahDetailModel; + RumahModel? rumahModel; + bool status = false; + String? idRumah; - Future init() async {} + Future init() async { + idRumah = await mySharedPrefs.getString('id') ?? ''; + if (idRumah != '') { + await getData(); + } + // await getData(); + } + + getData() async { + setBusy(true); + try { + var response = await httpService.get('rumah?id=$idRumah'); + MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data); + // log.i('myResponseModel: ${myResponseModel.data}'); + rumahDetailModel = RumahDetailModel.fromJson(myResponseModel.data); + rumahModel = rumahDetailModel!.rumahModel; + // rumahModel = RumahModel.fromJson(myResponseModel.data); + log.i('rumahModel: ${rumahModel!.toJson()}'); + + status = true; + } catch (e) { + log.e('Error: $e'); + status = false; + } finally { + setBusy(false); + } + } logout() { log.i('logout'); diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 64a0ece..7299b5c 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,9 +7,13 @@ #include "generated_plugin_registrant.h" #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2db3c22..786ff5c 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_linux + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index eb040e5..d993eb7 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,13 +6,13 @@ import FlutterMacOS import Foundation import file_selector_macos -import location import path_provider_foundation import shared_preferences_foundation +import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) - LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index c8c5c24..e559182 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -512,30 +512,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" - location: - dependency: "direct main" - description: - name: location - sha256: "9051959f6f2ccadd887b28b66e9cbbcc25b6838e37cf9e894c421ccc0ebf80b5" - url: "https://pub.dev" - source: hosted - version: "4.4.0" - location_platform_interface: - dependency: transitive - description: - name: location_platform_interface - sha256: "62eeaf1658e92e4459b727f55a3c328eccbac8ba043fa6d262ac5286ad48384c" - url: "https://pub.dev" - source: hosted - version: "2.3.0" - location_web: - dependency: transitive - description: - name: location_web - sha256: "6c08c408a040534c0269c4ff9fe17eebb5a36dea16512fbaf116b9c8bc21545b" - url: "https://pub.dev" - source: hosted - version: "3.1.1" logger: dependency: transitive description: @@ -949,6 +925,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" + url: "https://pub.dev" + source: hosted + version: "6.1.14" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: ba140138558fcc3eead51a1c42e92a9fb074a1b1149ed3c73e66035b2ccd94f2 + url: "https://pub.dev" + source: hosted + version: "2.0.19" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" + url: "https://pub.dev" + source: hosted + version: "3.1.0" validatorless: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3d6b778..3e2efb6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,7 @@ dependencies: path_provider: ^2.0.9 dio: flutter_easyloading: - location: ^4.4.0 + # location: ^4.4.0 # flutter_inappwebview: webview_flutter: ^3.0.4 google_fonts: @@ -54,6 +54,7 @@ dependencies: omni_datetime_picker: easy_image_viewer: native_video_player: + url_launcher: dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 77ab7a0..043a96f 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,8 +7,11 @@ #include "generated_plugin_registrant.h" #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index a423a02..a95e267 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST