|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
@ -8,7 +9,9 @@ import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
|
|
|
|
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../extensions/text_extensions.dart';
|
|
|
|
|
@ -37,35 +40,44 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_model.fromGasRefillModel(widget.model);
|
|
|
|
|
// _model.fromGasRefillModel(gasRefillModel);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
_userProvider = Provider.of<UserProvider>(context);
|
|
|
|
|
GasRefillProvider _gasRefillProvider = Provider.of<GasRefillProvider>(context);
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: context.translation.gasRefillDetails),
|
|
|
|
|
key: _scaffoldKey,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: LoadingManager(
|
|
|
|
|
isLoading: _isLoading,
|
|
|
|
|
isFailedLoading: false,
|
|
|
|
|
stateCode: 200,
|
|
|
|
|
onRefresh: () async {},
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [informationCard()],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: FutureBuilder(
|
|
|
|
|
future: _gasRefillProvider.getGasRefillObjectById(widget.model.id),
|
|
|
|
|
builder: (context, snap) {
|
|
|
|
|
if (snap.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return const ALoading();
|
|
|
|
|
} else if (!snap.hasData) {
|
|
|
|
|
_model = snap.data;
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: informationCard(_model),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return NoItemFound(message: context.translation.noDataFound);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget informationCard() {
|
|
|
|
|
Widget informationCard(GasRefillModel gasRefillModel) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
@ -87,24 +99,24 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
//),
|
|
|
|
|
// 8.width,
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: widget.model.status?.name ?? "",
|
|
|
|
|
textColor: AColors.getRequestStatusTextColor(widget.model.status?.value ?? 0),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColor(widget.model.status?.value ?? 0)),
|
|
|
|
|
label: gasRefillModel.status?.name ?? "",
|
|
|
|
|
textColor: AColors.getRequestStatusTextColor(gasRefillModel.status?.value ?? 0),
|
|
|
|
|
backgroundColor: AColors.getRequestStatusColor(gasRefillModel.status?.value ?? 0)),
|
|
|
|
|
8.height,
|
|
|
|
|
context.translation.gasRefillRequest.heading5(context),
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
|
|
///TBD
|
|
|
|
|
context.translation.gasRequest.bodyText(context),
|
|
|
|
|
'${context.translation.cylinderSize}: ${widget.model.gazRefillDetails[0].cylinderSize.value}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${widget.model.site.name}'.bodyText(context),
|
|
|
|
|
'${context.translation.cylinderSize}: ${gasRefillModel.gazRefillDetails[0].cylinderSize.value}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${gasRefillModel.site.name}'.bodyText(context),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
1.width.expanded,
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer && (widget.model.status?.value ?? 0) != 2)
|
|
|
|
|
if (_userProvider.user.type == UsersTypes.engineer && (gasRefillModel.status?.value ?? 0) != 2)
|
|
|
|
|
CircleAvatar(
|
|
|
|
|
radius: 25,
|
|
|
|
|
backgroundColor: AppColor.neutral30,
|
|
|
|
|
@ -118,13 +130,13 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
),
|
|
|
|
|
).onPress(
|
|
|
|
|
() async {
|
|
|
|
|
_model?.fromGasRefillModel(widget.model);
|
|
|
|
|
_model?.fromGasRefillModel(gasRefillModel);
|
|
|
|
|
// setState(() {});
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => RequestGasRefill(
|
|
|
|
|
gasRefillModel: widget.model,
|
|
|
|
|
gasRefillModel: gasRefillModel,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).then((value) {
|
|
|
|
|
@ -135,7 +147,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Text(widget.model.startDate?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
Text(gasRefillModel.startDate?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
@ -143,8 +155,8 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
8.height,
|
|
|
|
|
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
|
|
|
|
|
8.height,
|
|
|
|
|
'${context.translation.requestedQuantity}: ${widget.model.gazRefillDetails[0].requestedQty}'.bodyText(context),
|
|
|
|
|
'${context.translation.deliveredQuantity}: ${widget.model.gazRefillDetails[0].deliverdQty}'.bodyText(context),
|
|
|
|
|
'${context.translation.requestedQuantity}: ${gasRefillModel.gazRefillDetails[0].requestedQty}'.bodyText(context),
|
|
|
|
|
'${context.translation.deliveredQuantity}: ${gasRefillModel.gazRefillDetails[0].deliverdQty}'.bodyText(context),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
).paddingAll(16),
|
|
|
|
|
@ -173,7 +185,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
color: AppColor.neutral50.withOpacity(.6),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70),
|
|
|
|
|
SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 20 * AppStyle.getScaleFactor(context), color: AppColor.primary70),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
@ -202,6 +214,6 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
|
|
|
|
|
).paddingOnly(bottom: 16, start: 16, end: 16))
|
|
|
|
|
.onPress(() {}),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingAll(16);
|
|
|
|
|
).toShadowContainer(context, padding: 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|