feat: Implement emojipicker for reactions

This commit is contained in:
Christian Pauly 2020-12-12 17:19:53 +01:00
parent 19c04403a2
commit 20b3157473
3 changed files with 104 additions and 21 deletions

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:emoji_picker/emoji_picker.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart'; import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/components/adaptive_page_layout.dart'; import 'package:fluffychat/components/adaptive_page_layout.dart';
@ -459,6 +460,34 @@ class _ChatState extends State<_Chat> {
return filteredEvents; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
matrix = Matrix.of(context); matrix = Matrix.of(context);
@ -830,28 +859,32 @@ class _ChatState extends State<_Chat> {
}); });
return ListView.builder( return ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: emojis.length, itemCount: emojis.length + 1,
itemBuilder: (c, i) => InkWell( itemBuilder: (c, i) => i == emojis.length
borderRadius: BorderRadius.circular(8), ? InkWell(
onTap: () { borderRadius: BorderRadius.circular(8),
SimpleDialogs(context).tryRequestWithLoadingDialog( child: Container(
room.sendReaction( width: 56,
selectedEvents.first.eventId, height: 56,
emojis[i], 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),
),
),
),
); );
}), }),
), ),

View File

@ -183,6 +183,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.3" 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: encrypt:
dependency: transitive dependency: transitive
description: description:
@ -872,6 +879,48 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.5+4" 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: shelf:
dependency: transitive dependency: transitive
description: description:

View File

@ -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_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 flutter_cache_manager: ^2.0.0
open_noti_settings: ^0.0.4 open_noti_settings: ^0.0.4
emoji_picker: ^0.1.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: