Initial commit

This commit is contained in:
kicap
2024-03-02 08:48:26 +08:00
commit 758f5f3d8f
181 changed files with 9753 additions and 0 deletions

View File

@ -0,0 +1,103 @@
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import '../../../../app/themes/app_colors.dart';
import '../../../../app/themes/app_text.dart';
import './penyewa_log_view_model.dart';
class PenyewaLogView extends StatelessWidget {
const PenyewaLogView({super.key});
@override
Widget build(BuildContext context) {
return ViewModelBuilder<PenyewaLogViewModel>.reactive(
viewModelBuilder: () => PenyewaLogViewModel(),
onViewModelReady: (PenyewaLogViewModel model) async {
await model.init();
},
fireOnViewModelReadyOnce: true,
builder: (
BuildContext context,
PenyewaLogViewModel model,
Widget? child,
) {
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
body: Column(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: mainGrey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset:
const Offset(0, 3), // changes position of shadow
),
],
),
child: model.logHistorySewaanList == null
? const Center(child: CircularProgressIndicator())
: ListView.builder(
padding: const EdgeInsets.symmetric(
horizontal: 15, vertical: 10),
itemCount: model.logHistorySewaanList!.length,
itemBuilder: (context, index) {
// model.log
// .i(model.logHistorySewaanList![index].date);
return GestureDetector(
onTap: () {
// model.log.i('clicked on index $index');
model.checkKet(
model.logHistorySewaanList![index],
);
},
child: Card(
child: ListTile(
title: Text(
model.logHistorySewaanList![index].jenis!,
style:
boldTextStyle.copyWith(fontSize: 15),
),
subtitle: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
// Text(
// 'Tempat : ${model.logHistorySewaanList![index].}',
// style: regularTextStyle,
// ),
// Text(
// model.logHistorySewaanList![index]
// .jenis!,
// style: italicTextStyle,
// ),
],
),
// dummy date and time
trailing: Text(
model.otherFunction.formatDateString(model
.logHistorySewaanList![index].date!),
style: regularTextStyle,
),
),
),
);
},
),
),
)
],
),
),
);
},
);
}
}

View File

@ -0,0 +1,39 @@
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/penyewa_model.dart';
class PenyewaLogViewModel extends CustomBaseViewModel {
final log = getLogger('PenyewaLogViewModel');
List<PenyewaModel>? logHistorySewaanList;
String? nik;
Future<void> init() async {
nik = await mySharedPrefs.getString('nik');
await getData(nik);
}
getData(String? nik) async {
try {
var response = await httpService.get('user/log_user/$nik');
MyResponseModel myResponseModel = MyResponseModel.fromJson(response.data);
log.i(myResponseModel.data);
logHistorySewaanList = [];
myResponseModel.data.forEach((item) {
PenyewaModel penyewa = PenyewaModel.fromJson(item);
logHistorySewaanList!.add(penyewa);
log.d(penyewa);
});
notifyListeners();
} catch (e) {
log.e(e);
}
}
checkKet(PenyewaModel penyewaModel) async {
await bottomSheetService.showCustomSheet(
variant: BottomSheetType.detailLogHistoryView,
data: penyewaModel,
);
}
}