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