-
Notifications
You must be signed in to change notification settings - Fork 7
feat(UX-1501): message input #384
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
DE7924
wants to merge
23
commits into
main
Choose a base branch
from
UX-1501
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 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5324dac
feat(UX-1501): add MessageInput component and examples
3535c89
feat(message input) voice input
9a3fdc7
feat(message input): added photo and video attachment support
614a0c7
chore(automated): Lint commit and format
invalid-email-address dbabdaf
Merge branch 'main' into UX-1501
342cfbf
generated
e8d1bba
feat: Refactor message input components and add new attachment functi…
bf6afea
feat: Enhance message input component with accessibility and function…
ff2a63f
clean up
bad08c8
gradle update and generated files
d455dd2
Merge branch 'main' into UX-1501
2376b52
fix tests
28f0f09
Merge branch 'UX-1501' of https://github.com/ZebraDevs/zeta_flutter i…
b55cd05
fix failing action
119b6b5
chore(automated): Lint commit and format
invalid-email-address 7e45512
fix lint error
dd510e3
Merge branch 'UX-1501' of https://github.com/ZebraDevs/zeta_flutter i…
89d5776
chore(automated): Lint commit and format
invalid-email-address e8127f1
fix lint issue
63e2360
address comments
63e6b52
chore(automated): Lint commit and format
invalid-email-address a9f29d8
Merge branch 'main' into UX-1501
thelukewalton 92ba34e
apple stuff
thelukewalton 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
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 |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:zeta_example/widgets.dart'; | ||
| import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
|
||
| class MessageInputExample extends StatefulWidget { | ||
| static const String name = 'MessageInput'; | ||
|
|
||
| const MessageInputExample({super.key}); | ||
|
|
||
| @override | ||
| State<MessageInputExample> createState() => _MessageInputExampleState(); | ||
| } | ||
|
|
||
| class _MessageInputExampleState extends State<MessageInputExample> { | ||
| late TextEditingController controller; | ||
| List<String> messages = []; | ||
| List<File> attachments = []; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| controller = TextEditingController(); | ||
| messages = [for (var i = 0; i < 3; i++) 'Message $i']; | ||
| } | ||
|
|
||
| @override | ||
| void dispose() { | ||
| controller.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return ExampleScaffold( | ||
| name: MessageInputExample.name, | ||
| child: Column( | ||
| children: [ | ||
| Expanded( | ||
| child: ListView.builder( | ||
| itemCount: messages.length, | ||
| itemBuilder: (context, index) { | ||
| return ListTile( | ||
| title: Text(messages[index]), | ||
| ); | ||
| }, | ||
| ), | ||
| ), | ||
| ZetaMessageInput( | ||
| controller: controller, | ||
| disabled: false, | ||
| allowsVoiceInput: true, | ||
| cameraTrailingButton: true, | ||
| hasActionMenu: true, | ||
| onSendLocation: (location) => setState(() => messages.add('Location: $location')), | ||
| onSendVoiceMemo: (file, bytes) => setState(() { | ||
| messages.add('Voice memo: ${file.path}'); | ||
| }), | ||
| attachments: attachments, | ||
| onSendAttachments: (fileList) { | ||
| fileList.forEach((file) { | ||
| setState(() { | ||
| messages.add('File attachment: ${file.path}'); | ||
| }); | ||
| }); | ||
| attachments.clear(); | ||
| }, | ||
| onSend: (message) { | ||
| if (message.isNotEmpty) { | ||
| setState(() { | ||
| messages.add(message); | ||
| }); | ||
| print('Message sent: $message'); | ||
| controller.clear(); | ||
| } | ||
| }, | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| list(APPEND FLUTTER_PLUGIN_LIST | ||
| audioplayers_linux | ||
| file_selector_linux | ||
| record_linux | ||
| ) | ||
|
|
||
|
|
||
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
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
71 changes: 71 additions & 0 deletions
71
packages/zeta_flutter/lib/src/components/message_input/actions/action_button.dart
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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import 'package:flutter/foundation.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../../../../zeta_flutter.dart'; | ||
|
|
||
| /// Action button for the action menu in the message input | ||
| class ActionButton extends ZetaStatelessWidget { | ||
| /// Creates an [ActionButton]. | ||
| const ActionButton({ | ||
| super.key, | ||
| required this.icon, | ||
| this.onPressed, | ||
| this.onLongPress, | ||
| this.color, | ||
| this.disabled, | ||
| this.size, | ||
| this.semanticLabel, | ||
| }); | ||
|
|
||
| /// The icon to display. | ||
| final IconData icon; | ||
|
|
||
| /// The callback invoked when the button is pressed. | ||
| final VoidCallback? onPressed; | ||
|
|
||
| /// The callback invoked when the button is long pressed. | ||
| final VoidCallback? onLongPress; | ||
|
|
||
| /// The color of the icon. Defaults to mainDefault. | ||
| final Color? color; | ||
|
|
||
| /// Whether or not the button is disabled. | ||
| final bool? disabled; | ||
|
|
||
| /// A size override. | ||
| final double? size; | ||
|
|
||
| /// The semantic label on the icon button (used for screen readers). | ||
| final String? semanticLabel; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final ZetaColors colors = Zeta.of(context).colors; | ||
| final ZetaSpacing spacing = Zeta.of(context).spacing; | ||
|
|
||
| return Semantics( | ||
| label: semanticLabel, | ||
| child: IconButton( | ||
| icon: Icon( | ||
| icon, | ||
| color: color ?? (onPressed == null || (disabled ?? false) ? colors.mainDisabled : colors.mainDefault), | ||
| size: size ?? spacing.xl_3, | ||
| ), | ||
| onPressed: (disabled ?? false) ? null : onPressed, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
| super.debugFillProperties(properties); | ||
| properties | ||
| ..add(DiagnosticsProperty<IconData>('icon', icon)) | ||
| ..add(ObjectFlagProperty<VoidCallback>.has('callback', onPressed)) | ||
| ..add(ColorProperty('color', color)) | ||
| ..add(ObjectFlagProperty<VoidCallback?>.has('onLongPressed', onLongPress)) | ||
| ..add(DiagnosticsProperty<bool?>('disabled', disabled)) | ||
| ..add(StringProperty('semanticLabel', semanticLabel)) | ||
| ..add(DoubleProperty('size', size)); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.