|
|
|
@ -13,9 +13,12 @@ import 'package:fluffychat/pages/chat/chat.dart';
|
|
|
|
import 'package:fluffychat/pages/chat/input_bar.dart';
|
|
|
|
import 'package:fluffychat/pages/chat/input_bar.dart';
|
|
|
|
import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart';
|
|
|
|
import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart';
|
|
|
|
import 'package:fluffychat/pangea/choreographer/widgets/start_igc_button.dart';
|
|
|
|
import 'package:fluffychat/pangea/choreographer/widgets/start_igc_button.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
|
|
|
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/reading_assistance_input_bar.dart';
|
|
|
|
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/reading_assistance_input_bar.dart';
|
|
|
|
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
|
|
|
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/utils/error_reporter.dart';
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class PangeaChatInputRow extends StatefulWidget {
|
|
|
|
class PangeaChatInputRow extends StatefulWidget {
|
|
|
|
@ -52,18 +55,9 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
|
|
|
|
|
|
|
|
ChatController get _controller => widget.controller;
|
|
|
|
ChatController get _controller => widget.controller;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
LanguageModel? get activel1 =>
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
|
|
|
if (_controller.showEmojiPicker &&
|
|
|
|
|
|
|
|
_controller.emojiPickerType == EmojiPickerType.reaction) {
|
|
|
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const height = 48.0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final activel1 =
|
|
|
|
|
|
|
|
_controller.pangeaController.languageController.activeL1Model();
|
|
|
|
_controller.pangeaController.languageController.activeL1Model();
|
|
|
|
final activel2 =
|
|
|
|
LanguageModel? get activel2 =>
|
|
|
|
_controller.pangeaController.languageController.activeL2Model();
|
|
|
|
_controller.pangeaController.languageController.activeL2Model();
|
|
|
|
|
|
|
|
|
|
|
|
String hintText() {
|
|
|
|
String hintText() {
|
|
|
|
@ -72,20 +66,87 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return activel1 != null &&
|
|
|
|
return activel1 != null &&
|
|
|
|
activel2 != null &&
|
|
|
|
activel2 != null &&
|
|
|
|
activel1.langCode != LanguageKeys.unknownLanguage &&
|
|
|
|
activel1!.langCode != LanguageKeys.unknownLanguage &&
|
|
|
|
activel2.langCode != LanguageKeys.unknownLanguage
|
|
|
|
activel2!.langCode != LanguageKeys.unknownLanguage
|
|
|
|
? L10n.of(context).writeAMessageLangCodes(
|
|
|
|
? L10n.of(context).writeAMessageLangCodes(
|
|
|
|
activel1.langCodeShort.toUpperCase(),
|
|
|
|
activel1!.langCodeShort.toUpperCase(),
|
|
|
|
activel2.langCodeShort.toUpperCase(),
|
|
|
|
activel2!.langCodeShort.toUpperCase(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: L10n.of(context).writeAMessage;
|
|
|
|
: L10n.of(context).writeAMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _deleteErrorEventsAction() async {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (widget.overlayController == null ||
|
|
|
|
|
|
|
|
widget.overlayController!.event.status != EventStatus.error) {
|
|
|
|
|
|
|
|
throw Exception(
|
|
|
|
|
|
|
|
'Tried to delete failed to send events but one event is not failed to sent',
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
await widget.overlayController!.event.cancelSend();
|
|
|
|
|
|
|
|
_controller.clearSelectedEvents();
|
|
|
|
|
|
|
|
} catch (e, s) {
|
|
|
|
|
|
|
|
ErrorReporter(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
'Error while delete error events action',
|
|
|
|
|
|
|
|
).onErrorCallback(e, s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _sendAgainAction() {
|
|
|
|
|
|
|
|
if (widget.overlayController == null) {
|
|
|
|
|
|
|
|
ErrorHandler.logError(
|
|
|
|
|
|
|
|
e: "No selected events in send again action",
|
|
|
|
|
|
|
|
s: StackTrace.current,
|
|
|
|
|
|
|
|
data: {"roomId": _controller.room.id},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
_controller.clearSelectedEvents();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final event = widget.overlayController!.event;
|
|
|
|
|
|
|
|
if (event.status.isError) {
|
|
|
|
|
|
|
|
event.sendAgain();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final allEditEvents = event
|
|
|
|
|
|
|
|
.aggregatedEvents(
|
|
|
|
|
|
|
|
_controller.timeline!,
|
|
|
|
|
|
|
|
RelationshipTypes.edit,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.where((e) => e.status.isError);
|
|
|
|
|
|
|
|
for (final e in allEditEvents) {
|
|
|
|
|
|
|
|
e.sendAgain();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_controller.clearSelectedEvents();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
|
|
|
if (_controller.showEmojiPicker &&
|
|
|
|
|
|
|
|
_controller.emojiPickerType == EmojiPickerType.reaction) {
|
|
|
|
|
|
|
|
return const SizedBox.shrink();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const height = 48.0;
|
|
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
// if (!controller.selectMode) WritingAssistanceInputRow(controller),
|
|
|
|
// if (!controller.selectMode) WritingAssistanceInputRow(controller),
|
|
|
|
CompositedTransformTarget(
|
|
|
|
CompositedTransformTarget(
|
|
|
|
link: _controller.choreographer.inputLayerLinkAndKey.link,
|
|
|
|
link: _controller.choreographer.inputLayerLinkAndKey.link,
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
padding:
|
|
|
|
|
|
|
|
EdgeInsets.all(widget.overlayController != null ? 8.0 : 0.0),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: widget.overlayController != null
|
|
|
|
|
|
|
|
? Theme.of(context).cardColor
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
|
|
|
Radius.circular(8.0),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
key: widget.overlayController != null
|
|
|
|
key: widget.overlayController != null
|
|
|
|
? null
|
|
|
|
? null
|
|
|
|
@ -94,15 +155,15 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: widget.overlayController != null
|
|
|
|
children: widget.overlayController != null
|
|
|
|
? <Widget>[
|
|
|
|
? <Widget>[
|
|
|
|
if (_controller.selectedEvents
|
|
|
|
if (widget.overlayController!.event.status ==
|
|
|
|
.every((event) => event.status == EventStatus.error))
|
|
|
|
EventStatus.error)
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
|
height: height,
|
|
|
|
height: height,
|
|
|
|
child: TextButton(
|
|
|
|
child: TextButton(
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
foregroundColor: theme.colorScheme.error,
|
|
|
|
foregroundColor: theme.colorScheme.error,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: _controller.deleteErrorEventsAction,
|
|
|
|
onPressed: _deleteErrorEventsAction,
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
const Icon(Icons.delete),
|
|
|
|
const Icon(Icons.delete),
|
|
|
|
@ -111,29 +172,22 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (_controller.selectedEvents.isNotEmpty &&
|
|
|
|
if (widget.overlayController!.event
|
|
|
|
_controller.selectedEvents.first
|
|
|
|
|
|
|
|
.getDisplayEvent(_controller.timeline!)
|
|
|
|
.getDisplayEvent(_controller.timeline!)
|
|
|
|
.status
|
|
|
|
.status
|
|
|
|
.isSent &&
|
|
|
|
.isSent)
|
|
|
|
!_controller.selectedEvents.every(
|
|
|
|
ReadingAssistanceInputBar(
|
|
|
|
(event) => event.status == EventStatus.error,
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
widget.overlayController != null
|
|
|
|
|
|
|
|
? ReadingAssistanceInputBar(
|
|
|
|
|
|
|
|
_controller,
|
|
|
|
_controller,
|
|
|
|
widget.overlayController!,
|
|
|
|
widget.overlayController!,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
: const SizedBox(height: height),
|
|
|
|
if (widget.overlayController!.event
|
|
|
|
if (_controller.selectedEvents.length == 1 &&
|
|
|
|
|
|
|
|
_controller.selectedEvents.first
|
|
|
|
|
|
|
|
.getDisplayEvent(_controller.timeline!)
|
|
|
|
.getDisplayEvent(_controller.timeline!)
|
|
|
|
.status
|
|
|
|
.status
|
|
|
|
.isError)
|
|
|
|
.isError)
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
|
height: height,
|
|
|
|
height: height,
|
|
|
|
child: TextButton(
|
|
|
|
child: TextButton(
|
|
|
|
onPressed: _controller.sendAgainAction,
|
|
|
|
onPressed: _sendAgainAction,
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
children: <Widget>[
|
|
|
|
Text(L10n.of(context).tryToSendAgain),
|
|
|
|
Text(L10n.of(context).tryToSendAgain),
|
|
|
|
@ -150,8 +204,9 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
curve: FluffyThemes.animationCurve,
|
|
|
|
curve: FluffyThemes.animationCurve,
|
|
|
|
height: height,
|
|
|
|
height: height,
|
|
|
|
width:
|
|
|
|
width: _controller.sendController.text.isEmpty
|
|
|
|
_controller.sendController.text.isEmpty ? height : 0,
|
|
|
|
? height
|
|
|
|
|
|
|
|
: 0,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
decoration: const BoxDecoration(),
|
|
|
|
decoration: const BoxDecoration(),
|
|
|
|
@ -242,7 +297,8 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
return SharedAxisTransition(
|
|
|
|
return SharedAxisTransition(
|
|
|
|
animation: primaryAnimation,
|
|
|
|
animation: primaryAnimation,
|
|
|
|
secondaryAnimation: secondaryAnimation,
|
|
|
|
secondaryAnimation: secondaryAnimation,
|
|
|
|
transitionType: SharedAxisTransitionType.scaled,
|
|
|
|
transitionType:
|
|
|
|
|
|
|
|
SharedAxisTransitionType.scaled,
|
|
|
|
fillColor: Colors.transparent,
|
|
|
|
fillColor: Colors.transparent,
|
|
|
|
child: child,
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -320,6 +376,7 @@ class PangeaChatInputRowState extends State<PangeaChatInputRow> {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|