handle unlimited
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
"subscription": {
|
||||
"traffic": "Traffic",
|
||||
"updatedTimeAgo": "Updated ${timeago}",
|
||||
"remainingDuration": "${duration} days remaining",
|
||||
"remainingDuration": "📅 ${duration} Days Remaining",
|
||||
"expired": "Expired",
|
||||
"noTraffic": "No more traffic"
|
||||
},
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"subscription": {
|
||||
"traffic": "ترافیک",
|
||||
"updatedTimeAgo": "بروزرسانی شده در ${timeago}",
|
||||
"remainingDuration": "${duration} روز باقی مانده",
|
||||
"remainingDuration": "📅 ${duration} روز باقی مانده",
|
||||
"expired": "منقضی شده",
|
||||
"noTraffic": "پایان ترافیک"
|
||||
},
|
||||
|
||||
@@ -128,6 +128,7 @@ class SubscriptionInfo with _$SubscriptionInfo {
|
||||
const factory SubscriptionInfo({
|
||||
required int upload,
|
||||
required int download,
|
||||
@JsonKey(fromJson: _fromJsonTotal, defaultValue: 9223372036854775807)
|
||||
required int total,
|
||||
@JsonKey(fromJson: _dateTimeFromSecondsSinceEpoch) required DateTime expire,
|
||||
}) = _SubscriptionInfo;
|
||||
@@ -154,5 +155,15 @@ class SubscriptionInfo with _$SubscriptionInfo {
|
||||
_$SubscriptionInfoFromJson(json);
|
||||
}
|
||||
|
||||
DateTime _dateTimeFromSecondsSinceEpoch(dynamic expire) =>
|
||||
DateTime.fromMillisecondsSinceEpoch((expire as int) * 1000);
|
||||
int _fromJsonTotal(dynamic total) {
|
||||
if (total == null) {
|
||||
return 9223372036854775807;
|
||||
}
|
||||
return total as int;
|
||||
}
|
||||
|
||||
DateTime _dateTimeFromSecondsSinceEpoch(dynamic expire) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(
|
||||
(expire as int? ?? 92233720368) * 1000,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -305,13 +305,17 @@ class ProfileSubscriptionInfo extends HookConsumerWidget {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final remaining = remainingText(t, theme);
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
subInfo.consumption.sizeOf(subInfo.total),
|
||||
style: theme.textTheme.bodySmall,
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Text(
|
||||
subInfo.total > 10 * 1099511627776 //10TB
|
||||
? "∞ GiB"
|
||||
: subInfo.consumption.sizeOf(subInfo.total),
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
remaining.$1,
|
||||
|
||||
Reference in New Issue
Block a user