added add siswa and dana sosial

This commit is contained in:
kicap
2023-05-18 18:58:21 +08:00
parent 949474b8ef
commit e0b5213a3b
14 changed files with 519 additions and 161 deletions

View File

@ -88,27 +88,52 @@ class DanaSosialAdminView extends StatelessWidget {
),
],
),
child: ListView.builder(
padding: const EdgeInsets.symmetric(
horizontal: 15, vertical: 10),
itemCount: 20,
itemBuilder: (context, index) {
return Card(
child: GestureDetector(
onTap: () {
model.log.i('Card $index tapped');
},
child: ListTile(
title: Text('1/02/15 - 10.00 am',
style: boldTextStyle.copyWith(
fontSize: 13, color: mainColor)),
subtitle: Text('Progress $index'),
trailing: Text('Pembangunan $index'),
child: (model.danaSosialModelList.isEmpty)
? Center(
child: Text(
'Tidak ada data',
style: boldTextStyle.copyWith(
fontSize: 20,
),
),
)
: ListView.builder(
padding: const EdgeInsets.symmetric(
horizontal: 15, vertical: 10),
itemCount: model.danaSosialModelList.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
title: Text(
model.danaSosialModelList[index].tanggal ??
'',
style: boldTextStyle.copyWith(
fontSize: 13, color: mainColor)),
subtitle: Text(
'Rp. ${model.danaSosialModelList[index].jumlah}',
style: regularTextStyle.copyWith(
fontSize: 13, color: mainColor)),
trailing: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: mainColor,
borderRadius: BorderRadius.circular(50),
),
child: IconButton(
onPressed: () {
// model.goToTambahDanaSosial();
},
icon: const Icon(
Icons.edit,
color: Colors.white,
),
),
),
),
);
},
),
);
},
),
),
),
],

View File

@ -1,10 +1,48 @@
import '../../../../app/app.locator.dart';
import '../../../../app/app.logger.dart';
import '../../../../app/app.router.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';
class DanaSosialAdminViewModel extends CustomBaseViewModel {
final log = getLogger('DanaSosialAdminViewModel');
Future<void> init() async {}
final _httpService = locator<MyHttpServices>();
final easyLoading = locator<MyEasyLoading>();
List<DanaSosialModel> danaSosialModelList = [];
Future<void> init() async {
await getData();
}
getData() async {
setBusy(true);
easyLoading.showLoading();
try {
var response = await _httpService.get('dana_sosial');
log.i(response.data);
danaSosialModelList = [];
var datanya = response.data['data'];
// log.i(datanya.length);
if (datanya.length > 0) {
for (var item in datanya) {
danaSosialModelList.add(DanaSosialModel.fromJson(item));
}
}
setBusy(false);
notifyListeners();
log.i(danaSosialModelList);
} catch (e) {
log.e(e);
setBusy(false);
} finally {
easyLoading.dismissLoading();
}
}
goToTambahDanaSosial() {
navigationService.navigateTo(Routes.tambahDanaSosialView);