mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-04 23:24:20 +00:00
refactor: Remove unused utils, add duration formatter
This commit is contained in:
parent
2b8d3ee6d0
commit
df214a07bc
|
@ -1,13 +1,12 @@
|
||||||
// ignore_for_file: unnecessary_this
|
// ignore_for_file: unnecessary_this
|
||||||
|
|
||||||
extension DurationFormatter on Duration {
|
import 'dart:ui';
|
||||||
String toDayHourMinuteSecondFormat() => [
|
|
||||||
this.inHours.remainder(24),
|
|
||||||
this.inMinutes.remainder(60),
|
|
||||||
this.inSeconds.remainder(60)
|
|
||||||
].map((final int seg) => seg.toString().padLeft(2, '0')).join(':');
|
|
||||||
|
|
||||||
String toDayHourMinuteFormat() {
|
import 'package:duration/duration.dart';
|
||||||
|
import 'package:duration/locale.dart';
|
||||||
|
|
||||||
|
extension DurationFormatter on Duration {
|
||||||
|
String toTimezoneOffsetFormat() {
|
||||||
final designator = this >= Duration.zero ? '+' : '-';
|
final designator = this >= Duration.zero ? '+' : '-';
|
||||||
|
|
||||||
final Iterable<String> segments = [
|
final Iterable<String> segments = [
|
||||||
|
@ -18,15 +17,10 @@ extension DurationFormatter on Duration {
|
||||||
return '$designator${segments.first}:${segments.last}';
|
return '$designator${segments.first}:${segments.last}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// WAT: https://flutterigniter.com/how-to-format-duration/
|
String toPrettyString(final Locale locale) =>
|
||||||
String toHoursMinutesSecondsFormat() =>
|
prettyDuration(this, locale: getDurationLocale(locale));
|
||||||
this.toString().split('.').first.padLeft(8, '0');
|
|
||||||
|
|
||||||
String toDayHourMinuteFormat2() {
|
|
||||||
final Iterable<String> segments = [
|
|
||||||
this.inHours.remainder(24),
|
|
||||||
this.inMinutes.remainder(60),
|
|
||||||
].map((final int seg) => seg.toString().padLeft(2, '0'));
|
|
||||||
return '${segments.first} h ${segments.last} min';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DurationLocale getDurationLocale(final Locale locale) =>
|
||||||
|
DurationLocale.fromLanguageCode(locale.languageCode) ??
|
||||||
|
const EnglishDurationLocale();
|
||||||
|
|
|
@ -3,12 +3,3 @@ import 'package:flutter/material.dart';
|
||||||
Route materialRoute(final Widget widget) => MaterialPageRoute(
|
Route materialRoute(final Widget widget) => MaterialPageRoute(
|
||||||
builder: (final BuildContext context) => widget,
|
builder: (final BuildContext context) => widget,
|
||||||
);
|
);
|
||||||
|
|
||||||
Route noAnimationRoute(final Widget widget) => PageRouteBuilder(
|
|
||||||
pageBuilder: (
|
|
||||||
final BuildContext context,
|
|
||||||
final Animation<double> animation1,
|
|
||||||
final Animation<double> animation2,
|
|
||||||
) =>
|
|
||||||
widget,
|
|
||||||
);
|
|
||||||
|
|
Loading…
Reference in a new issue