refactor(ui): remove context and add size property to EmojiOverlay

This commit is contained in:
Salvatore Giordano
2021-09-09 17:01:36 +02:00
parent 2f65a0d480
commit 19472027cc
4 changed files with 13 additions and 13 deletions
@@ -38,7 +38,9 @@ class AuthInterceptor extends Interceptor {
'Authorization': token.rawValue,
'stream-auth-type': token.authType.raw,
};
options..queryParameters.addAll(params)..headers.addAll(headers);
options
..queryParameters.addAll(params)
..headers.addAll(headers);
return handler.next(options);
}
@@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
@@ -7,15 +7,15 @@ import 'package:substring_highlight/substring_highlight.dart';
/// Overlay for displaying emoji that can be used
class EmojiOverlay extends StatelessWidget {
/// Constructor for creating a [EmojiOverlay]
const EmojiOverlay(
this.context, {
const EmojiOverlay({
required this.query,
required this.onEmojiResult,
required this.size,
Key? key,
}) : super(key: key);
/// Context of the upper tree
final BuildContext context;
/// The size of the overlay
final Size size;
/// Query for searching emoji
final String query;
@@ -24,7 +24,7 @@ class EmojiOverlay extends StatelessWidget {
final ValueChanged<Emoji> onEmojiResult;
@override
Widget build(BuildContext otherContext) {
Widget build(BuildContext context) {
final _streamChatTheme = StreamChatTheme.of(context);
final _emojiNames =
Emoji.all().where((it) => it.name != null).map((e) => e.name!);
@@ -38,10 +38,6 @@ class EmojiOverlay extends StatelessWidget {
return const SizedBox();
}
// ignore: cast_nullable_to_non_nullable
final renderBox = context.findRenderObject() as RenderBox;
final size = renderBox.size;
return Card(
margin: const EdgeInsets.all(8),
elevation: 2,
@@ -51,7 +47,7 @@ class EmojiOverlay extends StatelessWidget {
),
clipBehavior: Clip.hardEdge,
child: Container(
constraints: BoxConstraints.loose(Size(size.width - 16, 200)),
constraints: BoxConstraints.loose(size),
decoration: BoxDecoration(
boxShadow: const [
BoxShadow(
@@ -1170,9 +1170,11 @@ class MessageInputState extends State<MessageInput> {
.split(':');
final query = splits.last.toLowerCase();
// ignore: cast_nullable_to_non_nullable
final renderObject = context.findRenderObject() as RenderBox;
return EmojiOverlay(
context,
size: Size(renderObject.size.width - 16, 200),
query: query,
onEmojiResult: (emoji) {
_chooseEmoji(splits, emoji);