added user page, pimpinan page, e signature
This commit is contained in:
213
lib/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart
Normal file
213
lib/ui/views/detail_dana_sosial/detail_dana_sosial_view.dart
Normal file
@ -0,0 +1,213 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
import '../../../app/themes/app_colors.dart';
|
||||
import '../../../app/themes/app_text.dart';
|
||||
import '../../widgets/my_textformfield.dart';
|
||||
import './detail_dana_sosial_view_model.dart';
|
||||
|
||||
class DetailDanaSosialView extends StatelessWidget {
|
||||
final int id;
|
||||
|
||||
const DetailDanaSosialView({Key? key, required this.id}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder<DetailDanaSosialViewModel>.reactive(
|
||||
viewModelBuilder: () => DetailDanaSosialViewModel(),
|
||||
onViewModelReady: (DetailDanaSosialViewModel model) async {
|
||||
await model.init(id);
|
||||
},
|
||||
builder: (
|
||||
BuildContext context,
|
||||
DetailDanaSosialViewModel model,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Detail Dana Sosial',
|
||||
style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: mainColor,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Nama Donator",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.namaController,
|
||||
maxLines: 1,
|
||||
readOnly: true,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Tanggal",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.tanggalController,
|
||||
maxLines: 1,
|
||||
readOnly: true,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Jenis",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: model.jenisController,
|
||||
maxLines: 1,
|
||||
readOnly: true,
|
||||
),
|
||||
Visibility(
|
||||
visible: model.jenisBool,
|
||||
child: const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: model.jenisBool,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Jumlah",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: model.jenisBool,
|
||||
child: MyTextFormField(
|
||||
controller: model.jumlahController,
|
||||
maxLines: 1,
|
||||
readOnly: true,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !model.jenisBool,
|
||||
child: const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !model.jenisBool,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Keterangan",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !model.jenisBool,
|
||||
child: MyTextFormField(
|
||||
controller: model.keteranganController,
|
||||
maxLines: 2,
|
||||
readOnly: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Tanda Tangan",
|
||||
style: regularTextStyle.copyWith(color: mainColor),
|
||||
),
|
||||
SizedBox(
|
||||
height: 150,
|
||||
width: 150,
|
||||
child: model.danaSosialModel == null
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: mainColor),
|
||||
),
|
||||
)
|
||||
: (model.danaSosialModel!.status! ==
|
||||
'Belum Dikonfirmasi'
|
||||
? const TtdWidget()
|
||||
: Image.asset(
|
||||
'assets/qrcode.png',
|
||||
fit: BoxFit.cover,
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Dr. Andi Fitriani D, S.Ag, M.Pd",
|
||||
style: regularTextStyle.copyWith(
|
||||
color: mainColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
// create a horizontal line
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TtdWidget extends ViewModelWidget<DetailDanaSosialViewModel> {
|
||||
const TtdWidget({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, DetailDanaSosialViewModel viewModel) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: mainColor),
|
||||
),
|
||||
child: viewModel.role == 'pimpinan'
|
||||
? InkWell(
|
||||
onTap: () {
|
||||
viewModel.handleTtd();
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Tanda Tangan",
|
||||
style: regularTextStyle.copyWith(
|
||||
color: mainColor,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.logger.dart';
|
||||
import '../../../app/core/custom_base_view_model.dart';
|
||||
import '../../../model/dana_sosial_model.dart';
|
||||
import '../../../services/http_services.dart';
|
||||
import '../../../services/my_easyloading.dart';
|
||||
import '../../../services/other_function.dart';
|
||||
|
||||
class DetailDanaSosialViewModel extends CustomBaseViewModel {
|
||||
final log = getLogger('DetailDanaSosialViewModel');
|
||||
final _httpService = locator<MyHttpServices>();
|
||||
final easyLoading = locator<MyEasyLoading>();
|
||||
|
||||
int? idDanaSosial;
|
||||
DanaSosialModel? danaSosialModel;
|
||||
bool jenisBool = true;
|
||||
|
||||
String? role;
|
||||
|
||||
TextEditingController namaController = TextEditingController();
|
||||
TextEditingController tanggalController = TextEditingController();
|
||||
TextEditingController jumlahController = TextEditingController();
|
||||
TextEditingController jenisController = TextEditingController();
|
||||
TextEditingController keteranganController = TextEditingController();
|
||||
|
||||
Future<void> init(int id) async {
|
||||
log.i('init and id: $id');
|
||||
getData(id);
|
||||
idDanaSosial = id;
|
||||
prefs.then((SharedPreferences prefs) {
|
||||
role = prefs.getString('role');
|
||||
});
|
||||
}
|
||||
|
||||
getData(int id) async {
|
||||
setBusy(true);
|
||||
easyLoading.showLoading();
|
||||
try {
|
||||
var response = await _httpService.get('dana_sosial_detail?id=$id');
|
||||
log.i(response.data);
|
||||
danaSosialModel = DanaSosialModel.fromJson(response.data['data']);
|
||||
namaController.text = danaSosialModel!.nama!;
|
||||
tanggalController.text = danaSosialModel!.tanggal!;
|
||||
jumlahController.text =
|
||||
"Rp. ${OtherFunction().commaFormat(danaSosialModel!.jumlah != null ? int.parse(danaSosialModel!.jumlah!) : 0)}";
|
||||
jenisController.text = danaSosialModel!.jenisDonasi!;
|
||||
keteranganController.text = danaSosialModel!.keterangan!;
|
||||
|
||||
if (danaSosialModel!.jenisDonasi == 'Uang') {
|
||||
jenisBool = true;
|
||||
} else {
|
||||
jenisBool = false;
|
||||
}
|
||||
log.i('status: ${danaSosialModel!.status}');
|
||||
setBusy(false);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
setBusy(false);
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void handleTtd() {
|
||||
dialogService
|
||||
.showConfirmationDialog(
|
||||
title: 'Konfirmasi',
|
||||
description: 'Apakah anda yakin ingin mengkonfirmasi tanda tangan ini?',
|
||||
cancelTitle: 'Tidak',
|
||||
confirmationTitle: 'Ya',
|
||||
)
|
||||
.then((value) async {
|
||||
if (value!.confirmed) {
|
||||
setBusy(true);
|
||||
easyLoading.showLoading();
|
||||
try {
|
||||
FormData formData = FormData.fromMap({
|
||||
'id': idDanaSosial,
|
||||
});
|
||||
var response =
|
||||
await _httpService.postWithFormData('dana_sosial_ttd', formData);
|
||||
log.i(response.data);
|
||||
getData(idDanaSosial!);
|
||||
|
||||
setBusy(false);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
log.e(e);
|
||||
setBusy(false);
|
||||
dialogService.showDialog(
|
||||
title: 'Error',
|
||||
description: e.toString(),
|
||||
);
|
||||
} finally {
|
||||
easyLoading.dismissLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user