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