files refactoring
parent
62cc13b1c0
commit
16a2fa2b26
@ -1,135 +1,135 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
|
||||
import '../../../extensions/text_extensions.dart';
|
||||
import '../../../models/new_models/gas_refill_model.dart';
|
||||
import '../../../new_views/app_style/app_color.dart';
|
||||
import '../requests/request_status.dart';
|
||||
|
||||
class GasRefillItem extends StatelessWidget {
|
||||
final int index;
|
||||
final GasRefillModel item;
|
||||
final Function(GasRefillModel) onPressed;
|
||||
|
||||
const GasRefillItem({Key? key,required this.item,required this.onPressed,required this.index}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// StatusLabel(
|
||||
// label: item.priority,
|
||||
// textColor: AppColor.getRequestStatusTextColorByName(context, item.priority),
|
||||
// backgroundColor: AppColor.getRequestStatusColorByName(context, item.priority),
|
||||
// ),
|
||||
StatusLabel(
|
||||
label: item.status!.name,
|
||||
textColor: AppColor.getRequestStatusTextColor(context, item.status!.value!),
|
||||
backgroundColor: AppColor.getRequestStatusColor(context, item.status!.value!),
|
||||
),
|
||||
1.width.expanded,
|
||||
Text(item.startDate != null ? item.startDate!.toServiceRequestCardFormat : "",
|
||||
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF3B3D4A))),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
context.translation.gasRefillRequest.heading5(context),
|
||||
'${context.translation.gasType}: ${item.gasRefillDetails![0].gasType!.name}'.bodyText(context),
|
||||
'${context.translation.site}: ${item.site!.name}'.bodyText(context),
|
||||
8.height,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.viewDetails,
|
||||
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
||||
),
|
||||
4.width,
|
||||
const Icon(
|
||||
Icons.arrow_forward,
|
||||
color: Color(0xFF4A8DB7),
|
||||
size: 14,
|
||||
)
|
||||
],
|
||||
).onPress(() => onPressed(item)),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// item.title ?? "-----",
|
||||
// style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// subtitle.hospital,
|
||||
// style: Theme.of(context).textTheme.titleSmall.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// if (item.clientName != null)
|
||||
// Text(
|
||||
// item.clientName,
|
||||
// style: Theme.of(context).textTheme.titleSmall.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Divider(color: onItemColor),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// ),
|
||||
// if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
|
||||
// ],
|
||||
// ),
|
||||
// if (item?.expectedDate != null) Divider(color: onItemColor),
|
||||
// if (item?.expectedDate != null)
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// ],
|
||||
// ),
|
||||
// if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.end,
|
||||
// children: item.details
|
||||
// .map(
|
||||
// (gas) => gas?.type?.name?.isNotEmpty ?? false
|
||||
// ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
|
||||
// : const SizedBox.shrink(),
|
||||
// )
|
||||
// .toList(),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
).toShadowContainer(context).paddingOnly(bottom: 8);
|
||||
}
|
||||
}
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/extensions/string_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
//
|
||||
// import '../../../extensions/text_extensions.dart';
|
||||
// import '../../../models/new_models/gas_refill_model.dart';
|
||||
// import '../../../new_views/app_style/app_color.dart';
|
||||
// import '../requests/request_status.dart';
|
||||
//
|
||||
// class GasRefillItem extends StatelessWidget {
|
||||
// final int index;
|
||||
// final GasRefillModel item;
|
||||
// final Function(GasRefillModel) onPressed;
|
||||
// todo @delete
|
||||
// const GasRefillItem({Key? key,required this.item,required this.onPressed,required this.index}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// // StatusLabel(
|
||||
// // label: item.priority,
|
||||
// // textColor: AppColor.getRequestStatusTextColorByName(context, item.priority),
|
||||
// // backgroundColor: AppColor.getRequestStatusColorByName(context, item.priority),
|
||||
// // ),
|
||||
// StatusLabel(
|
||||
// label: item.status!.name,
|
||||
// textColor: AppColor.getRequestStatusTextColor(context, item.status!.value!),
|
||||
// backgroundColor: AppColor.getRequestStatusColor(context, item.status!.value!),
|
||||
// ),
|
||||
// 1.width.expanded,
|
||||
// Text(item.startDate != null ? item.startDate!.toServiceRequestCardFormat : "",
|
||||
// textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF3B3D4A))),
|
||||
// ],
|
||||
// ),
|
||||
// 8.height,
|
||||
// context.translation.gasRefillRequest.heading5(context),
|
||||
// '${context.translation.gasType}: ${item.gasRefillDetails![0].gasType!.name}'.bodyText(context),
|
||||
// '${context.translation.site}: ${item.site!.name}'.bodyText(context),
|
||||
// 8.height,
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Text(
|
||||
// context.translation.viewDetails,
|
||||
// style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
|
||||
// ),
|
||||
// 4.width,
|
||||
// const Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: Color(0xFF4A8DB7),
|
||||
// size: 14,
|
||||
// )
|
||||
// ],
|
||||
// ).onPress(() => onPressed(item)),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Expanded(
|
||||
// // child: Column(
|
||||
// // crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// // children: [
|
||||
// // Text(
|
||||
// // item.title ?? "-----",
|
||||
// // style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
// // ),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Expanded(
|
||||
// // child: Text(
|
||||
// // subtitle.hospital,
|
||||
// // style: Theme.of(context).textTheme.titleSmall.copyWith(
|
||||
// // color: onItemColor,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// // if (item.clientName != null)
|
||||
// // Text(
|
||||
// // item.clientName,
|
||||
// // style: Theme.of(context).textTheme.titleSmall.copyWith(
|
||||
// // color: onItemColor,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // Divider(color: onItemColor),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Expanded(
|
||||
// // child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// // ),
|
||||
// // if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
|
||||
// // ],
|
||||
// // ),
|
||||
// // if (item?.expectedDate != null) Divider(color: onItemColor),
|
||||
// // if (item?.expectedDate != null)
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// // children: [
|
||||
// // Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// // Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// // ],
|
||||
// // ),
|
||||
// // if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// // crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// // children: [
|
||||
// // if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
|
||||
// // Column(
|
||||
// // crossAxisAlignment: CrossAxisAlignment.end,
|
||||
// // children: item.details
|
||||
// // .map(
|
||||
// // (gas) => gas?.type?.name?.isNotEmpty ?? false
|
||||
// // ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
|
||||
// // : const SizedBox.shrink(),
|
||||
// // )
|
||||
// // .toList(),
|
||||
// // )
|
||||
// // ],
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// ],
|
||||
// ).toShadowContainer(context).paddingOnly(bottom: 8);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,50 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/pages/user/gas_refill/gas_refill_details.dart';
|
||||
import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
|
||||
import '../../../models/new_models/gas_refill_model.dart';
|
||||
|
||||
class GasRefillList extends StatefulWidget {
|
||||
final List<GasRefillModel> items;
|
||||
final bool nextPage;
|
||||
final Future<void> Function() onLazyLoad;
|
||||
|
||||
const GasRefillList({Key? key,required this.items,required this.nextPage,required this.onLazyLoad}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GasRefillList> createState() => _GasRefillListState();
|
||||
}
|
||||
|
||||
class _GasRefillListState extends State<GasRefillList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.items.isEmpty) {
|
||||
return NoDataFound(
|
||||
message: context.translation.noServiceRequestFound,
|
||||
);
|
||||
}
|
||||
return LazyLoading(
|
||||
nextPage: widget.nextPage,
|
||||
onLazyLoad: widget.onLazyLoad,
|
||||
child: ListView.builder(
|
||||
//physics: const BouncingScrollPhysics(),
|
||||
itemCount: widget.items.length,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
itemBuilder: (context, itemIndex) {
|
||||
return GasRefillItem(
|
||||
index: itemIndex,
|
||||
item: widget.items[itemIndex],
|
||||
onPressed: (model) {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => GasRefillDetailsPage(model: model))).then((value) {
|
||||
model = value;
|
||||
setState(() {});
|
||||
});
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/modules/tm_module/gas_refill/gas_refill_details.dart';
|
||||
// import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
//
|
||||
// import '../../../models/new_models/gas_refill_model.dart';
|
||||
// todo @delete
|
||||
// class GasRefillList extends StatefulWidget {
|
||||
// final List<GasRefillModel> items;
|
||||
// final bool nextPage;
|
||||
// final Future<void> Function() onLazyLoad;
|
||||
//
|
||||
// const GasRefillList({Key? key,required this.items,required this.nextPage,required this.onLazyLoad}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<GasRefillList> createState() => _GasRefillListState();
|
||||
// }
|
||||
//
|
||||
// class _GasRefillListState extends State<GasRefillList> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// if (widget.items.isEmpty) {
|
||||
// return NoDataFound(
|
||||
// message: context.translation.noServiceRequestFound,
|
||||
// );
|
||||
// }
|
||||
// return LazyLoading(
|
||||
// nextPage: widget.nextPage,
|
||||
// onLazyLoad: widget.onLazyLoad,
|
||||
// child: ListView.builder(
|
||||
// //physics: const BouncingScrollPhysics(),
|
||||
// itemCount: widget.items.length,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
// itemBuilder: (context, itemIndex) {
|
||||
// return GasRefillItem(
|
||||
// index: itemIndex,
|
||||
// item: widget.items[itemIndex],
|
||||
// onPressed: (model) {
|
||||
// Navigator.of(context).push(MaterialPageRoute(builder: (_) => GasRefillDetailsPage(model: model))).then((value) {
|
||||
// model = value;
|
||||
// setState(() {});
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
Loading…
Reference in New Issue