changes the area to kecamatan , kelurahan and tps
This commit is contained in:
@ -0,0 +1,190 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import '../../../../../app/themes/app_colors.dart';
|
||||
import '../../../../../app/themes/app_text.dart';
|
||||
import '../../../../widgets/my_textformfield.dart';
|
||||
import './ganti_password_dialog_view_model.dart';
|
||||
|
||||
class GantiPasswordDialogView extends StatelessWidget {
|
||||
final DialogRequest? request;
|
||||
final Function(DialogResponse)? completer;
|
||||
|
||||
const GantiPasswordDialogView({
|
||||
Key? key,
|
||||
this.request,
|
||||
this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<GantiPasswordDialogViewModel>.reactive(
|
||||
viewModelBuilder: () => GantiPasswordDialogViewModel(),
|
||||
onViewModelReady: (GantiPasswordDialogViewModel model) async {
|
||||
await model.init();
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
GantiPasswordDialogViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Form(
|
||||
key: model.globalKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Ganti Password',
|
||||
style: boldTextStyle.copyWith(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
MyTextFormField(
|
||||
labelText: 'Password Lama',
|
||||
hintText: 'Masukkan password lama',
|
||||
obscureText: model.isPasswordLamaObscure,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isPasswordLamaObscure =
|
||||
!model.isPasswordLamaObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isPasswordLamaObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
controller: model.passwordLamaController,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Password lama tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Password lama minimal 8 karakter'),
|
||||
Validatorless.compare(
|
||||
model.thePasswordLamaController,
|
||||
'Password lama tidak sama',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Password Baru',
|
||||
hintText: 'Masukkan password baru',
|
||||
obscureText: model.isPasswordBaruObscure,
|
||||
controller: model.passwordBaruController,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isPasswordBaruObscure =
|
||||
!model.isPasswordBaruObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isPasswordBaruObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Password baru tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Password baru minimal 8 karakter'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Konfirmasi Password Baru',
|
||||
hintText: 'Masukkan konfirmasi password baru',
|
||||
obscureText: model.isKonfirmasiPasswordBaruObscure,
|
||||
controller: model.konfirmasiPasswordBaruController,
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
model.isKonfirmasiPasswordBaruObscure =
|
||||
!model.isKonfirmasiPasswordBaruObscure;
|
||||
model.notifyListeners();
|
||||
},
|
||||
icon: Icon(
|
||||
model.isKonfirmasiPasswordBaruObscure
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
),
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'Konfirmasi password baru tidak boleh kosong'),
|
||||
Validatorless.min(
|
||||
8, 'Konfirmasi password baru minimal 8 karakter'),
|
||||
Validatorless.compare(
|
||||
model.passwordBaruController,
|
||||
'Password baru tidak sama',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (model.globalKey.currentState!.validate()) {
|
||||
// remove keyboard
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
model.dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description:
|
||||
'Apakah anda yakin ingin mengubah password?',
|
||||
cancelTitle: 'Batal',
|
||||
confirmationTitle: 'Ya',
|
||||
)
|
||||
.then(
|
||||
(response) async {
|
||||
if (response!.confirmed) {
|
||||
// completer!(DialogResponse(confirmed: true));
|
||||
// model.log.i('Password berhasil diubah');
|
||||
bool res = await model.gantiPassword();
|
||||
// model.log.i('res: $res');
|
||||
if (res) {
|
||||
completer!(DialogResponse(confirmed: true));
|
||||
model.log.i('Password berhasil diubah');
|
||||
}
|
||||
} else {
|
||||
model.log.i('Password gagal diubah');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Simpan'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
completer!(DialogResponse(confirmed: false)),
|
||||
child: const Text(
|
||||
'Batal',
|
||||
style: TextStyle(color: dangerColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
|
||||
class GantiPasswordDialogViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('GantiPasswordDialogViewModel');
|
||||
|
||||
// form variable
|
||||
final globalKey = GlobalKey<FormState>();
|
||||
TextEditingController passwordLamaController = TextEditingController();
|
||||
TextEditingController passwordBaruController = TextEditingController();
|
||||
TextEditingController konfirmasiPasswordBaruController =
|
||||
TextEditingController();
|
||||
|
||||
TextEditingController thePasswordLamaController = TextEditingController();
|
||||
|
||||
bool isPasswordLamaObscure = true;
|
||||
bool isPasswordBaruObscure = true;
|
||||
bool isKonfirmasiPasswordBaruObscure = true;
|
||||
|
||||
// String? passwordLama;
|
||||
|
||||
Future<void> init() async {
|
||||
globalVar.backPressed = 'exitApp';
|
||||
String? passwordLama = await mySharedPrefs.getString('password');
|
||||
thePasswordLamaController.text = passwordLama!;
|
||||
}
|
||||
|
||||
Future<bool> gantiPassword() async {
|
||||
setBusy(true);
|
||||
|
||||
try {
|
||||
String? nik = await mySharedPrefs.getString('nik');
|
||||
var formData = FormData.fromMap({
|
||||
'nik': nik,
|
||||
'password_lama': passwordLamaController.text,
|
||||
'password_baru': passwordBaruController.text,
|
||||
});
|
||||
await httpService.postWithFormData(
|
||||
'login/ganti_pass_tim_survei', formData);
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.e(e.toString());
|
||||
return false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import 'package:cek_suara_app/ui/views/tim_survei_index_tracking/first_page/first_page_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../first_page/first_page_view.dart';
|
||||
import './halaman_pengaturan_view_model.dart';
|
||||
|
||||
class HalamanPengaturanView extends StatelessWidget {
|
||||
|
Reference in New Issue
Block a user