Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 Error calculating time remaining in farm lock #260

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:flutter_gen/gen_l10n/localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gradient_borders/box_borders/gradient_box_border.dart';
import 'package:intl/intl.dart';
import 'package:moment_dart/moment_dart.dart';
import 'package:humanize_duration/humanize_duration.dart';

class FarmLockBlockListSingleLineLock extends ConsumerWidget {
const FarmLockBlockListSingleLineLock({
Expand Down Expand Up @@ -186,33 +186,38 @@ class FarmLockBlockListSingleLineLock extends ConsumerWidget {
child: Column(
children: [
SelectableText(
DateTime.fromMillisecondsSinceEpoch(
farmLockUserInfos.end! *
1000,
)
.difference(
DateTime.now()
.toUtc(),
)
.toDurationString(
includeWeeks: true,
round: false,
delimiter: ', ',
),
humanizeDuration(
DateTime.fromMillisecondsSinceEpoch(
farmLockUserInfos.end! *
1000,
).toUtc().difference(
DateTime.now()
.toUtc(),
),
options:
const HumanizeOptions(
units: [
Units.year,
Units.day,
Units.hour,
],
),
),
style: style,
),
SelectableText(
DateFormat.yMMMEd(
Localizations.localeOf(
context,
).languageCode,
).format(
DateTime
.fromMillisecondsSinceEpoch(
farmLockUserInfos.end! *
1000,
),
),
).add_Hm().format(
DateTime
.fromMillisecondsSinceEpoch(
farmLockUserInfos
.end! *
1000,
).toUtc(),
),
style:
AppTextStyles.bodySmall(
context,
Expand Down Expand Up @@ -447,19 +452,24 @@ class FarmLockBlockListSingleLineLock extends ConsumerWidget {
style: styleHeader,
),
SelectableText(
DateTime.fromMillisecondsSinceEpoch(
farmLockUserInfos.end! *
1000,
)
.difference(
DateTime.now()
.toUtc(),
)
.toDurationString(
includeWeeks: true,
round: false,
delimiter: ', ',
),
humanizeDuration(
DateTime.fromMillisecondsSinceEpoch(
farmLockUserInfos
.end! *
1000,
).toUtc().difference(
DateTime.now()
.toUtc(),
),
options:
const HumanizeOptions(
units: [
Units.year,
Units.day,
Units.hour,
],
),
),
style: style,
),
],
Expand All @@ -469,13 +479,14 @@ class FarmLockBlockListSingleLineLock extends ConsumerWidget {
Localizations.localeOf(
context,
).languageCode,
).format(
DateTime
.fromMillisecondsSinceEpoch(
farmLockUserInfos.end! *
1000,
),
),
).add_Hm().format(
DateTime
.fromMillisecondsSinceEpoch(
farmLockUserInfos
.end! *
1000,
).toUtc(),
),
style: Theme.of(context)
.textTheme
.bodySmall,
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
humanize_duration:
dependency: "direct main"
description:
name: humanize_duration
sha256: a9fb33b18d028aa2ffd1731af25f59cfcb3c1c2af673cf73fffc7f9a42b2f57e
url: "https://pub.dev"
source: hosted
version: "0.0.2"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -720,14 +728,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.5"
moment_dart:
dependency: "direct main"
description:
name: moment_dart
sha256: "721f008251341578a818140afe402be827bc29951846575598426f4039a0799b"
url: "https://pub.dev"
source: hosted
version: "2.2.1+beta.0"
ninja_asn1:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ dependencies:
hive: ^2.2.3
hive_flutter: ^1.1.0

# Utilities to make working with 'Duration's easier.
humanize_duration: ^0.0.2

# Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues.
intl: ^0.19.0

Expand All @@ -74,9 +77,6 @@ dependencies:
# A Flutter plugin for rendering an animated and customizable starfield on a dark background.
lit_starfield: ^0.1.1

# Utilities to make working with 'Duration's easier.
moment_dart: ^2.1.0

# Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data directories.
path_provider: ^2.1.2

Expand Down