-
Notifications
You must be signed in to change notification settings - Fork 314
Show message content, sender, and timestamp in message action sheet #1624
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
Open
chrisbobbe
wants to merge
8
commits into
zulip:main
Choose a base branch
from
chrisbobbe:pr-message-content-in-action-sheet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bbc2ca1
action_sheet test: Narrow a Finder (long-press for message action sheet)
chrisbobbe bc31057
content [nfc]: Move parseMessageContent here, from msglist; make public
chrisbobbe 473a119
msglist [nfc]: Make SenderRow public
chrisbobbe fc565de
action_sheet [nfc]: Pull out a `designVariables` local
chrisbobbe 2c3bf7a
action_sheet [nfc]: Refactor some vertical padding, toward header param
chrisbobbe 9c924eb
action_sheet [nfc]: In _showActionSheet, s/context/pageContext/
chrisbobbe 27d124d
action_sheet: In _showActionSheet, wrap content in PerAccountStoreWidget
chrisbobbe 6a2649a
action_sheet: Add `header` param; use it to show message content
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,14 @@ import '../api/route/channels.dart'; | |
import '../api/route/messages.dart'; | ||
import '../generated/l10n/zulip_localizations.dart'; | ||
import '../model/binding.dart'; | ||
import '../model/content.dart'; | ||
import '../model/emoji.dart'; | ||
import '../model/internal_link.dart'; | ||
import '../model/narrow.dart'; | ||
import 'actions.dart'; | ||
import 'color.dart'; | ||
import 'compose_box.dart'; | ||
import 'content.dart'; | ||
import 'dialog.dart'; | ||
import 'emoji.dart'; | ||
import 'emoji_reaction.dart'; | ||
|
@@ -32,39 +34,71 @@ import 'theme.dart'; | |
import 'topic_list.dart'; | ||
|
||
void _showActionSheet( | ||
BuildContext context, { | ||
BuildContext pageContext, { | ||
required List<Widget> optionButtons, | ||
Widget? header, | ||
Color? headerBackgroundColor, | ||
}) { | ||
// Could omit this if we need _showActionSheet outside a per-account context. | ||
final store = PerAccountStoreWidget.of(pageContext); | ||
|
||
showModalBottomSheet<void>( | ||
context: context, | ||
context: pageContext, | ||
// Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect | ||
// on my iPhone 13 Pro but is marked as "much slower": | ||
// https://api.flutter.dev/flutter/dart-ui/Clip.html | ||
clipBehavior: Clip.antiAlias, | ||
useSafeArea: true, | ||
isScrollControlled: true, | ||
builder: (BuildContext _) { | ||
return Semantics( | ||
role: SemanticsRole.menu, | ||
child: SafeArea( | ||
minimum: const EdgeInsets.only(bottom: 16), | ||
child: Padding( | ||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0), | ||
final designVariables = DesignVariables.of(pageContext); | ||
return PerAccountStoreWidget( | ||
accountId: store.accountId, | ||
child: Semantics( | ||
role: SemanticsRole.menu, | ||
child: SafeArea( | ||
minimum: const EdgeInsets.only(bottom: 16), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
// TODO(#217): show message text | ||
Flexible(child: InsetShadowBox( | ||
top: 8, bottom: 8, | ||
color: DesignVariables.of(context).bgContextMenu, | ||
child: SingleChildScrollView( | ||
padding: const EdgeInsets.only(top: 16, bottom: 8), | ||
child: ClipRRect( | ||
borderRadius: BorderRadius.circular(7), | ||
child: Column(spacing: 1, | ||
children: optionButtons))))), | ||
const ActionSheetCancelButton(), | ||
if (header != null) | ||
Flexible( | ||
// TODO(upstream) Enforce a flex ratio (e.g. 1:3) | ||
// only when the header height plus the buttons' height | ||
// exceeds available space. Otherwise let one or the other | ||
// grow to fill available space even if it breaks the ratio. | ||
// Needs support for separate properties like `flex-grow` | ||
// and `flex-shrink`. | ||
flex: 1, | ||
child: InsetShadowBox( | ||
top: 8, bottom: 8, | ||
color: designVariables.bgContextMenu, | ||
child: SingleChildScrollView( | ||
padding: EdgeInsets.symmetric(vertical: 8), | ||
child: ColoredBox( | ||
color: headerBackgroundColor ?? Colors.transparent, | ||
child: header)))) | ||
else | ||
SizedBox(height: 8), | ||
Flexible( | ||
flex: 3, | ||
child: Padding( | ||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Flexible(child: InsetShadowBox( | ||
top: 8, bottom: 8, | ||
color: designVariables.bgContextMenu, | ||
child: SingleChildScrollView( | ||
padding: const EdgeInsets.symmetric(vertical: 8), | ||
child: ClipRRect( | ||
borderRadius: BorderRadius.circular(7), | ||
child: Column(spacing: 1, | ||
children: optionButtons))))), | ||
const ActionSheetCancelButton(), | ||
]))), | ||
])))); | ||
}); | ||
} | ||
|
@@ -604,7 +638,42 @@ void showMessageActionSheet({required BuildContext context, required Message mes | |
EditButton(message: message, pageContext: pageContext), | ||
]; | ||
|
||
_showActionSheet(pageContext, optionButtons: optionButtons); | ||
_showActionSheet(pageContext, | ||
optionButtons: optionButtons, | ||
header: _MessageActionSheetHeader(message: message)); | ||
} | ||
|
||
class _MessageActionSheetHeader extends StatelessWidget { | ||
const _MessageActionSheetHeader({required this.message}); | ||
|
||
final Message message; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final designVariables = DesignVariables.of(context); | ||
|
||
// TODO this seems to lose the hero animation when opening an image; | ||
// investigate. | ||
// TODO should we close the sheet before opening a narrow link? | ||
// On popping the pushed narrow route, the sheet is still open. | ||
|
||
return Container( | ||
// TODO(#647) use different color for highlighted messages | ||
// TODO(#681) use different color for DM messages | ||
color: designVariables.bgMessageRegular, | ||
padding: EdgeInsets.symmetric(vertical: 4), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
spacing: 4, | ||
children: [ | ||
SenderRow(message: message, showTimestamp: true), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 16), | ||
// TODO(#10) offer text selection; the Figma asks for it here: | ||
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3483-30210&m=dev | ||
child: MessageContent(message: message, content: parseMessageContent(message))), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couple of things I noticed with interactions in the message content:
Neither seem blocker for this feature though. |
||
])); | ||
} | ||
} | ||
|
||
abstract class MessageActionSheetMenuItemButton extends ActionSheetMenuItemButton { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The figma design says:
But currently it doesn't, so maybe let's have a TODO for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; there's a note on #1077 that's relevant: