Skip to content

Commit

Permalink
fix: time field placeholder based on user time format
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsahMohammad committed Mar 2, 2024
1 parent 6017df5 commit e756d72
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/date_entities.pbenum.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:flowy_infra_ui/style_widget/text_field.dart';
import 'package:intl/intl.dart';

const _maxLengthTwelveHour = 8;
const _maxLengthTwentyFourHour = 5;
Expand Down Expand Up @@ -55,6 +56,13 @@ class _TimeTextFieldState extends State<TimeTextField> {
text = widget.endTimeStr!;
}

if (widget.timeFormat == TimeFormatPB.TwelveHour) {
final twentyFourHourFormat = DateFormat('HH:mm');
final twelveHourFormat = DateFormat('hh:mm a');
final date = twentyFourHourFormat.parse(text);
text = twelveHourFormat.format(date);
}

_focusNode.addListener(_focusNodeListener);
widget.popoverMutex?.listenOnPopoverChanged(_popoverListener);
}
Expand Down

0 comments on commit e756d72

Please sign in to comment.