Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message List from Same User is now Distinguishable via Surface Tint on Long Press #1152

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Gaurav-Kushwaha-1225
Copy link

Changes Made

This issue resolved by:

  • Wrapping the MessageWithPossibleSender with a Container
  • Then, giving it a color property on a condition that when isMessageActionSheetOpen is true show the surface tint, else remain Colors.transparent.

For this,

  • I shifted the MessageWithPossibleSender from StatelessWidget to StatefulWidget.
  • Added a nullable VoidCallback? onDismiss method in parameters of showMessageActionSheet or BottomSheet for updating the Surface Tint of message.

Fixes #1142

Screenshots

Light Theme Dark Theme
video_2024-12-13_13-16-02.mp4
video_2024-12-13_13-16-08.mp4

@alya
Copy link
Collaborator

alya commented Dec 13, 2024

Please post screenshots of your changes in the PR description, as videos are hard to review.

@Gaurav-Kushwaha-1225
Copy link
Author

Please post screenshots of your changes in the PR description, as videos are hard to review.

Changes

1st

  • shifting the MessageWithPossibleSender widget from StatelessWidget to StatefulWidget.
  • adding isMessageActionSheetOpen and pressedTint as parameters of MessageWithPossibleSender for making surface value tint to transparent after bottom sheet is closed.
  • Screenshot:

2nd

  • Wrapped with Container with color property on isMessageActionSheetOpen condition.
  • Updating the function of onLongPress of MessageWithPossibleSender widget. That, when isMessageActionSheetOpen is true show the surface tint.
  • Screenshot:

3rd

  • Just adding a nullable VoidCallback? onDismiss method in parameters of showMessageActionSheet and _showActionSheet for getting response of closing of bottom sheet.
  • Screenshots:

@chrisbobbe
Copy link
Collaborator

Alya means before/after screenshots of the app's UI. We can read your code easily without screenshots :)

@chrisbobbe
Copy link
Collaborator

Also I see there's a failing check; please run tests locally (tools/check) and fix any failures.

@Gaurav-Kushwaha-1225
Copy link
Author

Alya means before/after screenshots of the app's UI. We can read your code easily without screenshots :)

I am sorry for the confusion.
Here, are the screenshots:

Before After

Also I see there's a failing check; please run tests locally (tools/check) and fix any failures.

I have updated the changes and there are no failing checks and conflicts now.
Thank you.

@alya
Copy link
Collaborator

alya commented Dec 16, 2024

Are those before/after scheenshots the same? The point is to show the differences from your PR's changes.

@Gaurav-Kushwaha-1225
Copy link
Author

Gaurav-Kushwaha-1225 commented Dec 17, 2024

Are those before/after scheenshots the same? The point is to show the differences from your PR's changes.

@alya,
In the screenshots, the message on which the user has long pressed, that message has appeared a surface tint color separating from rest other messages, in both light and dark theme.
This was the issue to resolve i.e. to give a surface tint to those messages where long press event has occurred.

@alya
Copy link
Collaborator

alya commented Dec 17, 2024

Oh, I see it now.

Is it happening in the dark theme screenshot? I don't see a difference, so if the effect is there, it's too subtle.

@alya
Copy link
Collaborator

alya commented Dec 17, 2024

It's also best to take screenshots that are identical other than the change your PR makes, to make them easy to compare.

@Gaurav-Kushwaha-1225
Copy link
Author

Oh, I see it now.

Is it happening in the dark theme screenshot? I don't see a difference, so if the effect is there, it's too subtle.

@alya
Yeah, actually I took the same tint color for both themes. I saw in the figma file both are different for different themes.
I will update the PR in few minutes.
Sorry, for my inconvenience.

@alya
Copy link
Collaborator

alya commented Dec 17, 2024

Sure, please be mindful to review your own work carefully next time. Posting screenshots is one of the things that should help you identify any problems yourself, before asking someone else to take a look.

@Gaurav-Kushwaha-1225
Copy link
Author

Gaurav-Kushwaha-1225 commented Dec 17, 2024

@alya

Here, is the updated PR.

Requirements according to Figma File

Before and After Screenshots

NOTE: In after screenshots, you may see the colors appearing to be a bit different (or less light/dark) from actual figma. This is because the action sheet is opened in my after screenshots which are not in figma file.

Before After

Both pressedTint colors in light and dark theme are according to the Figma File i.e. RGBA(0, 0, 0, 0.04) for light theme and RGBA(1, 1, 1, 0.04) for dark theme.

@PIG208
Copy link
Member

PIG208 commented Dec 17, 2024

Hi @Gaurav-Kushwaha-1225! Thanks for the updates. For the PR to be reviewable, we need tests for this: https://github.com/zulip/zulip-flutter?tab=readme-ov-file#submitting-a-pull-request

Please also pay attention to the point on commit style guide from that link, and organize the commit history coherently.

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Dec 23, 2024
@chrisbobbe
Copy link
Collaborator

I see you're adding merge commits; Zulip doesn't use those.

@Gaurav-Kushwaha-1225
Copy link
Author

Hi @Gaurav-Kushwaha-1225! Thanks for the updates. For the PR to be reviewable, we need tests for this: https://github.com/zulip/zulip-flutter?tab=readme-ov-file#submitting-a-pull-request

Please also pay attention to the point on commit style guide from that link, and organize the commit history coherently.

Hi @PIG208, I have added the necessary tests for these changes in test/widgets/message_list_test.dart file.
Please review the changes and feature added.
Thank you.

@PIG208
Copy link
Member

PIG208 commented Jan 8, 2025

Looks like this update still hasn't addressed my previous comment on the commit style:

Please also pay attention to the point on commit style guide from that link, and organize the commit history coherently.

As Chris said, we don't use merge commits. Could you please also review the commit style guide linked in our README?

@Gaurav-Kushwaha-1225 Gaurav-Kushwaha-1225 force-pushed the MsgListIssue branch 3 times, most recently from 1b7e27d to 4d26607 Compare January 13, 2025 15:46
@Gaurav-Kushwaha-1225
Copy link
Author

Looks like this update still hasn't addressed my previous comment on the commit style:

Please also pay attention to the point on commit style guide from that link, and organize the commit history coherently.

As Chris said, we don't use merge commits. Could you please also review the commit style guide linked in our README?

I’ve updated the commits, improving the commit style and making other enhancements.
I believe it’s ready for review now.

Please let me know if any further changes are required.

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! Comments below. Please also squash these two commits into one, so the tests land in the same commit as the code they're testing.

@@ -332,6 +335,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
final Color subscriptionListHeaderLine;
final Color subscriptionListHeaderText;
final Color unreadCountBadgeTextForChannel;
final Color pressedTint;
Copy link
Collaborator

@chrisbobbe chrisbobbe Jan 16, 2025

Choose a reason for hiding this comment

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

Since this comes from a variable in the Figma, please move it so it's with the other Figma variables: background, bannerBgIntDanger, etc., and put it there alphabetically, so (in current main) between mainBackground and textInput.

(And reorder its other appearances accordingly)

Choose a reason for hiding this comment

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

It is named as pressedTint itself in the design file.
And, regarding the reordering, that I will reorder and update soon.

onLongPress: () => showMessageActionSheet(context: context, message: message),
onLongPress: () async {
setState(() {
isMessageActionSheetOpen = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If isMessageActionSheetOpen is supposed to mean what its name says, it isn't accurate here. The action sheet won't be open until 100ms have passed.

I'd like to try a different approach, using an existing Flutter API that seems suitable.

  • _MessageWithPossibleSenderState gets a new final field:

      final WidgetStatesController statesController = WidgetStatesController();
  • Override _MessageWithPossibleSenderState.initState like so:

      @override
      void initState() {
        super.initState();
        statesController.addListener(() {
          setState(() {
            // Force a rebuild to resolve background color
          });
        });
      }
  • Override _MessageWithPossibleSenderState.dispose, calling statesController.dispose()

  • In addition to the existing onLongPress, pass onLongPressDown, onLongPressCancel, and onLongPressUp to the GestureDetector. Each passed callback should call statesController.update(WidgetState.pressed, … with true or false as appropriate.

  • At the top of the existing onLongPress calback, call statesController.update(WidgetState.selected, true). When the action sheet is dismissed, unset that with false.

  • For the background color, use:

                color: const WidgetStateColor.fromMap({
                  WidgetState.pressed: designVariables.pressedTint,
                  WidgetState.selected: designVariables.pressedTint,
                  WidgetState.any: Colors.transparent,
                }).resolve(statesController.value)

isMessageActionSheetOpen = true;
});

await Future.delayed(const Duration(milliseconds: 100), () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want an additional 100ms delay here; let's remove it.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

In addition to Chris's comments above, one other high-level comment. (I've only done an initial skim of this PR, since it's still in maintainer review.)

@@ -61,7 +62,7 @@ void _showActionSheet(
children: optionButtons))))),
const ActionSheetCancelButton(),
])));
});
}).whenComplete(onDismiss ?? () {});
Copy link
Member

Choose a reason for hiding this comment

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

This type of API based on callbacks can make the control flow pretty confusing to follow. The behavior here can be more cleanly modeled using Future.

Let's also avoid using explicit Future methods like whenComplete, in favor of async and await.

Concretely, let's have this function _showActionSheet, and its caller showMessageActionSheet, mimic the API we developed for showErrorDialog:

/// Displays an [AlertDialog] with a dismiss button.
///
/// The [DialogStatus.closed] field of the return value can be used
/// for waiting for the dialog to be closed.
// This API is inspired by [ScaffoldManager.showSnackBar].  We wrap
// [showDialog]'s return value, a [Future], inside [DialogStatus]
// whose documentation can be accessed.  This helps avoid confusion when
// intepreting the meaning of the [Future].
DialogStatus showErrorDialog({

We can use the same DialogStatus type for the return value. I'll update your PR branch with a quick prep commit that gives it a slightly more general name ModalStatus, and slightly more general docs, so that it's ready to be used that way.

@gnprice
Copy link
Member

gnprice commented Jan 17, 2025

I'll update your PR branch with a quick prep commit

Done. @Gaurav-Kushwaha-1225 As the first step when you start work on your next revision, be sure to pull down the updated version of this branch — use git fetch me or git fetch origin, whatever name you use for the remote pointing at your GitHub fork of this repo. (If you're unsure how to do this, the #git help channel is a good place for questions.)

gnprice and others added 2 commits January 18, 2025 02:49
We'll soon use this for modal bottom sheets too, aka action sheets.

Arguably that could mean it belongs in some other file, not specific
to dialogs nor bottom sheets.  But there isn't an obvious other file
for it, and I think this is as good a home as any.
It allows to see a tint color on the message
when it is pressed.

Moved `MessageWithPossibleSender` to `StatefulWidget`
and used `ModalStatus` return type of
`showMessageActionSheet` to check whether BottomSheet
is open or not.

Added `pressedTint` to `DesignVariables` for using
it in `MessageWithPossibleSender`.

Added tests too in `message_list_test.dart`.

Fixes: zulip#1142
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.

msglist: Message bounds hard to see in a run of messages from the same user
5 participants