Skip to content

Commit

Permalink
Merge pull request #97 from pangeachat/null-fix
Browse files Browse the repository at this point in the history
null check fix
  • Loading branch information
ggurdin authored Mar 4, 2024
2 parents 69fe23c + 7655a97 commit 7cade4c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 0 additions & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<true/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>processing</string>
<string>remote-notification</string>
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/chat/events/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class Message extends StatelessWidget {
final PangeaMessageEvent? pangeaMessageEvent =
controller.getPangeaMessageEvent(event.eventId);
ToolbarDisplayController? toolbarController;
if (event.messageType == MessageTypes.Text) {
if (event.messageType == MessageTypes.Text ||
event.messageType == MessageTypes.Notice) {
toolbarController = controller.getToolbarDisplayController(event.eventId);
}
// Pangea#
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/events/message_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class MessageContent extends StatelessWidget {
style: messageTextStyle,
pangeaMessageEvent: pangeaMessageEvent!,
immersionMode: immersionMode,
toolbarController: toolbarController!,
toolbarController: toolbarController,
);
}
// Pangea#
Expand Down
30 changes: 16 additions & 14 deletions lib/pangea/widgets/igc/pangea_rich_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '../../models/pangea_match_model.dart';
class PangeaRichText extends StatefulWidget {
final PangeaMessageEvent pangeaMessageEvent;
final bool immersionMode;
final ToolbarDisplayController toolbarController;
final ToolbarDisplayController? toolbarController;
final TextStyle? style;

const PangeaRichText({
Expand Down Expand Up @@ -89,7 +89,7 @@ class PangeaRichTextState extends State<PangeaRichText> {
.onError((error, stackTrace) => ErrorHandler.logError())
.then((event) {
repEvent = event;
widget.toolbarController.toolbar?.textSelection.setMessageText(
widget.toolbarController?.toolbar?.textSelection.setMessageText(
repEvent?.text ?? widget.pangeaMessageEvent.body,
);
}).whenComplete(() {
Expand All @@ -99,7 +99,7 @@ class PangeaRichTextState extends State<PangeaRichText> {
});
return widget.pangeaMessageEvent.body;
} else {
widget.toolbarController.toolbar?.textSelection.setMessageText(
widget.toolbarController?.toolbar?.textSelection.setMessageText(
repEvent!.text,
);
setState(() {});
Expand Down Expand Up @@ -129,31 +129,33 @@ class PangeaRichTextState extends State<PangeaRichText> {
final Widget richText = SelectableText.rich(
onSelectionChanged: (selection, cause) {
if (cause == SelectionChangedCause.longPress &&
!widget.toolbarController.highlighted &&
!widget.toolbarController.controller.selectedEvents.any(
(e) => e.eventId == widget.pangeaMessageEvent.eventId,
)) {
widget.toolbarController.controller.onSelectMessage(
!(widget.toolbarController?.highlighted ?? false) &&
!(widget.toolbarController?.controller.selectedEvents.any(
(e) => e.eventId == widget.pangeaMessageEvent.eventId,
) ??
false)) {
widget.toolbarController?.controller.onSelectMessage(
widget.pangeaMessageEvent.event,
);
return;
}
widget.toolbarController.toolbar?.textSelection
widget.toolbarController?.toolbar?.textSelection
.onTextSelection(selection);
},
onTap: () => widget.toolbarController.showToolbar(context),
enableInteractiveSelection: widget.toolbarController.highlighted,
onTap: () => widget.toolbarController?.showToolbar(context),
enableInteractiveSelection:
widget.toolbarController?.highlighted ?? false,
contextMenuBuilder: (context, state) =>
widget.toolbarController.highlighted
widget.toolbarController?.highlighted ?? true
? const SizedBox.shrink()
: MessageContextMenu.contextMenuOverride(
context: context,
textSelection: state,
onDefine: () => widget.toolbarController.showToolbar(
onDefine: () => widget.toolbarController?.showToolbar(
context,
mode: MessageMode.definition,
),
onListen: () => widget.toolbarController.showToolbar(
onListen: () => widget.toolbarController?.showToolbar(
context,
mode: MessageMode.play,
),
Expand Down

0 comments on commit 7cade4c

Please sign in to comment.