From c402a9e292bda0ec8784db98668f0de710e29d98 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Sun, 18 Feb 2024 14:34:54 +0330 Subject: [PATCH] Add detailed subscription info --- assets/translations/strings_en.i18n.json | 6 +- .../profile/details/profile_details_page.dart | 70 ++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/assets/translations/strings_en.i18n.json b/assets/translations/strings_en.i18n.json index 31b62423..7751f6b3 100644 --- a/assets/translations/strings_en.i18n.json +++ b/assets/translations/strings_en.i18n.json @@ -56,7 +56,11 @@ "remainingDuration": "${duration} Days Remaining", "remainingTrafficSemanticLabel": "${consumed} of ${total} traffic consumed.", "expired": "Expired", - "noTraffic": "Out of Quota" + "noTraffic": "Out of Quota", + "upload": "Upload", + "download": "Download", + "total": "Total Traffic", + "expireDate": "Expire Date" }, "sortBy": { "lastUpdate": "Recently updated", diff --git a/lib/features/profile/details/profile_details_page.dart b/lib/features/profile/details/profile_details_page.dart index af940db5..e1ae13b9 100644 --- a/lib/features/profile/details/profile_details_page.dart +++ b/lib/features/profile/details/profile_details_page.dart @@ -1,6 +1,7 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:flutter/material.dart'; import 'package:fpdart/fpdart.dart'; +import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hiddify/core/localization/translations.dart'; import 'package:hiddify/core/model/failures.dart'; @@ -203,12 +204,69 @@ class ProfileDetailsPage extends HookConsumerWidget with PresLogger { }, ), ], - if (state.isEditing) + if (state.isEditing) ...[ ListTile( title: Text(t.profile.detailsForm.lastUpdate), + leading: + const Icon(FluentIcons.history_24_regular), subtitle: Text(state.profile.lastUpdate.format()), dense: true, ), + ], + if (state.profile + case RemoteProfileEntity(:final subInfo?)) ...[ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 18, + vertical: 8, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text.rich( + style: + Theme.of(context).textTheme.bodySmall, + TextSpan( + children: [ + _buildSubProp( + FluentIcons.arrow_upload_16_regular, + subInfo.upload.size(), + t.profile.subscription.upload, + ), + const TextSpan(text: " "), + _buildSubProp( + FluentIcons.arrow_download_16_regular, + subInfo.download.size(), + t.profile.subscription.download, + ), + const TextSpan(text: " "), + _buildSubProp( + FluentIcons + .arrow_bidirectional_up_down_16_regular, + subInfo.total.size(), + t.profile.subscription.total, + ), + ], + ), + ), + const Gap(12), + Text.rich( + style: + Theme.of(context).textTheme.bodySmall, + TextSpan( + children: [ + _buildSubProp( + FluentIcons.clock_dismiss_20_regular, + subInfo.expire.format(), + t.profile.subscription.expireDate, + ), + ], + ), + ), + ], + ), + ), + ], ], ), ), @@ -283,4 +341,14 @@ class ProfileDetailsPage extends HookConsumerWidget with PresLogger { return const Scaffold(); } } + + InlineSpan _buildSubProp(IconData icon, String text, String semanticLabel) { + return TextSpan( + children: [ + WidgetSpan(child: Icon(icon, size: 16, semanticLabel: semanticLabel)), + const TextSpan(text: " "), + TextSpan(text: text), + ], + ); + } }