feat : init statics
This commit is contained in:
33
packages/inspection/lib/presentation/pages/users/logic.dart
Normal file
33
packages/inspection/lib/presentation/pages/users/logic.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class UsersLogic extends GetxController {
|
||||
Rx<Resource<PaginationModel<int>>> countList = Resource<PaginationModel<int>>.success(
|
||||
PaginationModel(results: [1, 2, 3, 4, 5, 6], count: 1, next: null, previous: null),
|
||||
).obs;
|
||||
|
||||
RxBool isLoadingMore = false.obs;
|
||||
RxInt currentPage = 1.obs;
|
||||
RxInt indexExpanded = (-1).obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void toggleExpandedList(int index) {
|
||||
if (indexExpanded.value == index) {
|
||||
indexExpanded.value = -1;
|
||||
} else {
|
||||
indexExpanded.value = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
190
packages/inspection/lib/presentation/pages/users/view.dart
Normal file
190
packages/inspection/lib/presentation/pages/users/view.dart
Normal file
@@ -0,0 +1,190 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class UsersPage extends GetView<UsersLogic> {
|
||||
const UsersPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
listType: ListType.separated,
|
||||
resource: data.value,
|
||||
hasMore: data.value.data?.next != null,
|
||||
isPaginating: controller.isLoadingMore.value,
|
||||
onRefresh: () async {
|
||||
controller.currentPage.value = 1;
|
||||
//await controller.getAllocatedMade();
|
||||
},
|
||||
onLoadMore: () async {
|
||||
controller.currentPage.value++;
|
||||
iLog(controller.currentPage.value);
|
||||
// await controller.getAllocatedMade(true);
|
||||
},
|
||||
padding: EdgeInsets.fromLTRB(8, 12, 8, 80),
|
||||
itemBuilder: (context, index) {
|
||||
var item = data.value.data!.results![index];
|
||||
return ObxValue((val) {
|
||||
return ListItem2(
|
||||
selected: val.value == index,
|
||||
onTap: () => controller.toggleExpandedList(index),
|
||||
index: index,
|
||||
labelColor: AppColor.blueLight,
|
||||
labelIcon: Assets.vec.profile2OutlineSvg.path,
|
||||
labelIconColor: AppColor.bgIcon,
|
||||
secondChild: itemListExpandedWidget(item, index),
|
||||
child: itemListWidget(item),
|
||||
);
|
||||
}, controller.indexExpanded);
|
||||
},
|
||||
itemCount: data.value.data?.results?.length ?? 0,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8.h),
|
||||
);
|
||||
}, controller.countList),
|
||||
floatingActionButton: RFab.add(onPressed: () {}),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListWidget(int item) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
'داود خرم مهری پور',
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
Text(
|
||||
'09302545455',
|
||||
style: AppFonts.yekan10.copyWith(color: AppColor.darkGreyDarkHover),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('باقی مانده', style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal)),
|
||||
Text(
|
||||
'0 کیلوگرم',
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.darkGreyDarkHover),
|
||||
),
|
||||
],
|
||||
),
|
||||
Assets.vec.scanBarcodeSvg.svg(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemListExpandedWidget(int item, int index) {
|
||||
return Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'داوود خرم پور',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 32.h,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColor.blueLight,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1.w, color: AppColor.blueLightHover),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
spacing: 3,
|
||||
children: [
|
||||
Text(
|
||||
'تاریخ بازرسی',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
|
||||
Text(
|
||||
'1403/12/12',
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
buildRow(
|
||||
title: 'تلفن خریدار',
|
||||
value: '0326598653',
|
||||
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
buildRow(title: 'آخرین فعالیت', value: '1409/12/12'),
|
||||
buildRow(title: 'موجودی', value: '5KG'),
|
||||
buildRow(title: 'فروش رفته', value: '5KG'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible:true,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 16.w,
|
||||
children: [
|
||||
RElevated(
|
||||
text: 'ویرایش',
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
|
||||
onPressed: () {
|
||||
/* controller.setEditData(item);
|
||||
Get.bottomSheet(
|
||||
addOrEditBottomSheet(true),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
).whenComplete(() {
|
||||
controller.clearForm();
|
||||
});*/
|
||||
},
|
||||
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
|
||||
backgroundColor: AppColor.blueDark,
|
||||
),
|
||||
ROutlinedElevated(
|
||||
text: 'حذف',
|
||||
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
|
||||
width: 150.w,
|
||||
height: 40.h,
|
||||
onPressed: () {
|
||||
buildDeleteDialog(
|
||||
onConfirm: () async {
|
||||
// controller.isExpandedList.remove(index);
|
||||
// controller.denyAllocation(item.key ?? '');
|
||||
//await controller.deleteAllocation(item);
|
||||
},
|
||||
onRefresh: () async{}
|
||||
);
|
||||
},
|
||||
borderColor: AppColor.redNormal,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user