From 46f61884bcd961a59585b57207bfe9c20fd68b4f Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 3 Aug 2023 12:21:42 +0300 Subject: [PATCH] In track gas refill summery to add Gas Type and Expected Date fields. --- .../widgets/gas_refill/gas_refill_item.dart | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 0ad575c1..aaf49bc2 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -1,11 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:test_sa/controllers/localization/localization.dart'; -import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; import 'package:test_sa/models/subtitle.dart'; -import 'package:test_sa/models/user.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart'; @@ -18,8 +14,7 @@ class GasRefillItem extends StatelessWidget { @override Widget build(BuildContext context) { - Subtitle _subtitle = AppLocalization.of(context).subtitle; - User _user = Provider.of(context, listen: false).user; + Subtitle subtitle = AppLocalization.of(context).subtitle; Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; @@ -27,7 +22,7 @@ class GasRefillItem extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 4), child: ElevatedButton( style: ElevatedButton.styleFrom( - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), backgroundColor: itemColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), @@ -48,14 +43,14 @@ class GasRefillItem extends StatelessWidget { children: [ Text( item.title ?? "-----", - style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), + 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.subtitle2.copyWith( + subtitle.hospital, + style: Theme.of(context).textTheme.titleSmall.copyWith( color: onItemColor, ), ), @@ -63,29 +58,48 @@ class GasRefillItem extends StatelessWidget { if (item.clientName != null) Text( item.clientName, - style: Theme.of(context).textTheme.subtitle2.copyWith( + style: Theme.of(context).textTheme.titleSmall.copyWith( color: onItemColor, ), ), ], ), - Divider( - color: onItemColor, - ), + Divider(color: onItemColor), Row( children: [ Expanded( - child: Text( - _subtitle.status, - style: Theme.of(context).textTheme.subtitle2.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)), ], ), - //Divider(color: onItemColor,), + if (item?.expectedDate != null) Divider(color: onItemColor), + if (item?.expectedDate != null) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text("Visit 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(), + ) + ], + ), ], ), ),