mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #1080 from richardshiue/fix-include-time
fix: some improvements for when including time in a date cell
This commit is contained in:
commit
a5e0e97df5
@ -222,8 +222,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Doc",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"board": {
|
"board": {
|
||||||
|
@ -210,8 +210,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Doc",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sideBar": {
|
"sideBar": {
|
||||||
|
@ -208,8 +208,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Doc",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -211,8 +211,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "Doc",
|
"menuName": "Doc",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sideBar": {
|
"sideBar": {
|
||||||
|
@ -221,8 +221,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "Документ",
|
"menuName": "Документ",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"board": {
|
"board": {
|
||||||
|
@ -215,8 +215,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "文档",
|
"menuName": "文档",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -211,8 +211,8 @@
|
|||||||
"document": {
|
"document": {
|
||||||
"menuName": "檔案",
|
"menuName": "檔案",
|
||||||
"date": {
|
"date": {
|
||||||
"timeHintTextInTwelveHour": "12:00 AM",
|
"timeHintTextInTwelveHour": "01:00 PM",
|
||||||
"timeHintTextInTwentyFourHour": "12:00"
|
"timeHintTextInTwentyFourHour": "13:00"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sideBar": {
|
"sideBar": {
|
||||||
|
@ -108,7 +108,7 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
|
|||||||
(err) {
|
(err) {
|
||||||
switch (ErrorCode.valueOf(err.code)!) {
|
switch (ErrorCode.valueOf(err.code)!) {
|
||||||
case ErrorCode.InvalidDateTimeFormat:
|
case ErrorCode.InvalidDateTimeFormat:
|
||||||
updateCalData(none(), Some(timeFormatPrompt(err)));
|
updateCalData(state.calData, Some(timeFormatPrompt(err)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.error(err);
|
Log.error(err);
|
||||||
@ -119,13 +119,13 @@ class DateCalBloc extends Bloc<DateCalEvent, DateCalState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String timeFormatPrompt(FlowyError error) {
|
String timeFormatPrompt(FlowyError error) {
|
||||||
String msg = "${LocaleKeys.grid_field_invalidTimeFormat.tr()}. ";
|
String msg = "${LocaleKeys.grid_field_invalidTimeFormat.tr()}.";
|
||||||
switch (state.dateTypeOptionPB.timeFormat) {
|
switch (state.dateTypeOptionPB.timeFormat) {
|
||||||
case TimeFormat.TwelveHour:
|
case TimeFormat.TwelveHour:
|
||||||
msg = "${msg}e.g. 01: 00 AM";
|
msg = "$msg e.g. 01:00 PM";
|
||||||
break;
|
break;
|
||||||
case TimeFormat.TwentyFourHour:
|
case TimeFormat.TwentyFourHour:
|
||||||
msg = "${msg}e.g. 13: 00";
|
msg = "$msg e.g. 13:00";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -261,6 +261,7 @@ class _TimeTextFieldState extends State<_TimeTextField> {
|
|||||||
child: RoundedInputField(
|
child: RoundedInputField(
|
||||||
height: 40,
|
height: 40,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
|
autoFocus: true,
|
||||||
hintText: state.timeHintText,
|
hintText: state.timeHintText,
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||||
|
@ -141,7 +141,9 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if type_option.include_time {
|
if type_option.include_time {
|
||||||
format!("{}{}", decoded_data.date, decoded_data.time)
|
format!("{} {}", decoded_data.date, decoded_data.time)
|
||||||
|
.trim_end()
|
||||||
|
.to_owned()
|
||||||
} else {
|
} else {
|
||||||
decoded_data.date
|
decoded_data.date
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ impl DateTypeOptionPB {
|
|||||||
let date = format!("{}", utc.format_with_items(StrftimeItems::new(fmt)));
|
let date = format!("{}", utc.format_with_items(StrftimeItems::new(fmt)));
|
||||||
|
|
||||||
let mut time = "".to_string();
|
let mut time = "".to_string();
|
||||||
if has_time {
|
if has_time && self.include_time {
|
||||||
let fmt = format!("{} {}", self.date_format.format_str(), self.time_format.format_str());
|
let fmt = format!("{}{}", self.date_format.format_str(), self.time_format.format_str());
|
||||||
time = format!("{}", utc.format_with_items(StrftimeItems::new(&fmt))).replace(&date, "");
|
time = format!("{}", utc.format_with_items(StrftimeItems::new(&fmt))).replace(&date, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user