mirror of
https://github.com/Livinglist/Hacki.git
synced 2025-08-06 18:24:42 +08:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
92a743f2f0 | |||
4148240daf |
@ -119,7 +119,7 @@ class PreferenceState extends Equatable {
|
||||
Font get font =>
|
||||
Font.values.elementAt(preferences.singleWhereType<FontPreference>().val);
|
||||
|
||||
DisplayDateFormat get displayDateFormat => DisplayDateFormat.values
|
||||
DateDisplayFormat get displayDateFormat => DateDisplayFormat.values
|
||||
.elementAt(preferences.singleWhereType<DateFormatPreference>().val);
|
||||
|
||||
@override
|
||||
|
@ -3,7 +3,7 @@ import 'dart:io';
|
||||
import 'package:hacki/extensions/date_time_extension.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
enum DisplayDateFormat {
|
||||
enum DateDisplayFormat {
|
||||
timeAgo,
|
||||
yMd,
|
||||
yMEd,
|
||||
@ -24,7 +24,9 @@ enum DisplayDateFormat {
|
||||
}
|
||||
|
||||
String convertToString(int timestamp) {
|
||||
if (_cache.containsKey(timestamp)) {
|
||||
final bool isTimeAgo = this == timeAgo;
|
||||
|
||||
if (!isTimeAgo && _cache.containsKey(timestamp)) {
|
||||
return _cache[timestamp] ?? 'This is wrong';
|
||||
}
|
||||
|
||||
@ -35,10 +37,8 @@ enum DisplayDateFormat {
|
||||
|
||||
final DateTime date = DateTime.fromMillisecondsSinceEpoch(updatedTimeStamp);
|
||||
|
||||
if (this == timeAgo) {
|
||||
final String dateString = date.toTimeAgoString();
|
||||
_cache[timestamp] = dateString;
|
||||
return dateString;
|
||||
if (isTimeAgo) {
|
||||
return date.toTimeAgoString();
|
||||
} else {
|
||||
final String defaultLocale = Platform.localeName;
|
||||
final DateFormat formatter = DateFormat(name, defaultLocale).add_Hm();
|
@ -1,7 +1,7 @@
|
||||
export 'app_exception.dart';
|
||||
export 'comments_order.dart';
|
||||
export 'date_display_format.dart';
|
||||
export 'discoverable_feature.dart';
|
||||
export 'display_date_format.dart';
|
||||
export 'export_destination.dart';
|
||||
export 'fetch_mode.dart';
|
||||
export 'font.dart';
|
||||
|
@ -548,7 +548,7 @@ final class TextScaleFactorPreference extends DoublePreference {
|
||||
final class DateFormatPreference extends IntPreference {
|
||||
DateFormatPreference({int? val}) : super(val: val ?? _dateFormatDefaultValue);
|
||||
|
||||
static final int _dateFormatDefaultValue = DisplayDateFormat.timeAgo.index;
|
||||
static final int _dateFormatDefaultValue = DateDisplayFormat.timeAgo.index;
|
||||
|
||||
@override
|
||||
DateFormatPreference copyWith({required int? val}) {
|
||||
|
@ -171,18 +171,18 @@ class _SettingsState extends State<Settings> with ItemActionMixin {
|
||||
const Text(
|
||||
'Date time display of comments',
|
||||
),
|
||||
DropdownMenu<DisplayDateFormat>(
|
||||
DropdownMenu<DateDisplayFormat>(
|
||||
initialSelection: preferenceState.displayDateFormat,
|
||||
dropdownMenuEntries: DisplayDateFormat.values
|
||||
dropdownMenuEntries: DateDisplayFormat.values
|
||||
.map(
|
||||
(DisplayDateFormat val) =>
|
||||
DropdownMenuEntry<DisplayDateFormat>(
|
||||
(DateDisplayFormat val) =>
|
||||
DropdownMenuEntry<DateDisplayFormat>(
|
||||
value: val,
|
||||
label: val.description,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onSelected: (DisplayDateFormat? order) {
|
||||
onSelected: (DateDisplayFormat? order) {
|
||||
if (order != null) {
|
||||
HapticFeedbackUtil.selection();
|
||||
context.read<PreferenceCubit>().update(
|
||||
@ -190,7 +190,7 @@ class _SettingsState extends State<Settings> with ItemActionMixin {
|
||||
val: order.index,
|
||||
),
|
||||
);
|
||||
DisplayDateFormat.clearCache();
|
||||
DateDisplayFormat.clearCache();
|
||||
}
|
||||
},
|
||||
),
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: hacki
|
||||
description: A Hacker News reader.
|
||||
version: 2.7.0+138
|
||||
version: 2.7.1+139
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
|
Reference in New Issue
Block a user