-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Home screen refactoring * Home screen refactoring * Fix preview * Sync preview (#26) * Sync preview * Add pagination in home media list * Add pagination in home media list * Improve home performance * Minor fix
- Loading branch information
1 parent
05c379a
commit b00c0ab
Showing
39 changed files
with
1,569 additions
and
485 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extension MapExtension<K, E> on Map<K, List<E>> { | ||
List<E> valuesWhere(bool Function(E element) test) => | ||
values.expand((element) => element.where(test)).toList(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:cloud_gallery/domain/extensions/context_extensions.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
enum DateFormatType { | ||
dayMonthYear("d MMMM, y"), | ||
dayMonthYearShort("d MMM, y"), | ||
monthYear("MMMM y"), | ||
monthYearShort("MMM y"), | ||
dayMonth("d MMMM"), | ||
dayMonthShort("d MMM"), | ||
year("y"), | ||
month("MMMM"), | ||
monthShort("MMM"), | ||
week("EEEE"), | ||
time("HH:mm:ss a"), | ||
timeShort("HH:mm a"), | ||
relative("relative"); | ||
|
||
final String formatPattern; | ||
|
||
const DateFormatType(this.formatPattern); | ||
|
||
bool get isRelative => this == DateFormatType.relative; | ||
} | ||
|
||
extension DateFormatter on DateTime { | ||
DateTime get dateOnly => DateTime(year, month, day); | ||
|
||
String format(BuildContext context, DateFormatType type) { | ||
if (isUtc) return toLocal().format(context, type); | ||
if (type.isRelative) return relativeFormat(context); | ||
return DateFormat(type.formatPattern).format(this); | ||
} | ||
|
||
String relativeFormat(BuildContext context) { | ||
if (isUtc) return toLocal().relativeFormat(context); | ||
final now = DateTime.now().toLocal(); | ||
final diff = now.difference(this); | ||
if (diff.inDays == 0) { | ||
return context.l10n.common_today; | ||
} else if (diff.inDays == 1) { | ||
return context.l10n.common_yesterday; | ||
} else if (diff.inDays == -1) { | ||
return context.l10n.common_tomorrow; | ||
} else if (diff.inDays < 7) { | ||
return DateFormat(DateFormatType.week.formatPattern).format(this); | ||
} else if (now.year == year) { | ||
return DateFormat(DateFormatType.dayMonth.formatPattern).format(this); | ||
} else { | ||
return DateFormat(DateFormatType.dayMonthYear.formatPattern).format(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extension DurationFormatter on Duration { | ||
String get format { | ||
String twoDigits(int n) { | ||
if (n >= 10) return "$n"; | ||
return "0$n"; | ||
} | ||
|
||
String twoDigitHours = twoDigits(inHours.remainder(24)); | ||
String twoDigitMinutes = twoDigits(inMinutes.remainder(60)); | ||
String twoDigitSeconds = twoDigits(inSeconds.remainder(60)); | ||
|
||
if (inHours > 0) { | ||
return "$twoDigitHours:$twoDigitMinutes:$twoDigitSeconds"; | ||
} else { | ||
return "$twoDigitMinutes:$twoDigitSeconds"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.