first commit
This commit is contained in:
63
lib/ui/views/action_dialog/action_dialog_view.dart
Normal file
63
lib/ui/views/action_dialog/action_dialog_view.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kamus_kesehatan/model/istilah_model.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import './action_dialog_view_model.dart';
|
||||
|
||||
class ActionDialogView extends StatelessWidget {
|
||||
final DialogRequest<IstilahModel> request;
|
||||
final Function(DialogResponse) completer;
|
||||
|
||||
const ActionDialogView({
|
||||
Key? key,
|
||||
required this.request,
|
||||
required this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<ActionDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => ActionDialogViewModel(),
|
||||
onViewModelReady: (ActionDialogViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
ActionDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
// create a row with 2 circle icon , 1 is whataspp icon, 2 is bookmark, no need text
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.green,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.phone),
|
||||
onPressed: () {
|
||||
// completer(DialogResponse(confirmed: true));
|
||||
model.openWhatsapp();
|
||||
},
|
||||
),
|
||||
),
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.blue,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.bookmark),
|
||||
onPressed: () {
|
||||
model.addBookmark(request.data!);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
90
lib/ui/views/action_dialog/action_dialog_view_model.dart
Normal file
90
lib/ui/views/action_dialog/action_dialog_view_model.dart
Normal file
@ -0,0 +1,90 @@
|
||||
import '../../../app/app.dialogs.dart';
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/istilah_model.dart';
|
||||
import '../../../services/my_storage.dart';
|
||||
|
||||
class ActionDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('ActionDialogViewModel');
|
||||
final myStorage = locator<MyStorage>();
|
||||
IstilahModel? data;
|
||||
|
||||
Future<void> init(IstilahModel? data) async {
|
||||
// log.i('init');
|
||||
// log.i(data!.istilah.toString());
|
||||
// log.i(data.arti.toString());
|
||||
this.data = data;
|
||||
// await myStorage.clear();
|
||||
}
|
||||
|
||||
addBookmark(IstilahModel istilahModel) async {
|
||||
List<dynamic>? listBookmark;
|
||||
|
||||
listBookmark = await myStorage.read('listBookmark');
|
||||
|
||||
listBookmark ??= [];
|
||||
|
||||
log.i('ini panjang listBookmark ${listBookmark.length}');
|
||||
log.i('ini listBookmark $listBookmark');
|
||||
|
||||
// check if istilahModel is already in listBookmark
|
||||
bool isExist = false;
|
||||
for (var item in listBookmark) {
|
||||
if (item['istilah'] == istilahModel.istilah) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isExist) {
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Bookmark sudah ada',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
listBookmark.add({
|
||||
'istilah': istilahModel.istilah,
|
||||
'arti': istilahModel.arti,
|
||||
});
|
||||
|
||||
await myStorage.write('listBookmark', listBookmark);
|
||||
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Berhasil menambahkan bookmark',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
|
||||
// // check if istilahModel is already in listBookmark
|
||||
// bool isExist = false;
|
||||
// for (var item in listBookmark) {
|
||||
// if (item.istilah == istilahModel.istilah) {
|
||||
// isExist = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!isExist) {
|
||||
// listBookmark.add(istilahModel);
|
||||
// await myStorage.write('listBookmark', listBookmark);
|
||||
// snackbarService.showSnackbar(
|
||||
// message: 'Berhasil menambahkan bookmark',
|
||||
// duration: const Duration(seconds: 2),
|
||||
// );
|
||||
// } else {
|
||||
// snackbarService.showSnackbar(
|
||||
// message: 'Bookmark sudah ada',
|
||||
// duration: const Duration(seconds: 2),
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
openWhatsapp() async {
|
||||
await dialogService.showCustomDialog(
|
||||
variant: DialogType.nomorTelponDialogView,
|
||||
data: data,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kamus_kesehatan/ui/widgets/my_textformfield.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import './nomor_telpon_dialog_view_model.dart';
|
||||
|
||||
class NomorTelponDialogView extends StatelessWidget {
|
||||
final DialogRequest? request;
|
||||
final Function(DialogResponse)? completer;
|
||||
|
||||
const NomorTelponDialogView({
|
||||
Key? key,
|
||||
this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<NomorTelponDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => NomorTelponDialogViewModel(),
|
||||
onViewModelReady: (NomorTelponDialogViewModel model) async {
|
||||
await model.init(request!.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
NomorTelponDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
MyTextFormField(
|
||||
controller: model.nomorTelponController,
|
||||
hintText: 'Nomor Telpon',
|
||||
keyboardType: TextInputType.phone,
|
||||
maxLength: 13,
|
||||
validator: Validatorless.multiple([
|
||||
Validatorless.required(
|
||||
'Nomor Telpon tidak boleh kosong'),
|
||||
Validatorless.number('Nomor Telpon harus angka'),
|
||||
Validatorless.min(10, 'Nomor Telpon minimal 10 digit'),
|
||||
Validatorless.regex(
|
||||
RegExp(r'^[0-9]*$'), 'Nomor Telpon tidak valid')
|
||||
])),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
completer!(DialogResponse(confirmed: false)),
|
||||
child: const Text(
|
||||
'Batal',
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
model.openWhatsapp();
|
||||
}
|
||||
},
|
||||
child: const Text('Share'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/istilah_model.dart';
|
||||
|
||||
class NomorTelponDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('NomorTelponDialogViewModel');
|
||||
TextEditingController nomorTelponController = TextEditingController();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
IstilahModel? data;
|
||||
Future<void> init(IstilahModel data) async {
|
||||
log.i('init');
|
||||
log.i(data.istilah.toString());
|
||||
log.i(data.arti.toString());
|
||||
this.data = data;
|
||||
// await myStorage.clear();
|
||||
}
|
||||
|
||||
openWhatsapp() async {
|
||||
// open whatsapp using url
|
||||
String noTelpon = nomorTelponController.text;
|
||||
// convert the number to international format
|
||||
noTelpon = noTelpon.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
noTelpon = '62${noTelpon.substring(1)}';
|
||||
|
||||
log.i('no_telpon: $noTelpon');
|
||||
// add the data to url with query parameter
|
||||
final url = Uri.parse('https://wa.me/$noTelpon?text=Kamus Medis : \n'
|
||||
'Istilah : ${data!.istilah}\n'
|
||||
'Arti : ${data!.arti}');
|
||||
|
||||
if (!await launchUrl(url)) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
}
|
||||
}
|
94
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
94
lib/ui/views/splash_screen/splash_screen_view.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './splash_screen_view_model.dart';
|
||||
|
||||
class SplashScreenView extends StatelessWidget {
|
||||
const SplashScreenView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<SplashScreenViewModel>.nonReactive(
|
||||
viewModelBuilder: () => SplashScreenViewModel(),
|
||||
onViewModelReady: (SplashScreenViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
SplashScreenViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
// backgroundColor: warningColor,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'KAMUS MEDIS DAN KESEHATAN',
|
||||
style: boldTextStyle.copyWith(
|
||||
// color: backgroundColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
// Text(
|
||||
// '(Survei App)',
|
||||
// style: boldTextStyle.copyWith(
|
||||
// // color: backgroundColor,
|
||||
// fontStyle: FontStyle.italic,
|
||||
// ),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
const Expanded(child: SizedBox()),
|
||||
Text(
|
||||
'Created By',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'Kicap Karan',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
'www.kicap-karan.com',
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
16
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
16
lib/ui/views/splash_screen/splash_screen_view_model.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../services/my_tts.dart';
|
||||
|
||||
class SplashScreenViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('SplashScreenViewModel');
|
||||
final myTts = locator<MyTts>();
|
||||
Future<void> init() async {
|
||||
await myTts.init();
|
||||
// await 3 seconds then go to login
|
||||
// await Future.delayed(const Duration(seconds: 3));
|
||||
await navigationService.navigateTo(Routes.userTrackingIndexView);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kamus_kesehatan/app/themes/app_text.dart';
|
||||
import 'package:kamus_kesehatan/ui/widgets/my_textformfield.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import './list_kamus_kesehatan_view_model.dart';
|
||||
|
||||
class ListKamusKesehatanView extends StatelessWidget {
|
||||
const ListKamusKesehatanView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<ListKamusKesehatanViewModel>.reactive(
|
||||
viewModelBuilder: () => ListKamusKesehatanViewModel(),
|
||||
onViewModelReady: (ListKamusKesehatanViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
ListKamusKesehatanViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(25),
|
||||
child: Column(
|
||||
children: [
|
||||
MyTextFormField(
|
||||
hintText: 'Cari istilah',
|
||||
labelText: 'Cari istilah',
|
||||
controller: model.searchController,
|
||||
suffixIcon: const Icon(Icons.search),
|
||||
onChanged: (String value) {
|
||||
model.searchIstilah();
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: model.listIstilah.isEmpty
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: model.listIstilah.length,
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
model.listIstilah[index].istilah!.toUpperCase(),
|
||||
style: boldTextStyle,
|
||||
),
|
||||
subtitle: Text(model.listIstilah[index].arti!),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
model.cekSuara(model.listIstilah[index]);
|
||||
},
|
||||
child: const Icon(Icons.volume_up),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.bukaDialogAksi(
|
||||
model.listIstilah[index]);
|
||||
},
|
||||
icon: const Icon(Icons.info),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.locator.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/istilah_model.dart';
|
||||
import '../../../../services/my_tts.dart';
|
||||
|
||||
class ListKamusKesehatanViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('ListKamusKesehatanViewModel');
|
||||
final myTts = locator<MyTts>();
|
||||
|
||||
TextEditingController searchController = TextEditingController();
|
||||
|
||||
List<IstilahModel> listIstilah = [];
|
||||
List<IstilahModel> allListIstilah = [];
|
||||
|
||||
Future<void> init() async {
|
||||
// await myTts.init();
|
||||
// myTts.getVoices();
|
||||
listIstilah = await rootBundle.loadString('assets/dataset.json').then(
|
||||
(String data) {
|
||||
final List<dynamic> jsonData = json.decode(data);
|
||||
return jsonData.map((dynamic item) {
|
||||
return IstilahModel.fromJson(item as Map<String, dynamic>);
|
||||
}).toList();
|
||||
},
|
||||
);
|
||||
allListIstilah = listIstilah;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
cekSuara(IstilahModel listIstilah) {
|
||||
myTts.stop();
|
||||
// speak the listIstilah.istilah and wait 2 seconds then speak the listIstilah.arti
|
||||
myTts.speak(listIstilah.istilah!);
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
myTts.speak(listIstilah.arti!);
|
||||
});
|
||||
}
|
||||
|
||||
searchIstilah() {
|
||||
if (searchController.text.isEmpty) {
|
||||
listIstilah = allListIstilah;
|
||||
} else {
|
||||
listIstilah = allListIstilah
|
||||
.where((IstilahModel istilah) => istilah.istilah!
|
||||
.toLowerCase()
|
||||
.contains(searchController.text.toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bukaDialogAksi(IstilahModel listIstilah) async {
|
||||
var res = await dialogService.showCustomDialog(
|
||||
variant: DialogType.actionDialogView,
|
||||
title: 'Form Aksi',
|
||||
data: listIstilah,
|
||||
);
|
||||
|
||||
if (res!.confirmed) {
|
||||
log.i('confirmed');
|
||||
// do something
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './profil_user_view_model.dart';
|
||||
|
||||
class ProfilUserView extends StatelessWidget {
|
||||
const ProfilUserView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<ProfilUserViewModel>.reactive(
|
||||
viewModelBuilder: () => ProfilUserViewModel(),
|
||||
onViewModelReady: (ProfilUserViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
ProfilUserViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(25),
|
||||
child: Column(
|
||||
children: [
|
||||
// MyTextFormField(
|
||||
// hintText: 'Cari istilah',
|
||||
// labelText: 'Cari istilah',
|
||||
// controller: model.searchController,
|
||||
// suffixIcon: const Icon(Icons.search),
|
||||
// onChanged: (String value) {
|
||||
// model.searchIstilah();
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// height: 20,
|
||||
// ),
|
||||
Expanded(
|
||||
child: model.listIstilah == null
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: model.listIstilah!.isEmpty
|
||||
? const Center(
|
||||
child: Text('Belum ada bookmark'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: model.listIstilah!.length,
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
onTap: () =>
|
||||
model.cekSuara(model.listIstilah![index]),
|
||||
title: Text(
|
||||
model.listIstilah![index].istilah!
|
||||
.toUpperCase(),
|
||||
style: boldTextStyle,
|
||||
),
|
||||
subtitle:
|
||||
Text(model.listIstilah![index].arti!),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// model.cekSuara(model.listIstilah[index]);
|
||||
},
|
||||
child: const Icon(Icons.phone),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
// model.bukaDialogAksi(
|
||||
// model.listIstilah[index]);
|
||||
},
|
||||
icon: const Icon(Icons.delete_forever),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
// return const Scaffold(
|
||||
// body: Padding(
|
||||
// padding: EdgeInsets.all(30),
|
||||
// child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Center(
|
||||
// child: CircleAvatar(
|
||||
// radius: 65,
|
||||
// backgroundColor: fontParagraphColor,
|
||||
// child: Icon(
|
||||
// Icons.person,
|
||||
// size: 50,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// _ChildWidget(
|
||||
// icon: Icons.person,
|
||||
// text: 'ini nama developer',
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// _ChildWidget(
|
||||
// icon: Icons.list_alt,
|
||||
// text: 'Kamus Medis Dan Kesehatan',
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// _ChildWidget(
|
||||
// // icon multiple person
|
||||
// icon: Icons.people,
|
||||
// text: 'Pembimbing 1',
|
||||
// ),
|
||||
// SizedBox(height: 20),
|
||||
// _ChildWidget(
|
||||
// // icon multiple person
|
||||
// icon: Icons.people,
|
||||
// text: 'Pembimbing 2',
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: unused_element
|
||||
class _ChildWidget extends StatelessWidget {
|
||||
const _ChildWidget({
|
||||
required this.icon,
|
||||
required this.text,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(width: 30),
|
||||
Icon(
|
||||
icon,
|
||||
size: 30,
|
||||
color: mainColor,
|
||||
),
|
||||
const SizedBox(width: 40),
|
||||
Text(
|
||||
text,
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const Expanded(child: SizedBox(width: 30)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import 'package:kamus_kesehatan/model/istilah_model.dart';
|
||||
|
||||
import '../../../../app/app.locator.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../services/my_storage.dart';
|
||||
import '../../../../services/my_tts.dart';
|
||||
|
||||
class ProfilUserViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('ProfilUserViewModel');
|
||||
final myTts = locator<MyTts>();
|
||||
final myStorage = locator<MyStorage>();
|
||||
|
||||
List<IstilahModel>? listIstilah;
|
||||
List<IstilahModel>? allListIstilah;
|
||||
|
||||
Future<void> init() async {
|
||||
List<dynamic>? listBookmark;
|
||||
|
||||
listBookmark = await myStorage.read('listBookmark');
|
||||
|
||||
listBookmark ??= [];
|
||||
|
||||
log.i('ini panjang listBookmark ${listBookmark.length}');
|
||||
log.i('ini listBookmark $listBookmark');
|
||||
|
||||
listIstilah = listBookmark.map((dynamic item) {
|
||||
return IstilahModel.fromJson(item as Map<String, dynamic>);
|
||||
}).toList();
|
||||
|
||||
allListIstilah = listIstilah;
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
cekSuara(IstilahModel listIstilah) {
|
||||
myTts.stop();
|
||||
// speak the listIstilah.istilah and wait 2 seconds then speak the listIstilah.arti
|
||||
myTts.speak(listIstilah.istilah!);
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
myTts.speak(listIstilah.arti!);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kamus_kesehatan/app/app.router.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:stylish_bottom_bar/model/bar_items.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import './user_tracking_index_view_model.dart';
|
||||
|
||||
class UserTrackingIndexView extends StatelessWidget {
|
||||
const UserTrackingIndexView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<UserTrackingIndexViewModel>.reactive(
|
||||
viewModelBuilder: () => UserTrackingIndexViewModel(),
|
||||
onViewModelReady: (UserTrackingIndexViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
UserTrackingIndexViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: mainColor,
|
||||
title: Text(
|
||||
model.header,
|
||||
style: const TextStyle(
|
||||
color: fontColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.exitApp();
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: fontColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
extendBody: false,
|
||||
body: ExtendedNavigator(
|
||||
router: UserTrackingIndexViewRouter(),
|
||||
navigatorKey: StackedService.nestedNavigationKey(2),
|
||||
initialRoute: UserTrackingIndexViewRoutes.listKamusKesehatanView,
|
||||
),
|
||||
bottomNavigationBar: StylishBottomBar(
|
||||
items: [
|
||||
for (var item in model.bottomNavBarList)
|
||||
BottomBarItem(
|
||||
icon: Icon(item['icon'],
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? mainColor
|
||||
: fontColor),
|
||||
title: Text(
|
||||
item['name'],
|
||||
style: regularTextStyle.copyWith(
|
||||
color: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? mainColor
|
||||
: fontColor,
|
||||
),
|
||||
// textAlign: TextAlign.l,
|
||||
),
|
||||
backgroundColor: model.currentIndex ==
|
||||
model.bottomNavBarList.indexOf(item)
|
||||
? fontColor
|
||||
: fontColor,
|
||||
),
|
||||
],
|
||||
currentIndex: model.currentIndex,
|
||||
option: BubbleBarOptions(),
|
||||
hasNotch: true,
|
||||
backgroundColor: mainColor,
|
||||
onTap: (value) {
|
||||
model.handleNavigation(value);
|
||||
},
|
||||
// fabLocation: StylishBarFabLocation.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../services/global_var.dart';
|
||||
|
||||
class UserTrackingIndexViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('UserTrackingIndexViewModel');
|
||||
final globalVar = locator<GlobalVar>();
|
||||
final navigationService = locator<NavigationService>();
|
||||
final dialogService = locator<DialogService>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'List Kamus',
|
||||
'icon': Icons.list_alt_outlined,
|
||||
'header': 'List Kamus',
|
||||
},
|
||||
{
|
||||
'name': 'Profil Developer',
|
||||
'icon': Icons.person_outline_outlined,
|
||||
'header': 'Profil Developer',
|
||||
},
|
||||
];
|
||||
|
||||
String header = 'List Kamus';
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
// UserTrackingIndexViewRoutes.tampilkanListView,
|
||||
UserTrackingIndexViewRoutes.listKamusKesehatanView,
|
||||
UserTrackingIndexViewRoutes.profilUserView,
|
||||
];
|
||||
|
||||
Future<void> init() async {
|
||||
// setIndex(0);
|
||||
// handleNavigation(0);
|
||||
}
|
||||
|
||||
void handleNavigation(int index) {
|
||||
// log.d("handleNavigation: $index");
|
||||
// log.d("currentIndex: $currentIndex");
|
||||
|
||||
if (currentIndex == index) return;
|
||||
|
||||
setIndex(index);
|
||||
header = _bottomNavBarList[index]['header'] as String;
|
||||
navigationService.navigateTo(
|
||||
_views[index],
|
||||
id: 2,
|
||||
);
|
||||
}
|
||||
|
||||
exitApp() async {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin keluar?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Keluar',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
38
lib/ui/widgets/my_button.dart
Normal file
38
lib/ui/widgets/my_button.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyButton extends StatelessWidget {
|
||||
const MyButton({
|
||||
Key? key,
|
||||
required this.text,
|
||||
this.theBackgroundColor = mainColor,
|
||||
this.textColor = backgroundColor,
|
||||
this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onPressed;
|
||||
final Color theBackgroundColor;
|
||||
final Color textColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theBackgroundColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
88
lib/ui/widgets/my_textformfield.dart
Normal file
88
lib/ui/widgets/my_textformfield.dart
Normal file
@ -0,0 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class MyTextFormField extends StatelessWidget {
|
||||
const MyTextFormField({
|
||||
Key? key,
|
||||
this.labelText,
|
||||
this.hintText,
|
||||
this.obscureText,
|
||||
this.validator,
|
||||
this.suffixIcon,
|
||||
this.prefixIcon,
|
||||
this.focusNode,
|
||||
this.controller,
|
||||
this.maxLines = 1,
|
||||
this.onEditingComplete,
|
||||
this.keyboardType = TextInputType.text,
|
||||
this.initialValue,
|
||||
this.readOnly = false,
|
||||
this.maxLength,
|
||||
this.onChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
final String? labelText;
|
||||
final String? hintText;
|
||||
final bool? obscureText;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final Widget? suffixIcon;
|
||||
final Widget? prefixIcon;
|
||||
final FocusNode? focusNode;
|
||||
final TextEditingController? controller;
|
||||
final int maxLines;
|
||||
final VoidCallback? onEditingComplete;
|
||||
final TextInputType keyboardType;
|
||||
final String? initialValue;
|
||||
final bool readOnly;
|
||||
final int? maxLength;
|
||||
final void Function(String)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
onChanged: onChanged,
|
||||
maxLength: maxLength,
|
||||
readOnly: readOnly,
|
||||
initialValue: initialValue,
|
||||
onEditingComplete: onEditingComplete,
|
||||
maxLines: maxLines,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
obscureText: obscureText ?? false,
|
||||
keyboardType: keyboardType,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: prefixIcon,
|
||||
suffixIcon: suffixIcon,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
// color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
// color: mainColor,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
errorBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||
borderSide: BorderSide(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
labelText: labelText,
|
||||
hintText: hintText,
|
||||
labelStyle: const TextStyle(color: fontColor),
|
||||
),
|
||||
validator: validator,
|
||||
);
|
||||
}
|
||||
}
|
73
lib/ui/widgets/top_container.dart
Normal file
73
lib/ui/widgets/top_container.dart
Normal file
@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../app/themes/app_colors.dart';
|
||||
|
||||
class TopContainer extends StatelessWidget {
|
||||
const TopContainer({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.icon,
|
||||
required this.background,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
final IconData icon;
|
||||
final Color background;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
),
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
':',
|
||||
style: TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: fontGrey,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
icon,
|
||||
color: fontGrey,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user