fix: add time to view meta info (#4769)

This commit is contained in:
Mathias Mogensen 2024-02-28 12:34:02 +01:00 committed by GitHub
parent abd08e5e53
commit 0cffe42d80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -8,7 +8,6 @@ import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widget
import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/font_size_action.dart'; import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/font_size_action.dart';
import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/view_meta_info.dart'; import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/view_meta_info.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/date_time.pbenum.dart';
import 'package:appflowy_popover/appflowy_popover.dart'; import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart';
@ -35,13 +34,11 @@ class MoreViewActions extends StatefulWidget {
class _MoreViewActionsState extends State<MoreViewActions> { class _MoreViewActionsState extends State<MoreViewActions> {
late final List<Widget> viewActions; late final List<Widget> viewActions;
late final UserDateFormatPB dateFormat;
final popoverMutex = PopoverMutex(); final popoverMutex = PopoverMutex();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
dateFormat = context.read<AppearanceSettingsCubit>().state.dateFormat;
viewActions = ViewActionType.values viewActions = ViewActionType.values
.map( .map(
(type) => ViewAction( (type) => ViewAction(
@ -61,11 +58,15 @@ class _MoreViewActionsState extends State<MoreViewActions> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appearanceSettings = context.watch<AppearanceSettingsCubit>().state;
final dateFormat = appearanceSettings.dateFormat;
final timeFormat = appearanceSettings.timeFormat;
return BlocBuilder<ViewInfoBloc, ViewInfoState>( return BlocBuilder<ViewInfoBloc, ViewInfoState>(
builder: (context, state) { builder: (context, state) {
return AppFlowyPopover( return AppFlowyPopover(
mutex: popoverMutex, mutex: popoverMutex,
constraints: BoxConstraints.loose(const Size(200, 400)), constraints: BoxConstraints.loose(const Size(210, 400)),
offset: const Offset(0, 30), offset: const Offset(0, 30),
popupBuilder: (_) { popupBuilder: (_) {
final actions = [ final actions = [
@ -79,6 +80,7 @@ class _MoreViewActionsState extends State<MoreViewActions> {
const Divider(height: 4), const Divider(height: 4),
ViewMetaInfo( ViewMetaInfo(
dateFormat: dateFormat, dateFormat: dateFormat,
timeFormat: timeFormat,
documentCounters: state.documentCounters, documentCounters: state.documentCounters,
createdAt: state.createdAt, createdAt: state.createdAt,
), ),

View File

@ -12,11 +12,13 @@ class ViewMetaInfo extends StatelessWidget {
const ViewMetaInfo({ const ViewMetaInfo({
super.key, super.key,
required this.dateFormat, required this.dateFormat,
required this.timeFormat,
this.documentCounters, this.documentCounters,
this.createdAt, this.createdAt,
}); });
final UserDateFormatPB dateFormat; final UserDateFormatPB dateFormat;
final UserTimeFormatPB timeFormat;
final Counters? documentCounters; final Counters? documentCounters;
final DateTime? createdAt; final DateTime? createdAt;
@ -47,8 +49,9 @@ class ViewMetaInfo extends StatelessWidget {
if (documentCounters != null) const VSpace(2), if (documentCounters != null) const VSpace(2),
FlowyText.regular( FlowyText.regular(
LocaleKeys.moreAction_createdAt.tr( LocaleKeys.moreAction_createdAt.tr(
args: [dateFormat.formatDate(createdAt!, false)], args: [dateFormat.formatDate(createdAt!, true, timeFormat)],
), ),
maxLines: 2,
color: Theme.of(context).hintColor, color: Theme.of(context).hintColor,
), ),
], ],