-
Notifications
You must be signed in to change notification settings - Fork 371
feat(ui)!: refactor poll message into attachment #2296
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
Changes from 3 commits
0d41776
7a85290
7b4c6f8
f8b9f53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| part of 'attachment_widget_builder.dart'; | ||
|
|
||
| const _kDefaultPollMessageConstraints = BoxConstraints( | ||
| maxWidth: 270, | ||
| ); | ||
|
|
||
| /// {@template pollAttachmentBuilder} | ||
| /// A widget builder for Poll attachment type. | ||
| /// | ||
| /// This builder is used when a message contains a poll. | ||
| /// {@endtemplate} | ||
| class PollAttachmentBuilder extends StreamAttachmentWidgetBuilder { | ||
| /// {@macro urlAttachmentBuilder} | ||
| const PollAttachmentBuilder({ | ||
| this.shape, | ||
| this.padding = const EdgeInsets.all(8), | ||
| this.constraints = _kDefaultPollMessageConstraints, | ||
| }); | ||
|
|
||
| /// The shape of the poll attachment. | ||
| final ShapeBorder? shape; | ||
|
|
||
| /// The constraints to apply to the poll attachment widget. | ||
| final BoxConstraints constraints; | ||
|
|
||
| /// The padding to apply to the poll attachment widget. | ||
| final EdgeInsetsGeometry padding; | ||
|
|
||
| @override | ||
| bool canHandle( | ||
| Message message, | ||
| Map<String, List<Attachment>> attachments, | ||
| ) { | ||
| final poll = message.poll; | ||
| return poll != null; | ||
| } | ||
|
|
||
| @override | ||
|
Check warning on line 38 in packages/stream_chat_flutter/lib/src/attachment/builder/poll_attachment_builder.dart
|
||
| Widget build( | ||
| BuildContext context, | ||
| Message message, | ||
| Map<String, List<Attachment>> attachments, | ||
| ) { | ||
| assert(debugAssertCanHandle(message, attachments), ''); | ||
|
Check warning on line 44 in packages/stream_chat_flutter/lib/src/attachment/builder/poll_attachment_builder.dart
|
||
|
|
||
| return Padding( | ||
| padding: padding, | ||
| child: PollAttachment( | ||
|
Check warning on line 48 in packages/stream_chat_flutter/lib/src/attachment/builder/poll_attachment_builder.dart
|
||
| message: message, | ||
| shape: shape, | ||
| constraints: constraints, | ||
|
Check warning on line 51 in packages/stream_chat_flutter/lib/src/attachment/builder/poll_attachment_builder.dart
|
||
| ), | ||
| ); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.