mirror of
				https://gitlab.com/famedly/fluffychat.git
				synced 2025-10-31 03:57:27 +01:00 
			
		
		
		
	feat: Implement emojipicker for reactions
This commit is contained in:
		
							parent
							
								
									19c04403a2
								
							
						
					
					
						commit
						20b3157473
					
				| @ -3,6 +3,7 @@ import 'dart:io'; | ||||
| import 'dart:math'; | ||||
| 
 | ||||
| import 'package:adaptive_dialog/adaptive_dialog.dart'; | ||||
| import 'package:emoji_picker/emoji_picker.dart'; | ||||
| import 'package:famedlysdk/famedlysdk.dart'; | ||||
| import 'package:file_picker_cross/file_picker_cross.dart'; | ||||
| import 'package:fluffychat/components/adaptive_page_layout.dart'; | ||||
| @ -459,6 +460,34 @@ class _ChatState extends State<_Chat> { | ||||
|     return filteredEvents; | ||||
|   } | ||||
| 
 | ||||
|   void _pickEmojiAction(BuildContext context) async { | ||||
|     final emoji = await showModalBottomSheet( | ||||
|       context: context, | ||||
|       backgroundColor: Colors.transparent, | ||||
|       builder: (context) => Column( | ||||
|         children: [ | ||||
|           Spacer(), | ||||
|           EmojiPicker( | ||||
|             onEmojiSelected: (emoji, category) => | ||||
|                 Navigator.of(context).pop<Emoji>(emoji), | ||||
|           ), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|     if (emoji == null) return; | ||||
|     return _sendEmojiAction(context, emoji.emoji); | ||||
|   } | ||||
| 
 | ||||
|   void _sendEmojiAction(BuildContext context, String emoji) { | ||||
|     SimpleDialogs(context).tryRequestWithLoadingDialog( | ||||
|       room.sendReaction( | ||||
|         selectedEvents.first.eventId, | ||||
|         emoji, | ||||
|       ), | ||||
|     ); | ||||
|     setState(() => selectedEvents.clear()); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     matrix = Matrix.of(context); | ||||
| @ -830,28 +859,32 @@ class _ChatState extends State<_Chat> { | ||||
|                       }); | ||||
|                       return ListView.builder( | ||||
|                         scrollDirection: Axis.horizontal, | ||||
|                         itemCount: emojis.length, | ||||
|                         itemBuilder: (c, i) => InkWell( | ||||
|                           borderRadius: BorderRadius.circular(8), | ||||
|                           onTap: () { | ||||
|                             SimpleDialogs(context).tryRequestWithLoadingDialog( | ||||
|                               room.sendReaction( | ||||
|                                 selectedEvents.first.eventId, | ||||
|                                 emojis[i], | ||||
|                         itemCount: emojis.length + 1, | ||||
|                         itemBuilder: (c, i) => i == emojis.length | ||||
|                             ? InkWell( | ||||
|                                 borderRadius: BorderRadius.circular(8), | ||||
|                                 child: Container( | ||||
|                                   width: 56, | ||||
|                                   height: 56, | ||||
|                                   alignment: Alignment.center, | ||||
|                                   child: Icon(Icons.add_outlined), | ||||
|                                 ), | ||||
|                                 onTap: () => _pickEmojiAction(context), | ||||
|                               ) | ||||
|                             : InkWell( | ||||
|                                 borderRadius: BorderRadius.circular(8), | ||||
|                                 onTap: () => | ||||
|                                     _sendEmojiAction(context, emojis[i]), | ||||
|                                 child: Container( | ||||
|                                   width: 56, | ||||
|                                   height: 56, | ||||
|                                   alignment: Alignment.center, | ||||
|                                   child: Text( | ||||
|                                     emojis[i], | ||||
|                                     style: TextStyle(fontSize: 30), | ||||
|                                   ), | ||||
|                                 ), | ||||
|                               ), | ||||
|                             ); | ||||
|                             setState(() => selectedEvents.clear()); | ||||
|                           }, | ||||
|                           child: Container( | ||||
|                             width: 56, | ||||
|                             height: 56, | ||||
|                             alignment: Alignment.center, | ||||
|                             child: Text( | ||||
|                               emojis[i], | ||||
|                               style: TextStyle(fontSize: 30), | ||||
|                             ), | ||||
|                           ), | ||||
|                         ), | ||||
|                       ); | ||||
|                     }), | ||||
|                   ), | ||||
|  | ||||
							
								
								
									
										49
									
								
								pubspec.lock
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								pubspec.lock
									
									
									
									
									
								
							| @ -183,6 +183,13 @@ packages: | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.0.3" | ||||
|   emoji_picker: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: emoji_picker | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.1.0" | ||||
|   encrypt: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @ -872,6 +879,48 @@ packages: | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.6.5+4" | ||||
|   shared_preferences: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.5.12+4" | ||||
|   shared_preferences_linux: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences_linux | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.0.2+4" | ||||
|   shared_preferences_macos: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences_macos | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.0.1+11" | ||||
|   shared_preferences_platform_interface: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences_platform_interface | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "1.0.4" | ||||
|   shared_preferences_web: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences_web | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.1.2+7" | ||||
|   shared_preferences_windows: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: shared_preferences_windows | ||||
|       url: "https://pub.dartlang.org" | ||||
|     source: hosted | ||||
|     version: "0.0.1+3" | ||||
|   shelf: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|  | ||||
| @ -64,6 +64,7 @@ dependencies: | ||||
|   flutter_svg: 0.19.1 # Because fluffychat depends on flutter_svg >=0.19.2 which requires Flutter SDK version >=1.24.0-6.0.pre <2.0.0, version solving failed. | ||||
|   flutter_cache_manager: ^2.0.0 | ||||
|   open_noti_settings: ^0.0.4 | ||||
|   emoji_picker: ^0.1.0 | ||||
| 
 | ||||
| dev_dependencies: | ||||
|   flutter_test: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Christian Pauly
						Christian Pauly