Skip to content

Conversation

@yash-agarwa-l
Copy link
Contributor

@yash-agarwa-l yash-agarwa-l commented Dec 26, 2025

Fixes #1215.

Before
Before
After
Before
After - Additional
Before Before Before

compose_date.mp4

@alya
Copy link
Collaborator

alya commented Dec 27, 2025

As usual, please include before/after screenshots demonstrating all your changes, in addition to any videos.

@yash-agarwa-l
Copy link
Contributor Author

yash-agarwa-l commented Dec 27, 2025

Thank you, I’ve added the after screenshots as well.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yash-agarwa-l! Comments below, from a brief review. I'll look more closely at the logic in a later review.

Comment on lines 1712 to 1713


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't add extra lines

_insertTextAtCursor(insert);
}

void _insertTextAtCursor(String insertion) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'd thought that ComposeContentController already had a method for inserting inline content, using ComposeContentController.insertionIndex, but it looks like it doesn't. ComposeContentController.insertPadded is what we use for quote-and-reply (a kind of block content, i.e. not inline content):

  /// Inserts [newText] in [text], setting off with an empty line before and after.
  ///
  /// Assumes [newText] is not empty and consists entirely of complete lines
  /// (each line ends with a newline).
  ///
  /// Inserts at [insertionIndex]. If that's zero, no empty line is added before.
  ///
  /// If there is already an empty line before or after, does not add another.
  void insertPadded(String newText) {

I propose adding a method insertInline, just above insertPadded, and renaming insertPadded to insertBlock so it makes more sense alongside the new method. Here's a draft of a dartdoc plus asserts; would you fill in the implementation?

  /// Inserts [newText] in [text],
  /// setting off with a space character before and after.
  ///
  /// Assumes [newText] does not start or end with whitespace
  /// (i.e. that [String.trim] would not return a different string).
  ///
  /// Inserts at [insertionIndex]. If that's zero, no space is added before.
  ///
  /// If there is already an empty space before or after, does not add another.
  void insertInline(String newText) {
    assert(newText.isNotEmpty);
    assert(newText.trim() == newText);

Then the global-time button would call insertInline.

Comment on lines 1694 to 1703
String formatGlobalTime(DateTime date) {
final iso = date.toIso8601String();
final trimmedIso = iso.contains('.') ? iso.substring(0, iso.indexOf('.')) : iso;
final offset = date.timeZoneOffset;
final sign = offset.isNegative ? '-' : '+';
final hours = offset.inHours.abs().toString().padLeft(2, '0');
final minutes = (offset.inMinutes.abs() % 60).toString().padLeft(2, '0');

return '$trimmedIso$sign$hours:$minutes';
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the kind of logic that belongs in lib/model/compose.dart; see other functions there. Maybe name this one just globalTime, and it can go at the end of the file.

"@composeBoxAttachFromCameraTooltip": {
"description": "Tooltip for compose box icon to attach an image from the camera to the message."
},
"composeBoxAttachGlobalTimeTooltip": "Insert global time",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these entries in the same commit that makes them necessary.

});
});

group('global time button', () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these tests in the same commit that makes them necessary.

Comment on lines +1245 to +1283
/// A button to insert a global time timestamp into the compose box.
///
/// Shows date and time pickers sequentially, then inserts a formatted
/// timestamp in Zulip's global time format: `<time:YYYY-MM-DDTHH:mm:ss±HH:mm>`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these dartdocs in the same commit that makes them necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just for clarity, you would like me to squash everything into the one commit that introduces the implementation logic, correct?

@alya
Copy link
Collaborator

alya commented Jan 3, 2026

Are we controlling the date/time picker styling at all? The "Select date/time" text should perhaps be sized like a heading.

@chrisbobbe chrisbobbe self-assigned this Jan 3, 2026
@chrisbobbe chrisbobbe added the maintainer review PR ready for review by Zulip maintainers label Jan 3, 2026
yash-agarwa-l added a commit to yash-agarwa-l/zulip-flutter that referenced this pull request Jan 3, 2026
Renames `insertPadded` to `insertBlock` for block content (line-padded),
makingthe distinction between the two insertion types explicit.

Fixes the issue described here:
zulip#2056 (comment)
@yash-agarwa-l
Copy link
Contributor Author

Thanks for the review. I’ve addressed the feedback and squashed the commits as requested.

@yash-agarwa-l
Copy link
Contributor Author

@alya Ack. It's using the default styling right now, but I can bump the size up to a heading. Is there a specific style you want there?

Fixes zulip#1215.

This adds a clock button to the compose box that opens date and time
pickers sequentially. When completed, it inserts a timestamp in Zulip's
global time format (e.g., <time:2025-12-31T13:30:00+05:30>). This allows
users to easily reference specific times that display correctly across
all timezones.
yash-agarwa-l added a commit to yash-agarwa-l/zulip-flutter that referenced this pull request Jan 6, 2026
Renames `insertPadded` to `insertBlock` for block content (line-padded),
makingthe distinction between the two insertion types explicit.

Fixes the issue described here:
zulip#2056 (comment)
Renames `insertPadded` to `insertBlock` for block content (line-padded),
makingthe distinction between the two insertion types explicit.

Fixes the issue described here:
zulip#2056 (comment)
@alya
Copy link
Collaborator

alya commented Jan 8, 2026

I dunno, you can try our modal heading size and update the screenshots for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer review PR ready for review by Zulip maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compose: Insert a <time> element ("global times")

3 participants