change area to kecamatan and some changes
This commit is contained in:
@ -34,143 +34,151 @@ class AdminFirstPageView extends StatelessWidget {
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TopContainer(
|
||||
title: 'Jumlah Area',
|
||||
value: '${model.jumlahArea} Area',
|
||||
icon: Icons.place_outlined,
|
||||
background: warningColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Jumlah Caleg',
|
||||
value: '${model.jumlahCaleg} Caleg',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: greenColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Tim Survei',
|
||||
value: '${model.jumlahTimSurvei} Tim Survei',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: orangeColor,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const TopContainer(
|
||||
title: 'Jumlah Pemilih',
|
||||
value: '10 Pemilih',
|
||||
icon: Icons.people_alt_outlined,
|
||||
background: blueColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy && model.status == true)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'Admin\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan tambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Area ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'terlebih dahulu sebelum menambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Caleg',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'.\n\nData Pemilih akan diambil dari data yang dimasukkan oleh tim survei\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'Jika terjadi kesalahan pada data, silahkan hubungi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// TopContainer(
|
||||
// title: 'Jumlah\nArea',
|
||||
// value: '${model.jumlahArea} Area',
|
||||
// icon: Icons.place_outlined,
|
||||
// background: warningColor,
|
||||
// ),
|
||||
// const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Jumlah\nCaleg',
|
||||
value: '${model.jumlahCaleg} Caleg',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: greenColor,
|
||||
),
|
||||
if (!model.isBusy && model.status == false)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'Admin\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Terjadi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Error ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: redColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'pada saat mengambil data\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan coba lagi dengan menekan icon',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Pengaturan\n',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'di pojok kanan bawah\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TopContainer(
|
||||
title: 'Tim\nSurvei',
|
||||
value: '${model.jumlahTimSurvei} Tim Survei',
|
||||
icon: Icons.co_present_outlined,
|
||||
background: orangeColor,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 10),
|
||||
const TopContainer(
|
||||
title: 'Jumlah\nPemilih',
|
||||
value: '10 Pemilih',
|
||||
icon: Icons.people_alt_outlined,
|
||||
background: blueColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
if (model.isBusy)
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
if (!model.isBusy && model.status == true)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'Admin\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan tambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Area ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'terlebih dahulu sebelum menambahkan data ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Caleg',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'.\n\nData Pemilih akan diambil dari data yang dimasukkan oleh tim survei\n\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
'Jika terjadi kesalahan pada data, silahkan hubungi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!model.isBusy && model.status == false)
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Selamat Datang, ',
|
||||
style: regularTextStyle,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'Admin\n',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Terjadi ',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Error ',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: redColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'pada saat mengambil data\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'Silahkan coba lagi dengan menekan icon',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: ' Pengaturan\n',
|
||||
style: boldTextStyle.copyWith(
|
||||
color: greenColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: 'di pojok kanan bawah\n',
|
||||
style: regularTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// with setting icon
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: warningColor,
|
||||
onPressed: () {
|
||||
// model.gotoSetting();
|
||||
model.snackbarService.showSnackbar(
|
||||
message: 'Fitur belum tersedia',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.settings),
|
||||
child: const Icon(Icons.settings, color: fontColor),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndTop,
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:cek_suara/model/area_model.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../model/area_model.dart';
|
||||
import '../../../../model/caleg_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
import '../../../../model/tim_survei_model.dart';
|
||||
@ -24,11 +25,11 @@ class AdminFirstPageViewModel extends CustomBaseViewModel {
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('area');
|
||||
var response = await httpService.get('area/kecamatan');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
KecamatanDetail areaListModel =
|
||||
KecamatanDetail.fromJson(myResponseModel.data);
|
||||
jumlahArea = areaListModel.jumlah!;
|
||||
|
||||
response = await httpService.get('caleg');
|
||||
|
@ -26,6 +26,26 @@ class AdminIndexTrackingView extends StatelessWidget {
|
||||
) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
model.header,
|
||||
style: const TextStyle(
|
||||
color: fontColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
backgroundColor: warningColor,
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
model.logout();
|
||||
},
|
||||
icon: const Icon(Icons.logout, color: fontColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
extendBody: false,
|
||||
body: ExtendedNavigator(
|
||||
router: AdminIndexTrackingViewRouter(),
|
||||
|
@ -11,13 +11,10 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
final log = getLogger('AdminIndexTrackingViewModel');
|
||||
final globalVar = locator<GlobalVar>();
|
||||
final navigationService = locator<NavigationService>();
|
||||
final dialogService = locator<DialogService>();
|
||||
// final mySharedPrefs = locator<MySharedPrefs>();
|
||||
|
||||
final _bottomNavBarList = [
|
||||
{
|
||||
'name': 'Area',
|
||||
'icon': Icons.place_outlined,
|
||||
'header': 'Halaman Area',
|
||||
},
|
||||
{
|
||||
'name': 'Caleg',
|
||||
'icon': Icons.co_present_outlined,
|
||||
@ -40,7 +37,6 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
List<Map<String, dynamic>> get bottomNavBarList => _bottomNavBarList;
|
||||
|
||||
final List<String> _views = [
|
||||
AdminIndexTrackingViewRoutes.halamanAreaView,
|
||||
AdminIndexTrackingViewRoutes.halamanCalegView,
|
||||
AdminIndexTrackingViewRoutes.timSurveiView,
|
||||
AdminIndexTrackingViewRoutes.halamanPengaturanView,
|
||||
@ -48,7 +44,7 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setIndex(3);
|
||||
setIndex(2);
|
||||
// await super.init();
|
||||
}
|
||||
|
||||
@ -65,4 +61,20 @@ class AdminIndexTrackingViewModel extends IndexTrackingViewModel {
|
||||
id: 2,
|
||||
);
|
||||
}
|
||||
|
||||
logout() async {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin keluar?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Keluar',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
// await mySharedPrefs.clear();
|
||||
navigationService.clearStackAndShow(Routes.loginScreenView);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'package:cek_suara/app/themes/app_colors.dart';
|
||||
import 'package:cek_suara/app/themes/app_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import './detail_suara_bottom_sheet_view_model.dart';
|
||||
|
||||
class DetailSuaraBottomSheetView extends StatelessWidget {
|
||||
@ -88,13 +88,22 @@ class DetailSuaraBottomSheetView extends StatelessWidget {
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (request!.description == 'Caleg')
|
||||
Text(
|
||||
model.listPemilih[i].namaTimSurvei!,
|
||||
style: italicTextStyle,
|
||||
),
|
||||
Text(
|
||||
model.listPemilih[i].namaArea!,
|
||||
),
|
||||
CardWidget(
|
||||
title: 'Tim',
|
||||
value: model
|
||||
.listPemilih[i].namaTimSurvei!),
|
||||
CardWidget(
|
||||
title: 'Kec',
|
||||
value:
|
||||
model.listPemilih[i].kecamatan!),
|
||||
CardWidget(
|
||||
title: 'Kel / Desa',
|
||||
value:
|
||||
model.listPemilih[i].kelurahan!),
|
||||
CardWidget(
|
||||
title: 'TPS',
|
||||
value: model.listPemilih[i].tps!
|
||||
.toString()),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
@ -139,3 +148,48 @@ class DetailSuaraBottomSheetView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CardWidget extends StatelessWidget {
|
||||
const CardWidget({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
title,
|
||||
style: italicTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
' : ',
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Text(
|
||||
value,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
import 'package:cek_suara/model/pemilih_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';
|
||||
import '../../../../model/pemilih_model.dart';
|
||||
|
||||
class DetailSuaraBottomSheetViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('DetailSuaraBottomSheetViewModel');
|
||||
@ -23,13 +22,17 @@ class DetailSuaraBottomSheetViewModel extends CustomBaseViewModel {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
var response = await httpService.get('caleg/suara/$id');
|
||||
// var response = await httpService.get('caleg/suara/$id');
|
||||
var response = await httpService
|
||||
.get('${status == 'Caleg' ? 'caleg' : 'survei'}/suara/$id');
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
PemilihDetailModel pemilihDetailModel =
|
||||
PemilihDetailModel.fromJson(myResponseModel.data);
|
||||
PemilihDetail pemilihDetail =
|
||||
PemilihDetail.fromJson(myResponseModel.data);
|
||||
|
||||
listPemilih = pemilihDetailModel.pemilihModel!;
|
||||
counter = pemilihDetailModel.jumlah!;
|
||||
log.i(pemilihDetail.pemilihModel!);
|
||||
|
||||
listPemilih = pemilihDetail.pemilihModel!;
|
||||
counter = pemilihDetail.jumlah!;
|
||||
this.status = true;
|
||||
} catch (e) {
|
||||
this.status = false;
|
||||
|
@ -41,62 +41,83 @@ class DetailSuaraPemilihBottomSheetView extends StatelessWidget {
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
request.title!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
request.title!,
|
||||
style: boldTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Container(
|
||||
height: 100,
|
||||
width: 150,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
model.showImage(
|
||||
context,
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
const SizedBox(height: 15),
|
||||
Container(
|
||||
height: 100,
|
||||
width: 150,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.network(
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.error,
|
||||
color: backgroundColor,
|
||||
size: 50,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
model.showImage(
|
||||
context,
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Image.network(
|
||||
dotenv.env['url']! + request.data!.img!,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.error,
|
||||
color: backgroundColor,
|
||||
size: 50,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Nama',
|
||||
value: request.data!.namaPemilih!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'No KTP /\nNo HP',
|
||||
value: request.data!.nikNomorHp!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Tanggal/\nWaktu',
|
||||
value: request.data!.createdAt!,
|
||||
),
|
||||
],
|
||||
_DetailChildWidget(
|
||||
title: 'Nama',
|
||||
value: request.data!.namaPemilih!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'No KTP /\nNo HP',
|
||||
value: request.data!.nikNomorHp!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Tanggal/\nWaktu',
|
||||
value: model.myFunction
|
||||
.convertDateTime2(request.data!.createdAt!),
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Caleg', value: request.data!.namaCaleg!),
|
||||
_DetailChildWidget(
|
||||
title: 'Tim Survei',
|
||||
value: request.data!.namaTimSurvei!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Kecamatan',
|
||||
value: request.data!.kecamatan!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'Kelurahan',
|
||||
value: request.data!.kelurahan!,
|
||||
),
|
||||
_DetailChildWidget(
|
||||
title: 'TPS',
|
||||
value: request.data!.tps!.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1,143 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../widgets/my_button.dart';
|
||||
import '../../../widgets/my_textformfield.dart';
|
||||
import './halaman_area_view_model.dart';
|
||||
|
||||
class HalamanAreaView extends StatelessWidget {
|
||||
const HalamanAreaView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<HalamanAreaViewModel>.reactive(
|
||||
viewModelBuilder: () => HalamanAreaViewModel(),
|
||||
onViewModelReady: (HalamanAreaViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
HalamanAreaViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: WillPopScope(
|
||||
onWillPop: () async {
|
||||
// model.log.i('backPressed: ${model.globalVar.backPressed}');
|
||||
if (model.globalVar.backPressed == 'exitApp') {
|
||||
// model.back();
|
||||
model.quitApp(context);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
MyTextFormField(
|
||||
hintText: 'Nama Area',
|
||||
labelText: 'Nama Area',
|
||||
controller: model.namaAreaController,
|
||||
validator: Validatorless.required(
|
||||
'Nama Area tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
text: 'Tambah Area',
|
||||
onPressed: () async {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
// close keyboard
|
||||
FocusScope.of(context).unfocus();
|
||||
bool res = await model.addArea();
|
||||
model.log.i('res: $res');
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: warningColor,
|
||||
),
|
||||
child: Column(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Jumlah Area: ${model.jumlahArea} area',
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (model.isBusy)
|
||||
const Center(
|
||||
child: CircularProgressIndicator()),
|
||||
if (!model.isBusy)
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
if (model.jumlahArea == 0)
|
||||
Center(
|
||||
child: model.status == true
|
||||
? const Text(
|
||||
'Belum ada area diinput')
|
||||
: const Text(
|
||||
'Gagal mengambil data'),
|
||||
),
|
||||
if (model.jumlahArea > 0)
|
||||
for (var i = 0;
|
||||
i < model.jumlahArea;
|
||||
i++)
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Text('${i + 1}'),
|
||||
title: Text(
|
||||
'${model.listAreaModel[i].namaArea}'),
|
||||
trailing: IconButton(
|
||||
// trash bin icon
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: Colors.red,
|
||||
),
|
||||
onPressed: () {
|
||||
model.deleteArea(model
|
||||
.listAreaModel[i]
|
||||
.idArea!);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../model/area_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
class HalamanAreaViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('HalamanAreaViewModel');
|
||||
|
||||
// variabel
|
||||
List<AreaModel> listAreaModel = [];
|
||||
int jumlahArea = 0;
|
||||
bool status = false;
|
||||
|
||||
// add area form
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController namaAreaController = TextEditingController();
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
await getData();
|
||||
}
|
||||
|
||||
getData() async {
|
||||
log.i('getData');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('area');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.area!;
|
||||
jumlahArea = areaListModel.jumlah!;
|
||||
|
||||
log.i('listAreaModel: $listAreaModel');
|
||||
log.i('jumlahArea: $jumlahArea');
|
||||
status = true;
|
||||
} catch (e) {
|
||||
status = false;
|
||||
log.e(e);
|
||||
} finally {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addArea() async {
|
||||
log.i('addArea');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
easyLoading.customLoading('Tambah Area..');
|
||||
|
||||
var formData = FormData.fromMap({
|
||||
'area': namaAreaController.text,
|
||||
});
|
||||
|
||||
try {
|
||||
var response = await httpService.postWithFormData('area', formData);
|
||||
log.i(response.data);
|
||||
await getData();
|
||||
// reset form
|
||||
namaAreaController.clear();
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
return false;
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
deleteArea(int idArea) {
|
||||
dialogService
|
||||
.showDialog(
|
||||
title: 'Hapus Area',
|
||||
description: 'Apakah Anda yakin ingin menghapus area ini?',
|
||||
buttonTitle: 'Hapus',
|
||||
cancelTitle: 'Batal',
|
||||
buttonTitleColor: dangerColor,
|
||||
cancelTitleColor: mainColor,
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
log.i('deleteArea id_area: $idArea');
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
easyLoading.customLoading('Hapus Area..');
|
||||
|
||||
try {
|
||||
var response = await httpService.delete('area/$idArea');
|
||||
log.i(response.data);
|
||||
await getData();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'exitApp';
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -47,6 +47,11 @@ class HalamanCalegView extends StatelessWidget {
|
||||
Expanded(
|
||||
// flex: 3,
|
||||
child: Container(
|
||||
alignment: model.isBusy
|
||||
? Alignment.center
|
||||
: (model.listCalegModel.isNotEmpty
|
||||
? Alignment.topCenter
|
||||
: Alignment.center),
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
@ -66,9 +71,11 @@ class HalamanCalegView extends StatelessWidget {
|
||||
: MainAxisAlignment.center),
|
||||
children: [
|
||||
if (model.isBusy)
|
||||
const LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
const Center(
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
if (!model.isBusy &&
|
||||
model.listCalegModel.isNotEmpty)
|
||||
|
@ -1,9 +1,7 @@
|
||||
import 'package:cek_suara/app/themes/app_colors.dart';
|
||||
|
||||
// import '../../../../app/app.bottomsheets.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/caleg_model.dart';
|
||||
import '../../../../model/my_response.model.dart';
|
||||
|
||||
@ -58,7 +56,8 @@ class HalamanCalegViewModel extends CustomBaseViewModel {
|
||||
|
||||
if (res!.confirmed) {
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Caleg berhasil ditambahkan',
|
||||
message:
|
||||
'Caleg berhasil ditambahkan\nPassword default caleg : 12345678',
|
||||
title: 'Berhasil',
|
||||
duration: const Duration(seconds: 3),
|
||||
);
|
||||
|
@ -136,27 +136,39 @@ class TambahEditCalegView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (model.calegModel == null) const SizedBox(height: 10),
|
||||
if (model.calegModel == null)
|
||||
MyTextFormField(
|
||||
hintText: 'Area',
|
||||
labelText: 'Pencarian Area',
|
||||
controller: model.cariAreaController,
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () {
|
||||
// remove keyboard focus
|
||||
FocusScope.of(context).unfocus();
|
||||
model.cariArea();
|
||||
},
|
||||
child: const Icon(Icons.search),
|
||||
),
|
||||
// if (model.calegModel == null) const SizedBox(height: 10),
|
||||
// if (model.calegModel == null)
|
||||
// MyTextFormField(
|
||||
// hintText: 'Area',
|
||||
// labelText: 'Pencarian Area',
|
||||
// controller: model.cariAreaController,
|
||||
// // suffixIcon: GestureDetector(
|
||||
// // onTap: () {
|
||||
// // // remove keyboard focus
|
||||
// // FocusScope.of(context).unfocus();
|
||||
// // model.cariArea();
|
||||
// // },
|
||||
// // child: const Icon(Icons.search),
|
||||
// // ),
|
||||
|
||||
// controller: model.partaiController,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// // controller: model.partaiController,
|
||||
// ),
|
||||
const SizedBox(height: 20),
|
||||
// create a horizontal divider
|
||||
|
||||
const Text("Pilih Kecamatan"),
|
||||
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.3,
|
||||
width: double.infinity,
|
||||
// create a border
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
|
||||
// create 10 random checkbox
|
||||
child: SingleChildScrollView(
|
||||
@ -175,18 +187,19 @@ class TambahEditCalegView extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: model.listAreaId.contains(
|
||||
model.listAreaModel[index].idArea!),
|
||||
value: model.listAreaId.contains(model
|
||||
.listAreaModel[index].kecamatanId!),
|
||||
onChanged: (value) {
|
||||
if (model.calegModel != null) return;
|
||||
model.tambahHapusArea(
|
||||
model.listAreaModel[index].idArea!,
|
||||
model.listAreaModel[index]
|
||||
.kecamatanId!,
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
model.listAreaModel[index].namaArea!,
|
||||
model.listAreaModel[index].name!,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -19,15 +19,15 @@ class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('TambahEditCalegViewModel');
|
||||
|
||||
// variabel list area
|
||||
List<AreaModel> listAreaModel = [];
|
||||
List<AreaModel> allListAreaModel = [];
|
||||
List<KecamatanModel> listAreaModel = [];
|
||||
List<KecamatanModel> allListAreaModel = [];
|
||||
|
||||
// form variable
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController namaController = TextEditingController();
|
||||
TextEditingController cariAreaController = TextEditingController();
|
||||
TextEditingController nomorUrutController = TextEditingController();
|
||||
List<int> listAreaId = [];
|
||||
List<String> listAreaId = [];
|
||||
|
||||
// image picker
|
||||
String? _imagePath;
|
||||
@ -58,13 +58,13 @@ class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
var response = await httpService.get('caleg/relasi_area/$idCaleg');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
var data = myResponseModel.data['area'];
|
||||
var data = myResponseModel.data['kecamatan'];
|
||||
for (var item in data) {
|
||||
listAreaId.add(item['id_area']);
|
||||
listAreaId.add(item['kecamatan_id']);
|
||||
}
|
||||
listAreaModel = [];
|
||||
for (var item in allListAreaModel) {
|
||||
if (listAreaId.contains(item.idArea)) {
|
||||
if (listAreaId.contains(item.kecamatanId)) {
|
||||
listAreaModel.add(item);
|
||||
}
|
||||
}
|
||||
@ -85,16 +85,19 @@ class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
setBusy(true);
|
||||
globalVar.backPressed = 'cantBack';
|
||||
try {
|
||||
var response = await httpService.get('area');
|
||||
var response = await httpService.get('area/kecamatan');
|
||||
log.i(response.data);
|
||||
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
|
||||
AreaListModel areaListModel =
|
||||
AreaListModel.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.area!;
|
||||
allListAreaModel = areaListModel.area!;
|
||||
// log.i(myResponseModel.data);
|
||||
KecamatanDetail areaListModel =
|
||||
KecamatanDetail.fromJson(myResponseModel.data);
|
||||
listAreaModel = areaListModel.kecamatan!;
|
||||
allListAreaModel = areaListModel.kecamatan!;
|
||||
// listAreaModel = areaListModel.area!;
|
||||
// allListAreaModel = areaListModel.area!;
|
||||
// jumlahArea = areaListModel.jumlah!;
|
||||
|
||||
log.i('listAreaModel: $listAreaModel');
|
||||
// log.i('listAreaModel: $listAreaModel');
|
||||
// log.i('jumlahArea: $jumlahArea');
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
@ -120,33 +123,33 @@ class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
tambahHapusArea(int idArea) {
|
||||
tambahHapusArea(String kecamatanId) {
|
||||
log.i('tambahHapusArea');
|
||||
if (listAreaId.contains(idArea)) {
|
||||
listAreaId.remove(idArea);
|
||||
if (listAreaId.contains(kecamatanId)) {
|
||||
listAreaId.remove(kecamatanId);
|
||||
} else {
|
||||
listAreaId.add(idArea);
|
||||
listAreaId.add(kecamatanId);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
cariArea() {
|
||||
log.i('cariArea ${cariAreaController.text}');
|
||||
// cariArea() {
|
||||
// log.i('cariArea ${cariAreaController.text}');
|
||||
|
||||
if (cariAreaController.text.isEmpty) {
|
||||
listAreaModel = allListAreaModel;
|
||||
return;
|
||||
}
|
||||
// if (cariAreaController.text.isEmpty) {
|
||||
// listAreaModel = allListAreaModel;
|
||||
// return;
|
||||
// }
|
||||
|
||||
listAreaModel = allListAreaModel
|
||||
.where((element) => element.namaArea!
|
||||
.toLowerCase()
|
||||
.contains(cariAreaController.text.toLowerCase()))
|
||||
.toList();
|
||||
// listAreaModel = allListAreaModel
|
||||
// .where((element) => element.namaArea!
|
||||
// .toLowerCase()
|
||||
// .contains(cariAreaController.text.toLowerCase()))
|
||||
// .toList();
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
// notifyListeners();
|
||||
// }
|
||||
|
||||
Future<bool> addCaleg() async {
|
||||
log.i('addCaleg');
|
||||
@ -157,7 +160,7 @@ class TambahEditCalegViewModel extends CustomBaseViewModel {
|
||||
var formData = FormData.fromMap({
|
||||
'nama': namaController.text,
|
||||
'nomor_urut': nomorUrutController.text,
|
||||
'area': const JsonEncoder().convert(listAreaId),
|
||||
'kecamatan': const JsonEncoder().convert(listAreaId),
|
||||
'foto': await MultipartFile.fromFile(
|
||||
imageFile!.path,
|
||||
filename: imageFile!.name,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:cek_suara/ui/views/admin_index_tracking/admin_first_page/admin_first_page_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../admin_first_page/admin_first_page_view.dart';
|
||||
import './halaman_pengaturan_view_model.dart';
|
||||
|
||||
class HalamanPengaturanView extends StatelessWidget {
|
||||
|
@ -76,71 +76,70 @@ class TambahDetailTimSurveiView extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (model.timSurveiModel == null)
|
||||
Column(
|
||||
children: [
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
' Pilih Caleg',
|
||||
),
|
||||
const Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
' Pilih Caleg',
|
||||
),
|
||||
),
|
||||
if (model.isBusy && model.timSurveiModel == null)
|
||||
const LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
),
|
||||
if (!model.isBusy && model.listCalegModel.isNotEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: sixthGrey,
|
||||
),
|
||||
if (model.isBusy)
|
||||
const LinearProgressIndicator(
|
||||
minHeight: 5,
|
||||
color: mainColor,
|
||||
),
|
||||
if (!model.isBusy && model.listCalegModel.isNotEmpty)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: sixthGrey,
|
||||
),
|
||||
),
|
||||
child: Expanded(
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
isExpanded: true,
|
||||
value: model.selectedCaleg!,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
iconSize: 24,
|
||||
elevation: 16,
|
||||
style:
|
||||
const TextStyle(color: Colors.black),
|
||||
onChanged: (String? newValue) {
|
||||
model.log.i(newValue);
|
||||
model.selectedCaleg = newValue!;
|
||||
model.selectedCalegId = model
|
||||
.listCalegModel
|
||||
.firstWhere((element) =>
|
||||
element.namaCaleg ==
|
||||
model.selectedCaleg)
|
||||
.idCaleg;
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
isExpanded: true,
|
||||
value: model.selectedCaleg!,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
iconSize: 24,
|
||||
elevation: 16,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
onChanged: (String? newValue) {
|
||||
model.log.i(newValue);
|
||||
model.selectedCaleg = newValue!;
|
||||
model.selectedCalegId = model.listCalegModel
|
||||
.firstWhere((element) =>
|
||||
element.namaCaleg ==
|
||||
model.selectedCaleg)
|
||||
.idCaleg;
|
||||
|
||||
model.log.i(model.selectedCalegId);
|
||||
model.log.i(model.selectedCalegId);
|
||||
|
||||
model.notifyListeners();
|
||||
},
|
||||
items: model.listCalegString
|
||||
.map<DropdownMenuItem<String>>(
|
||||
(String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
model.notifyListeners();
|
||||
},
|
||||
items: model.listCalegString
|
||||
.map<DropdownMenuItem<String>>(
|
||||
(String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
),
|
||||
if (model.timSurveiModel == null)
|
||||
const SizedBox(height: 20),
|
||||
// Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
|
||||
// ],
|
||||
// ),
|
||||
if (model.timSurveiModel == null &&
|
||||
request.title! == 'Tambah Tim Survei')
|
||||
SizedBox(
|
||||
width: 200,
|
||||
child: MyButton(
|
||||
@ -169,6 +168,7 @@ class TambahDetailTimSurveiView extends StatelessWidget {
|
||||
),
|
||||
if (model.timSurveiModel != null)
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
MyTextFormField(
|
||||
labelText: 'Caleg',
|
||||
@ -185,11 +185,13 @@ class TambahDetailTimSurveiView extends StatelessWidget {
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: mainColor.withOpacity(0.5),
|
||||
color: mainColor,
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
model.checkSuara(model.timSurveiModel!);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.list_alt_outlined,
|
||||
color: Colors.white,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../app/app.bottomsheets.dart';
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../../model/caleg_model.dart';
|
||||
@ -83,4 +84,16 @@ class TambahDetailTimSurveiViewModel extends CustomBaseViewModel {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
checkSuara(TimSurveiModel timSurveiModel) async {
|
||||
await bottomSheetService.showCustomSheet(
|
||||
data: timSurveiModel.nik,
|
||||
barrierDismissible: true,
|
||||
isScrollControlled: true,
|
||||
title: 'Detail Suara Tim Survei ${timSurveiModel.nama}',
|
||||
description: 'Tim Survei',
|
||||
ignoreSafeArea: false,
|
||||
variant: BottomSheetType.detailSuaraBottomSheetView,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:cek_suara/app/themes/app_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../../app/themes/app_colors.dart';
|
||||
import '../../../../app/themes/app_text.dart';
|
||||
import '../../../widgets/top_container.dart';
|
||||
import './tim_survei_view_model.dart';
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'package:cek_suara/app/themes/app_colors.dart';
|
||||
import 'package:cek_suara/ui/widgets/my_button.dart';
|
||||
import 'package:cek_suara/ui/widgets/my_textformfield.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../widgets/my_button.dart';
|
||||
import '../../widgets/my_textformfield.dart';
|
||||
import './login_screen_view_model.dart';
|
||||
|
||||
class LoginScreenView extends StatelessWidget {
|
||||
@ -37,59 +38,80 @@ class LoginScreenView extends StatelessWidget {
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Center(
|
||||
child: Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
'Halaman Login',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const MyTextFormField(
|
||||
// controller: model.usernameController,
|
||||
hintText: 'Username',
|
||||
// prefixIcon: Icons.person,
|
||||
obscureText: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const MyTextFormField(
|
||||
// controller: model.passwordController,
|
||||
hintText: 'Password',
|
||||
suffixIcon: Icon(Icons.lock),
|
||||
obscureText: true,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
// theBackgroundColor: lightColor,
|
||||
textColor: fontColor,
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
model.login();
|
||||
},
|
||||
Center(
|
||||
child: Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 200,
|
||||
height: 200,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Text(
|
||||
'Halaman Login',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.usernameController,
|
||||
hintText: 'Username',
|
||||
validator: Validatorless.required(
|
||||
'Username tidak boleh kosong'),
|
||||
// prefixIcon: Icons.person,
|
||||
obscureText: false,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.passwordController,
|
||||
hintText: 'Password',
|
||||
validator: Validatorless.required(
|
||||
'Password tidak boleh kosong'),
|
||||
suffixIcon: GestureDetector(
|
||||
onTap: () {
|
||||
model.isPasswordVisible =
|
||||
!model.isPasswordVisible;
|
||||
},
|
||||
child: Icon(
|
||||
model.isPasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: fontColor,
|
||||
),
|
||||
),
|
||||
obscureText: true,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: MyButton(
|
||||
// theBackgroundColor: lightColor,
|
||||
textColor: fontColor,
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
model.login();
|
||||
}
|
||||
// model.login();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -1,9 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../app/app.router.dart';
|
||||
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class LoginScreenViewModel extends CustomBaseViewModel {
|
||||
bool isPasswordVisible = true;
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController usernameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
|
||||
final log = getLogger('LoginScreenViewModel');
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'backNormal';
|
||||
@ -11,11 +18,22 @@ class LoginScreenViewModel extends CustomBaseViewModel {
|
||||
|
||||
login() async {
|
||||
easyLoading.customLoading('Login..');
|
||||
globalVar.backPressed = 'cantBack';
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'backNormal';
|
||||
// navigationService.pushNamedAndRemoveUntil('/home-screen');
|
||||
await navigationService.navigateToAdminIndexTrackingView();
|
||||
if (usernameController.text == 'admin' &&
|
||||
passwordController.text == 'admin123') {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'backNormal';
|
||||
// navigationService.pushNamedAndRemoveUntil('/home-screen');
|
||||
await navigationService.navigateToAdminIndexTrackingView();
|
||||
} else {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
easyLoading.dismissLoading();
|
||||
globalVar.backPressed = 'backNormal';
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Username atau Password salah',
|
||||
title: 'Login Gagal',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user