From 9a1cb38e2a1a215a321d70fd2aa4fdf2329c7c6f Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 22 Sep 2021 09:24:36 +0200 Subject: [PATCH] refactor(ui): rename portal to overlays --- .../lib/src/message_input.dart | 20 +++++----- .../stream_chat_flutter/lib/src/overlays.dart | 40 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 1c8f8f37..9cd84aa2 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -192,15 +192,15 @@ class MessageInput extends StatefulWidget { this.onAttachmentLimitExceed, this.attachmentButtonBuilder, this.commandButtonBuilder, - this.customPortalOptions = const [], + this.customOverlays = const [], }) : assert( initialMessage == null || editMessage == null, "Can't provide both `initialMessage` and `editMessage`", ), super(key: key); - /// List of portal options for showing overlays - final List customPortalOptions; + /// List of options for showing overlays + final List customOverlays; /// Message to edit final Message? editMessage; @@ -466,15 +466,15 @@ class MessageInputState extends State { ); } - return MultiPortal( + return MultiOverlay( childAnchor: Alignment.topCenter, - portalAnchor: Alignment.bottomCenter, - portalOptions: [ - PortalOptions( + overlayAnchor: Alignment.bottomCenter, + overlayOptions: [ + OverlayOptions( visible: _showCommandsOverlay, widget: _buildCommandsOverlayEntry(), ), - PortalOptions( + OverlayOptions( visible: _focusNode.hasFocus && textEditingController.text.isNotEmpty && textEditingController.selection.baseOffset > 0 && @@ -486,11 +486,11 @@ class MessageInputState extends State { .contains(':'), widget: _buildEmojiOverlay(), ), - PortalOptions( + OverlayOptions( visible: _showMentionsOverlay, widget: _buildMentionsOverlayEntry(), ), - ...widget.customPortalOptions, + ...widget.customOverlays, ], child: child, ); diff --git a/packages/stream_chat_flutter/lib/src/overlays.dart b/packages/stream_chat_flutter/lib/src/overlays.dart index 59328429..8d36be50 100644 --- a/packages/stream_chat_flutter/lib/src/overlays.dart +++ b/packages/stream_chat_flutter/lib/src/overlays.dart @@ -2,47 +2,47 @@ import 'package:collection/collection.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_portal/flutter_portal.dart'; -/// Class that contains the parameters for building a portal entry -class PortalOptions { - /// Constructs a new portal options object - /// [visible] - the visibility of the portal +/// Class that contains the parameters for building an overlay entry +class OverlayOptions { + /// Constructs a new overlay options object + /// [visible] - the visibility of the overlay /// [widget] - the widget to be displayed - PortalOptions({ + OverlayOptions({ required this.visible, required this.widget, }); - /// the visibility of the portal + /// the visibility of the overlay final bool visible; /// the widget to be displayed final Widget widget; } -/// Widget that renders a single portal widget from a list of [portalOptions] +/// Widget that renders a single overlay widget from a list of [overlayOptions] /// It shows the first one that is visible -class MultiPortal extends StatelessWidget { - /// Constructs a new MultiPortal widget - /// [portalOptions] - the list of portal options - /// [portalAnchor] - the anchor relative to the portal +class MultiOverlay extends StatelessWidget { + /// Constructs a new MultiOverlay widget + /// [overlayOptions] - the list of overlay options + /// [overlayAnchor] - the anchor relative to the overlay /// [childAnchor] - the anchor relative to the child /// [child] - the child widget - const MultiPortal({ + const MultiOverlay({ Key? key, - required this.portalOptions, + required this.overlayOptions, required this.child, - required this.portalAnchor, + required this.overlayAnchor, required this.childAnchor, }) : super(key: key); - /// The list of portal options - final List portalOptions; + /// The list of overlay options + final List overlayOptions; /// The child widget final Widget child; - /// The anchor relative to the portal - final Alignment? portalAnchor; + /// The anchor relative to the overlay + final Alignment? overlayAnchor; /// The anchor relative to the child final Alignment? childAnchor; @@ -50,11 +50,11 @@ class MultiPortal extends StatelessWidget { @override Widget build(BuildContext context) { final visibleOverlay = - portalOptions.firstWhereOrNull((element) => element.visible); + overlayOptions.firstWhereOrNull((element) => element.visible); return PortalEntry( childAnchor: childAnchor, - portalAnchor: portalAnchor, + portalAnchor: overlayAnchor, visible: visibleOverlay != null, portal: visibleOverlay?.widget, child: child,