Merge branch 'main' into 3331-clicking-analytics-header-items-navigates-to-full-page-display
This commit is contained in:
commit
a840146d04
10 changed files with 1035 additions and 736 deletions
|
|
@ -27,9 +27,10 @@ abstract class AppConfig {
|
|||
static const bool allowOtherHomeservers = true;
|
||||
static const bool enableRegistration = true;
|
||||
// #Pangea
|
||||
static const double toolbarMaxHeight = 250.0;
|
||||
static const double toolbarMaxHeight = 225.0;
|
||||
static const double toolbarMinHeight = 150.0;
|
||||
static const double toolbarMinWidth = 350.0;
|
||||
static const double toolbarMenuHeight = 215.0;
|
||||
static const double defaultHeaderHeight = 56.0;
|
||||
static const double toolbarButtonsHeight = 50.0;
|
||||
static const double toolbarSpacing = 8.0;
|
||||
|
|
@ -89,6 +90,8 @@ abstract class AppConfig {
|
|||
static String _privacyUrl = "https://www.pangeachat.com/privacy";
|
||||
//Pangea#
|
||||
|
||||
static const Set<String> defaultReactions = {'👍', '❤️', '😂', '😮', '😢'};
|
||||
|
||||
static String get privacyUrl => _privacyUrl;
|
||||
// #Pangea
|
||||
// static const String website = 'https://fluffychat.im';
|
||||
|
|
|
|||
|
|
@ -5032,5 +5032,6 @@
|
|||
},
|
||||
"failedToFetchTranscription": "Failed to fetch transcription",
|
||||
"deleteEmptySpaceDesc": "The space will be deleted for all participants. This action cannot be undone.",
|
||||
"customReaction": "Custom reaction",
|
||||
"regenerate": "Regenerate"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2099,10 +2099,10 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
OverlayUtil.showOverlay(
|
||||
context: context,
|
||||
child: overlayEntry!,
|
||||
transformTargetId: "",
|
||||
position: OverlayPositionEnum.centered,
|
||||
onDismiss: clearSelectedEvents,
|
||||
blurBackground: true,
|
||||
backgroundColor: Colors.black,
|
||||
);
|
||||
|
||||
// select the message
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class OverlayUtil {
|
|||
static showOverlay({
|
||||
required BuildContext context,
|
||||
required Widget child,
|
||||
required String transformTargetId,
|
||||
String? transformTargetId,
|
||||
backDropToDismiss = true,
|
||||
blurBackground = false,
|
||||
Color? borderColor,
|
||||
|
|
@ -37,6 +37,13 @@ class OverlayUtil {
|
|||
bool canPop = true,
|
||||
}) {
|
||||
try {
|
||||
if (position == OverlayPositionEnum.transform) {
|
||||
assert(
|
||||
transformTargetId != null,
|
||||
"transformTargetId must be provided when position is OverlayPositionEnum.transform",
|
||||
);
|
||||
}
|
||||
|
||||
if (closePrevOverlay) {
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
}
|
||||
|
|
@ -77,7 +84,7 @@ class OverlayUtil {
|
|||
followerAnchor:
|
||||
followerAnchor ?? Alignment.bottomCenter,
|
||||
link: MatrixState.pAnyState
|
||||
.layerLinkAndKey(transformTargetId)
|
||||
.layerLinkAndKey(transformTargetId!)
|
||||
.link,
|
||||
showWhenUnlinked: false,
|
||||
offset: offset ?? Offset.zero,
|
||||
|
|
|
|||
|
|
@ -217,16 +217,16 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
|
||||
updateSelectedSpan(widget._initialSelectedToken!.text);
|
||||
|
||||
int retries = 0;
|
||||
while (retries < 5 &&
|
||||
selectedToken != null &&
|
||||
!MatrixState.pAnyState.isOverlayOpen(
|
||||
selectedToken!.text.uniqueKey,
|
||||
)) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
_showReadingAssistanceContent();
|
||||
retries++;
|
||||
}
|
||||
// int retries = 0;
|
||||
// while (retries < 5 &&
|
||||
// selectedToken != null &&
|
||||
// !MatrixState.pAnyState.isOverlayOpen(
|
||||
// selectedToken!.text.uniqueKey,
|
||||
// )) {
|
||||
// await Future.delayed(const Duration(milliseconds: 100));
|
||||
// _showReadingAssistanceContent();
|
||||
// retries++;
|
||||
// }
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
|
|
@ -296,9 +296,9 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
}
|
||||
|
||||
if (mounted) setState(() {});
|
||||
Future.delayed(const Duration(milliseconds: 10), () {
|
||||
_showReadingAssistanceContent();
|
||||
});
|
||||
// Future.delayed(const Duration(milliseconds: 10), () {
|
||||
// _showReadingAssistanceContent();
|
||||
// });
|
||||
}
|
||||
|
||||
void _showReadingAssistanceContent() {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,6 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pages/chat/events/message_reactions.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/enums/reading_assistance_mode_enum.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/measure_render_box.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
|
|
@ -15,7 +14,6 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
final Event event;
|
||||
final Event? nextEvent;
|
||||
final Event? prevEvent;
|
||||
final PangeaMessageEvent? pangeaMessageEvent;
|
||||
|
||||
final MessageOverlayController overlayController;
|
||||
final ChatController chatController;
|
||||
|
|
@ -25,8 +23,6 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
|
||||
final double? messageHeight;
|
||||
final double? messageWidth;
|
||||
final double maxWidth;
|
||||
final double maxHeight;
|
||||
|
||||
final bool hasReactions;
|
||||
|
||||
|
|
@ -37,11 +33,8 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
required this.event,
|
||||
required this.messageHeight,
|
||||
required this.messageWidth,
|
||||
required this.maxWidth,
|
||||
required this.maxHeight,
|
||||
required this.overlayController,
|
||||
required this.chatController,
|
||||
required this.pangeaMessageEvent,
|
||||
required this.nextEvent,
|
||||
required this.prevEvent,
|
||||
required this.hasReactions,
|
||||
|
|
@ -58,7 +51,7 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
ignoring: !isTransitionAnimation &&
|
||||
readingAssistanceMode != ReadingAssistanceMode.practiceMode,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||
constraints: BoxConstraints(maxWidth: overlayController.maxWidth),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Column(
|
||||
|
|
@ -76,7 +69,6 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
.key
|
||||
: null,
|
||||
event,
|
||||
pangeaMessageEvent: pangeaMessageEvent,
|
||||
immersionMode: chatController.choreographer.immersionMode,
|
||||
controller: chatController,
|
||||
overlayController: overlayController,
|
||||
|
|
@ -93,7 +85,6 @@ class OverlayCenterContent extends StatelessWidget {
|
|||
(sizeAnimation == null && isTransitionAnimation)
|
||||
? messageHeight
|
||||
: null,
|
||||
maxHeight: maxHeight,
|
||||
isTransitionAnimation: isTransitionAnimation,
|
||||
readingAssistanceMode: readingAssistanceMode,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -12,7 +11,6 @@ import 'package:fluffychat/pages/chat/chat.dart';
|
|||
import 'package:fluffychat/pages/chat/events/message_content.dart';
|
||||
import 'package:fluffychat/pages/chat/events/reply_content.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/utils/p_language_store.dart';
|
||||
|
|
@ -28,7 +26,6 @@ import 'package:fluffychat/widgets/matrix.dart';
|
|||
// @ggurdin be great to explain the need/function of a widget like this
|
||||
class OverlayMessage extends StatelessWidget {
|
||||
final Event event;
|
||||
final PangeaMessageEvent? pangeaMessageEvent;
|
||||
final MessageOverlayController overlayController;
|
||||
final ChatController controller;
|
||||
final Event? nextEvent;
|
||||
|
|
@ -39,7 +36,6 @@ class OverlayMessage extends StatelessWidget {
|
|||
final Animation<Size>? sizeAnimation;
|
||||
final double? messageWidth;
|
||||
final double? messageHeight;
|
||||
final double maxHeight;
|
||||
|
||||
final bool isTransitionAnimation;
|
||||
final ReadingAssistanceMode? readingAssistanceMode;
|
||||
|
|
@ -52,8 +48,6 @@ class OverlayMessage extends StatelessWidget {
|
|||
required this.timeline,
|
||||
required this.messageWidth,
|
||||
required this.messageHeight,
|
||||
required this.maxHeight,
|
||||
this.pangeaMessageEvent,
|
||||
this.nextEvent,
|
||||
this.previousEvent,
|
||||
this.sizeAnimation,
|
||||
|
|
@ -146,7 +140,8 @@ class OverlayMessage extends StatelessWidget {
|
|||
final showTranslation = overlayController.showTranslation &&
|
||||
overlayController.translation != null;
|
||||
|
||||
final showTranscription = pangeaMessageEvent?.isAudioMessage == true;
|
||||
final showTranscription =
|
||||
overlayController.pangeaMessageEvent?.isAudioMessage == true;
|
||||
|
||||
final showSpeechTranslation = overlayController.showSpeechTranslation &&
|
||||
overlayController.speechTranslation != null;
|
||||
|
|
@ -284,115 +279,109 @@ class OverlayMessage extends StatelessWidget {
|
|||
),
|
||||
width: messageWidth,
|
||||
height: messageHeight,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: maxHeight,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (event.relationshipType == RelationshipTypes.reply)
|
||||
FutureBuilder<Event?>(
|
||||
future: event.getReplyEvent(
|
||||
timeline,
|
||||
),
|
||||
builder: (
|
||||
BuildContext context,
|
||||
snapshot,
|
||||
) {
|
||||
final replyEvent = snapshot.hasData
|
||||
? snapshot.data!
|
||||
: Event(
|
||||
eventId: event.relationshipEventId!,
|
||||
content: {
|
||||
'msgtype': 'm.text',
|
||||
'body': '...',
|
||||
},
|
||||
senderId: "",
|
||||
type: 'm.room.message',
|
||||
room: event.room,
|
||||
status: EventStatus.sent,
|
||||
originServerTs: DateTime.now(),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 8,
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (event.relationshipType == RelationshipTypes.reply)
|
||||
FutureBuilder<Event?>(
|
||||
future: event.getReplyEvent(
|
||||
timeline,
|
||||
),
|
||||
builder: (
|
||||
BuildContext context,
|
||||
snapshot,
|
||||
) {
|
||||
final replyEvent = snapshot.hasData
|
||||
? snapshot.data!
|
||||
: Event(
|
||||
eventId: event.relationshipEventId!,
|
||||
content: {
|
||||
'msgtype': 'm.text',
|
||||
'body': '...',
|
||||
},
|
||||
senderId: "",
|
||||
type: 'm.room.message',
|
||||
room: event.room,
|
||||
status: EventStatus.sent,
|
||||
originServerTs: DateTime.now(),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 8,
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: ReplyContent.borderRadius,
|
||||
child: InkWell(
|
||||
borderRadius: ReplyContent.borderRadius,
|
||||
child: InkWell(
|
||||
borderRadius: ReplyContent.borderRadius,
|
||||
onTap: () => controller.scrollToEventId(
|
||||
replyEvent.eventId,
|
||||
),
|
||||
child: AbsorbPointer(
|
||||
child: ReplyContent(
|
||||
replyEvent,
|
||||
ownMessage: ownMessage,
|
||||
timeline: timeline,
|
||||
),
|
||||
onTap: () => controller.scrollToEventId(
|
||||
replyEvent.eventId,
|
||||
),
|
||||
child: AbsorbPointer(
|
||||
child: ReplyContent(
|
||||
replyEvent,
|
||||
ownMessage: ownMessage,
|
||||
timeline: timeline,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
MessageContent(
|
||||
displayEvent,
|
||||
textColor: textColor,
|
||||
linkColor: linkColor,
|
||||
borderRadius: borderRadius,
|
||||
timeline: timeline,
|
||||
pangeaMessageEvent: pangeaMessageEvent,
|
||||
immersionMode: immersionMode,
|
||||
overlayController: overlayController,
|
||||
controller: controller,
|
||||
nextEvent: nextEvent,
|
||||
prevEvent: previousEvent,
|
||||
isTransitionAnimation: isTransitionAnimation,
|
||||
readingAssistanceMode: readingAssistanceMode,
|
||||
selected: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (event.hasAggregatedEvents(
|
||||
timeline,
|
||||
RelationshipTypes.edit,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 8.0,
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 4.0,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.edit_outlined,
|
||||
color: textColor.withAlpha(164),
|
||||
size: 14,
|
||||
),
|
||||
Text(
|
||||
displayEvent.originServerTs.localizedTimeShort(
|
||||
context,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: textColor.withAlpha(
|
||||
164,
|
||||
),
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
MessageContent(
|
||||
displayEvent,
|
||||
textColor: textColor,
|
||||
linkColor: linkColor,
|
||||
borderRadius: borderRadius,
|
||||
timeline: timeline,
|
||||
pangeaMessageEvent: overlayController.pangeaMessageEvent,
|
||||
immersionMode: immersionMode,
|
||||
overlayController: overlayController,
|
||||
controller: controller,
|
||||
nextEvent: nextEvent,
|
||||
prevEvent: previousEvent,
|
||||
isTransitionAnimation: isTransitionAnimation,
|
||||
readingAssistanceMode: readingAssistanceMode,
|
||||
selected: true,
|
||||
),
|
||||
if (event.hasAggregatedEvents(
|
||||
timeline,
|
||||
RelationshipTypes.edit,
|
||||
))
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 8.0,
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 4.0,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.edit_outlined,
|
||||
color: textColor.withAlpha(164),
|
||||
size: 14,
|
||||
),
|
||||
Text(
|
||||
displayEvent.originServerTs.localizedTimeShort(
|
||||
context,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: textColor.withAlpha(
|
||||
164,
|
||||
),
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -404,9 +393,8 @@ class OverlayMessage extends StatelessWidget {
|
|||
color: noBubble ? Colors.transparent : color,
|
||||
borderRadius: borderRadius,
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: FluffyThemes.columnWidth * 1.5,
|
||||
maxHeight: maxHeight,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
|
|
|
|||
|
|
@ -147,14 +147,13 @@ class ReadingAssistanceContentState extends State<ReadingAssistanceContent> {
|
|||
),
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: AppConfig.toolbarMaxHeight,
|
||||
minWidth: min(
|
||||
AppConfig.toolbarMinWidth,
|
||||
widget.overlayController.maxWidth,
|
||||
),
|
||||
minHeight: AppConfig.toolbarMinHeight,
|
||||
maxWidth: widget.overlayController.maxWidth,
|
||||
),
|
||||
height: AppConfig.toolbarMaxHeight,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@ import 'package:path_provider/path_provider.dart';
|
|||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pages/chat/events/audio_player.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/pressable_button.dart';
|
||||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import 'package:fluffychat/pangea/events/models/representation_content_model.dart';
|
||||
import 'package:fluffychat/pangea/events/utils/report_message.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/controllers/tts_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_audio_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
|
|
@ -45,13 +46,74 @@ enum SelectMode {
|
|||
}
|
||||
}
|
||||
|
||||
enum MessageActions {
|
||||
reply,
|
||||
forward,
|
||||
edit,
|
||||
delete,
|
||||
copy,
|
||||
download,
|
||||
pin,
|
||||
report,
|
||||
info;
|
||||
|
||||
IconData get icon {
|
||||
switch (this) {
|
||||
case MessageActions.reply:
|
||||
return Icons.reply_all;
|
||||
case MessageActions.forward:
|
||||
return Symbols.forward;
|
||||
case MessageActions.edit:
|
||||
return Symbols.edit;
|
||||
case MessageActions.delete:
|
||||
return Symbols.delete;
|
||||
case MessageActions.copy:
|
||||
return Icons.copy_outlined;
|
||||
case MessageActions.download:
|
||||
return Symbols.download;
|
||||
case MessageActions.pin:
|
||||
return Symbols.push_pin;
|
||||
case MessageActions.report:
|
||||
return Icons.shield_outlined;
|
||||
case MessageActions.info:
|
||||
return Icons.info_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
String tooltip(BuildContext context) {
|
||||
final l10n = L10n.of(context);
|
||||
switch (this) {
|
||||
case MessageActions.reply:
|
||||
return l10n.reply;
|
||||
case MessageActions.forward:
|
||||
return l10n.forward;
|
||||
case MessageActions.edit:
|
||||
return l10n.edit;
|
||||
case MessageActions.delete:
|
||||
return l10n.redactMessage;
|
||||
case MessageActions.copy:
|
||||
return l10n.copy;
|
||||
case MessageActions.download:
|
||||
return l10n.download;
|
||||
case MessageActions.pin:
|
||||
return l10n.pinMessage;
|
||||
case MessageActions.report:
|
||||
return l10n.reportMessage;
|
||||
case MessageActions.info:
|
||||
return l10n.messageInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SelectModeButtons extends StatefulWidget {
|
||||
final VoidCallback lauchPractice;
|
||||
final MessageOverlayController overlayController;
|
||||
final ChatController controller;
|
||||
|
||||
const SelectModeButtons({
|
||||
required this.lauchPractice,
|
||||
required this.overlayController,
|
||||
required this.controller,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -475,46 +537,172 @@ class SelectModeButtonsState extends State<SelectModeButtons> {
|
|||
);
|
||||
}
|
||||
|
||||
bool _messageActionEnabled(MessageActions action) {
|
||||
if (messageEvent == null) return false;
|
||||
|
||||
switch (action) {
|
||||
case MessageActions.reply:
|
||||
return widget.controller.selectedEvents.length == 1 &&
|
||||
widget.controller.room.canSendDefaultMessages;
|
||||
case MessageActions.edit:
|
||||
return widget.controller.canEditSelectedEvents &&
|
||||
!widget.controller.selectedEvents.first.isActivityMessage;
|
||||
case MessageActions.delete:
|
||||
return widget.controller.canRedactSelectedEvents;
|
||||
case MessageActions.copy:
|
||||
return widget.controller.selectedEvents.length == 1 &&
|
||||
widget.controller.selectedEvents.single.messageType ==
|
||||
MessageTypes.Text;
|
||||
case MessageActions.download:
|
||||
return widget.controller.canSaveSelectedEvent;
|
||||
case MessageActions.pin:
|
||||
return widget.controller.canPinSelectedEvents;
|
||||
case MessageActions.forward:
|
||||
case MessageActions.report:
|
||||
case MessageActions.info:
|
||||
return widget.controller.selectedEvents.length == 1;
|
||||
}
|
||||
}
|
||||
|
||||
void _onActionPressed(MessageActions action) {
|
||||
switch (action) {
|
||||
case MessageActions.reply:
|
||||
widget.controller.replyAction();
|
||||
break;
|
||||
case MessageActions.forward:
|
||||
widget.controller.forwardEventsAction();
|
||||
break;
|
||||
case MessageActions.edit:
|
||||
widget.controller.editSelectedEventAction();
|
||||
break;
|
||||
case MessageActions.delete:
|
||||
widget.controller.redactEventsAction();
|
||||
break;
|
||||
case MessageActions.copy:
|
||||
widget.controller.copyEventsAction();
|
||||
break;
|
||||
case MessageActions.download:
|
||||
widget.controller.saveSelectedEvent(context);
|
||||
break;
|
||||
case MessageActions.pin:
|
||||
widget.controller.pinEvent();
|
||||
break;
|
||||
case MessageActions.report:
|
||||
final event = widget.controller.selectedEvents.first;
|
||||
widget.controller.clearSelectedEvents();
|
||||
reportEvent(
|
||||
event,
|
||||
widget.controller,
|
||||
widget.controller.context,
|
||||
);
|
||||
break;
|
||||
case MessageActions.info:
|
||||
widget.controller.showEventInfo();
|
||||
widget.controller.clearSelectedEvents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final modes = messageEvent?.isAudioMessage == true ? audioModes : textModes;
|
||||
final actions = MessageActions.values.where(_messageActionEnabled);
|
||||
|
||||
return Container(
|
||||
height: AppConfig.toolbarButtonsHeight,
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 4.0,
|
||||
children: [
|
||||
for (final mode in modes)
|
||||
TooltipVisibility(
|
||||
visible: (!_isError || mode != _selectedMode),
|
||||
child: Tooltip(
|
||||
message: mode.tooltip(context),
|
||||
child: PressableButton(
|
||||
depressed: mode == _selectedMode,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
onPressed: () => _updateMode(mode),
|
||||
playSound: mode != SelectMode.audio,
|
||||
colorFactor: Theme.of(context).brightness == Brightness.light
|
||||
? 0.55
|
||||
: 0.3,
|
||||
child: Container(
|
||||
height: buttonSize,
|
||||
width: buttonSize,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: icon(mode),
|
||||
),
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Container(
|
||||
width: 250,
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: AppConfig.toolbarMenuHeight,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConfig.borderRadius,
|
||||
),
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: modes.length + actions.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index < modes.length) {
|
||||
final mode = modes[index];
|
||||
return SizedBox(
|
||||
height: 50.0,
|
||||
child: ListTile(
|
||||
leading: Icon(mode.icon),
|
||||
title: Text(mode.tooltip(context)),
|
||||
onTap: () => _updateMode(mode),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (index == modes.length) {
|
||||
return const Divider(height: 1.0);
|
||||
} else {
|
||||
final action = actions.elementAt(index - modes.length - 1);
|
||||
return SizedBox(
|
||||
height: 50.0,
|
||||
child: ListTile(
|
||||
leading: Icon(action.icon),
|
||||
title: Text(action.tooltip(context)),
|
||||
onTap: () => _onActionPressed(action),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// return SizedBox(
|
||||
// width: 150,
|
||||
// child: ListView.builder(
|
||||
// itemCount: modes.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final mode = modes[index];
|
||||
// return ListTile(
|
||||
// leading: Icon(mode.icon),
|
||||
// title: Text(mode.name),
|
||||
// onTap: () {
|
||||
// _updateMode(mode);
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
|
||||
// return Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// spacing: 4.0,
|
||||
// children: [
|
||||
// for (final mode in modes)
|
||||
// TooltipVisibility(
|
||||
// visible: (!_isError || mode != _selectedMode),
|
||||
// child: Tooltip(
|
||||
// message: mode.tooltip(context),
|
||||
// child: PressableButton(
|
||||
// depressed: mode == _selectedMode,
|
||||
// borderRadius: BorderRadius.circular(20),
|
||||
// color: Theme.of(context).colorScheme.primaryContainer,
|
||||
// onPressed: () => _updateMode(mode),
|
||||
// playSound: mode != SelectMode.audio,
|
||||
// colorFactor: Theme.of(context).brightness == Brightness.light
|
||||
// ? 0.55
|
||||
// : 0.3,
|
||||
// child: Container(
|
||||
// height: buttonSize,
|
||||
// width: buttonSize,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Theme.of(context).colorScheme.primaryContainer,
|
||||
// shape: BoxShape.circle,
|
||||
// ),
|
||||
// child: icon(mode),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue