modify struktur organisasi page so can be edited, add delete siswa, add 'pengeluaran' in dana sosial, added edit siswa dialog
This commit is contained in:
@ -0,0 +1,313 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:panti_asuhan/app/themes/app_colors.dart';
|
||||
import 'package:panti_asuhan/app/themes/app_text.dart';
|
||||
import 'package:panti_asuhan/ui/widgets/my_textformfield.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:validatorless/validatorless.dart';
|
||||
|
||||
import './edit_dialog_siswa_view_model.dart';
|
||||
|
||||
class EditDialogSiswaView extends StatelessWidget {
|
||||
final DialogRequest request;
|
||||
final Function(DialogResponse) completer;
|
||||
|
||||
const EditDialogSiswaView({
|
||||
Key? key,
|
||||
required this.request,
|
||||
required this.completer,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<EditDialogSiswaViewModel>.reactive(
|
||||
viewModelBuilder: () => EditDialogSiswaViewModel(),
|
||||
onViewModelReady: (EditDialogSiswaViewModel model) async {
|
||||
await model.init(request.data);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
EditDialogSiswaViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
key: model.formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
'Edit Data Siswa',
|
||||
style: boldTextStyle,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Nama',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
hintText: 'Masukkan Nama',
|
||||
controller: model.namaController,
|
||||
validator:
|
||||
Validatorless.required('Nama tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Tanggal Lahir',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.tanggalLahirController,
|
||||
readOnly: true,
|
||||
validator: Validatorless.required(
|
||||
'Tanggal lahir tidak boleh kosong'),
|
||||
onTap: () {
|
||||
model.changeDate(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Tempat Lahir',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
hintText: 'Masukkan Tempat Lahir',
|
||||
controller: model.tempatLahirController,
|
||||
validator: Validatorless.required(
|
||||
'Tempat lahir tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Jenis Kelamin',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 60,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: model.jenisKelamin,
|
||||
onChanged: (String? newValue) {
|
||||
// model.setSelectedJenisKelamin(newValue!);
|
||||
model.log.i(newValue);
|
||||
model.jenisKelamin = newValue!;
|
||||
model.notifyListeners();
|
||||
},
|
||||
items: model.jenisKelaminList.map((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(
|
||||
value,
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' No. Telepon',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
hintText: 'Masukkan No. Telepon',
|
||||
controller: model.noTelponController,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'No. telepon tidak boleh kosong'),
|
||||
Validatorless.number(
|
||||
'No. telepon harus berupa angka'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Agama',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.agamaController,
|
||||
validator:
|
||||
Validatorless.required('Agama tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Kewarganegaraan',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.kewarganegaraanController,
|
||||
validator: Validatorless.required(
|
||||
'Kewarganegaraan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Alamat',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.alamatController,
|
||||
maxLines: 2,
|
||||
validator:
|
||||
Validatorless.required('Alamat tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Pendidikan SD',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.pendidikanSDController,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SD tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Pendidikan SMP',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.pendidikanSMPController,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMP tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Pendidikan SMA',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.pendidikanSMAController,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMA tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Kemampuan',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.kemampuanController,
|
||||
maxLines: 4,
|
||||
validator: Validatorless.required(
|
||||
'Kemampuan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
' Hobi',
|
||||
style: regularTextStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: mainColor,
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.hobiController,
|
||||
maxLines: 4,
|
||||
validator:
|
||||
Validatorless.required('Hobi tidak boleh kosong'),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
'Batal',
|
||||
style: TextStyle(
|
||||
color: dangerColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (model.formKey.currentState!.validate()) {
|
||||
// bool res = await model.postData();
|
||||
// model.log.i("res: $res");
|
||||
// if (res) {
|
||||
// completer(
|
||||
// DialogResponse(
|
||||
// confirmed: true,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
}
|
||||
},
|
||||
child: const Text(
|
||||
'Update',
|
||||
style: TextStyle(
|
||||
color: blueColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_holo_date_picker/flutter_holo_date_picker.dart';
|
||||
|
||||
import '../../../../../app/app.logger.dart';
|
||||
import '../../../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../../../model/siswa_model.dart';
|
||||
|
||||
class EditDialogSiswaViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('EditDialogSiswaViewModel');
|
||||
SiswaModel? siswaModel;
|
||||
String jenisKelamin = 'Laki-laki';
|
||||
List<String> jenisKelaminList = ['Laki-laki', 'Perempuan'];
|
||||
|
||||
TextEditingController namaController = TextEditingController();
|
||||
TextEditingController tanggalLahirController = TextEditingController();
|
||||
TextEditingController tempatLahirController = TextEditingController();
|
||||
TextEditingController alamatController = TextEditingController();
|
||||
TextEditingController noTelponController = TextEditingController();
|
||||
TextEditingController agamaController = TextEditingController();
|
||||
TextEditingController kewarganegaraanController = TextEditingController();
|
||||
TextEditingController pendidikanSDController = TextEditingController();
|
||||
TextEditingController pendidikanSMPController = TextEditingController();
|
||||
TextEditingController pendidikanSMAController = TextEditingController();
|
||||
TextEditingController kemampuanController = TextEditingController();
|
||||
TextEditingController hobiController = TextEditingController();
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
Future<void> init(data) async {
|
||||
log.i('data: $data');
|
||||
setBusy(true);
|
||||
siswaModel = data;
|
||||
notifyListeners();
|
||||
setBusy(false);
|
||||
namaController.text = siswaModel!.nama!;
|
||||
tanggalLahirController.text = siswaModel!.tanggalLahir!;
|
||||
tempatLahirController.text = siswaModel!.tempatLahir!;
|
||||
alamatController.text = siswaModel!.alamat!;
|
||||
noTelponController.text = siswaModel!.noTelpon!;
|
||||
agamaController.text = siswaModel!.agama!;
|
||||
kewarganegaraanController.text = siswaModel!.kewarganegaraan!;
|
||||
pendidikanSDController.text = siswaModel!.pendidikanSd!;
|
||||
pendidikanSMPController.text = siswaModel!.pendidikanSmp!;
|
||||
pendidikanSMAController.text = siswaModel!.pendidikanSma!;
|
||||
kemampuanController.text = siswaModel!.kemampuan!;
|
||||
hobiController.text = siswaModel!.hobi!;
|
||||
|
||||
jenisKelamin = siswaModel!.jenisKelamin!;
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void changeDate(BuildContext context) async {
|
||||
// get today's date
|
||||
var datePicked = await DatePicker.showSimpleDatePicker(
|
||||
context,
|
||||
initialDate: DateTime(2010),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2015),
|
||||
dateFormat: "dd-MMMM-yyyy",
|
||||
locale: DateTimePickerLocale.id,
|
||||
looping: true,
|
||||
);
|
||||
|
||||
if (datePicked != null) {
|
||||
String date = datePicked.toString().split(' ')[0];
|
||||
tanggalLahirController.text = date;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,15 +43,15 @@ class EditSiswaView extends StatelessWidget {
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
child: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: Stack(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: fontParagraphColor,
|
||||
backgroundImage: model.siswaModel != null
|
||||
@ -67,164 +67,235 @@ class EditSiswaView extends StatelessWidget {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Nama',
|
||||
controller: model.namaController,
|
||||
validator:
|
||||
Validatorless.required('Nama tidak boleh kosong'),
|
||||
enabled: false,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Tanggal Lahir',
|
||||
controller: model.tanggalLahirController,
|
||||
readOnly: true,
|
||||
validator: Validatorless.required(
|
||||
'Tanggal lahir tidak boleh kosong'),
|
||||
enabled: false,
|
||||
onTap: () {
|
||||
// model.changeDate(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Tempat Lahir',
|
||||
controller: model.tempatLahirController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Tempat lahir tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// create dropdown button
|
||||
MyTextFormField(
|
||||
labelText: 'Jenis Kelamin',
|
||||
controller: model.jkController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMP tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'No. Telepon',
|
||||
controller: model.noTelponController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.number,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'No. telepon tidak boleh kosong'),
|
||||
Validatorless.number(
|
||||
'No. telepon harus berupa angka'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Agama',
|
||||
controller: model.agamaController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator:
|
||||
Validatorless.required('Agama tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Kewarganegaraan',
|
||||
controller: model.kewarganegaraanController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: Validatorless.required(
|
||||
'Kewarganegaraan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Alamat',
|
||||
controller: model.alamatController,
|
||||
enabled: false,
|
||||
maxLines: 2,
|
||||
validator:
|
||||
Validatorless.required('Alamat tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SD',
|
||||
controller: model.pendidikanSDController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SD tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SMP',
|
||||
controller: model.pendidikanSMPController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMP tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SMA',
|
||||
controller: model.pendidikanSMAController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMA tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Kemampuan',
|
||||
controller: model.kemampuanController,
|
||||
enabled: false,
|
||||
maxLines: 4,
|
||||
validator: Validatorless.required(
|
||||
'Kemampuan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: "Hobi",
|
||||
controller: model.hobiController,
|
||||
enabled: false,
|
||||
maxLines: 4,
|
||||
validator:
|
||||
Validatorless.required('Hobi tidak boleh kosong'),
|
||||
),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// TextButton(
|
||||
// onPressed: () {},
|
||||
// child: const Text(
|
||||
// 'Batal',
|
||||
// style: TextStyle(
|
||||
// color: dangerColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () async {
|
||||
// // if (model.formKey.currentState!.validate()) {
|
||||
// // bool res = await model.postData();
|
||||
// // model.log.i("res: $res");
|
||||
// // if (res) {
|
||||
// // completer(
|
||||
// // DialogResponse(
|
||||
// // confirmed: true,
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// },
|
||||
// child: const Text(
|
||||
// 'Simpan',
|
||||
// style: TextStyle(
|
||||
// color: blueColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 45,
|
||||
// create a edit rounded button
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: blueColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
// model.changeEdit();
|
||||
model.editData();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.edit,
|
||||
color: Colors.white,
|
||||
size: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Nama',
|
||||
controller: model.namaController,
|
||||
validator:
|
||||
Validatorless.required('Nama tidak boleh kosong'),
|
||||
enabled: false,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Tanggal Lahir',
|
||||
controller: model.tanggalLahirController,
|
||||
readOnly: true,
|
||||
validator: Validatorless.required(
|
||||
'Tanggal lahir tidak boleh kosong'),
|
||||
enabled: false,
|
||||
onTap: () {
|
||||
// model.changeDate(context);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Tempat Lahir',
|
||||
controller: model.tempatLahirController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Tempat lahir tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// create dropdown button
|
||||
MyTextFormField(
|
||||
labelText: 'Jenis Kelamin',
|
||||
controller: model.jkController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMP tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'No. Telepon',
|
||||
controller: model.noTelponController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.number,
|
||||
validator: Validatorless.multiple(
|
||||
[
|
||||
Validatorless.required(
|
||||
'No. telepon tidak boleh kosong'),
|
||||
Validatorless.number('No. telepon harus berupa angka'),
|
||||
],
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
// create a close rounded button
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: dangerColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
// model.changeEdit();
|
||||
model.dialogService
|
||||
.showDialog(
|
||||
title: 'Hapus Data',
|
||||
description:
|
||||
'Apakah anda yakin ingin menghapus data ini?',
|
||||
buttonTitle: 'Hapus',
|
||||
cancelTitle: 'Batal',
|
||||
buttonTitleColor: dangerColor,
|
||||
cancelTitleColor: mainColor,
|
||||
)
|
||||
.then((value) {
|
||||
if (value!.confirmed) {
|
||||
model.deleteData();
|
||||
// close dialog
|
||||
Navigator.pop(context);
|
||||
// model.navigationService.clearTillFirstAndShow(
|
||||
// Routes.splashScreenView);
|
||||
}
|
||||
});
|
||||
|
||||
// model.deleteData();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.delete_forever,
|
||||
color: Colors.white,
|
||||
size: 15,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Agama',
|
||||
controller: model.agamaController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator:
|
||||
Validatorless.required('Agama tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Kewarganegaraan',
|
||||
controller: model.kewarganegaraanController,
|
||||
enabled: false,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
validator: Validatorless.required(
|
||||
'Kewarganegaraan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Alamat',
|
||||
controller: model.alamatController,
|
||||
enabled: false,
|
||||
maxLines: 2,
|
||||
validator:
|
||||
Validatorless.required('Alamat tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SD',
|
||||
controller: model.pendidikanSDController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SD tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SMP',
|
||||
controller: model.pendidikanSMPController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMP tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Pendidikan SMA',
|
||||
controller: model.pendidikanSMAController,
|
||||
enabled: false,
|
||||
validator: Validatorless.required(
|
||||
'Pendidikan SMA tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: 'Kemampuan',
|
||||
controller: model.kemampuanController,
|
||||
enabled: false,
|
||||
maxLines: 4,
|
||||
validator:
|
||||
Validatorless.required('Kemampuan tidak boleh kosong'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MyTextFormField(
|
||||
labelText: "Hobi",
|
||||
controller: model.hobiController,
|
||||
enabled: false,
|
||||
maxLines: 4,
|
||||
validator:
|
||||
Validatorless.required('Hobi tidak boleh kosong'),
|
||||
),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// TextButton(
|
||||
// onPressed: () {},
|
||||
// child: const Text(
|
||||
// 'Batal',
|
||||
// style: TextStyle(
|
||||
// color: dangerColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () async {
|
||||
// // if (model.formKey.currentState!.validate()) {
|
||||
// // bool res = await model.postData();
|
||||
// // model.log.i("res: $res");
|
||||
// // if (res) {
|
||||
// // completer(
|
||||
// // DialogResponse(
|
||||
// // confirmed: true,
|
||||
// // ),
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// },
|
||||
// child: const Text(
|
||||
// 'Simpan',
|
||||
// style: TextStyle(
|
||||
// color: blueColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../app/app.dialogs.dart';
|
||||
import '../../../../app/app.locator.dart';
|
||||
import '../../../../app/app.logger.dart';
|
||||
import '../../../../app/core/custom_base_view_model.dart';
|
||||
@ -64,4 +66,46 @@ class EditSiswaViewModel extends CustomBaseViewModel {
|
||||
easyLoading.dismissLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void deleteData() async {
|
||||
setBusy(true);
|
||||
easyLoading.showLoading();
|
||||
try {
|
||||
var response = await _httpService.postWithFormData(
|
||||
'siswa_delete',
|
||||
FormData.fromMap(
|
||||
{
|
||||
'id': siswaModel!.idSiswa,
|
||||
},
|
||||
),
|
||||
);
|
||||
log.i(response.data);
|
||||
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Data berhasil dihapus',
|
||||
title: 'Berhasil',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
// navigationService.back();
|
||||
} catch (e) {
|
||||
snackbarService.showSnackbar(
|
||||
message: 'Data gagal dihapus',
|
||||
title: 'Gagal',
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
log.e(e);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
easyLoading.dismissLoading();
|
||||
}
|
||||
}
|
||||
|
||||
editData() async {
|
||||
var res = dialogService.showCustomDialog(
|
||||
variant: DialogType.editDialogSiswaView,
|
||||
data: siswaModel,
|
||||
);
|
||||
|
||||
res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user