complete admin, mandor and user page
This commit is contained in:
@ -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(
|
||||
|
||||
@ -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,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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: <JavascriptChannel>{
|
||||
// _toasterJavascriptChannel(context),
|
||||
// },
|
||||
javascriptChannels: <JavascriptChannel>{
|
||||
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: <JavascriptChannel>{
|
||||
// _toasterJavascriptChannel(context),
|
||||
// },
|
||||
javascriptChannels: <JavascriptChannel>{
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -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<WebViewController> webViewControllerCompleter =
|
||||
Completer<WebViewController>();
|
||||
|
||||
Future<void> init() async {
|
||||
// Future.delayed(const Duration(milliseconds: 1), () {
|
||||
// status = false;
|
||||
// notifyListeners();
|
||||
// });
|
||||
globalVar.backPressed = "exitApp";
|
||||
url = dotenv.env['url']!;
|
||||
log.d(url);
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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<NavigationService>();
|
||||
final _dialogService = locator<DialogService>();
|
||||
final _mySharedPrefs = locator<MySharedPrefs>();
|
||||
final _snackbarService = locator<SnackbarService>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<void> init() async {}
|
||||
final log = getLogger('PengembangProfilViewModel');
|
||||
String? level;
|
||||
String? id;
|
||||
MandorModel? mandorModel;
|
||||
|
||||
Future<void> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -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()}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user