Merge pull request #878 from pangeachat/874-small-bugs-and-ux-issues-from-user-testing

start language assistance on enter
This commit is contained in:
ggurdin 2024-11-01 10:31:14 -04:00 committed by GitHub
commit 3cd8dfac6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 53 additions and 44 deletions

View file

@ -1,5 +1,4 @@
import 'package:animations/animations.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/choreographer/widgets/send_button.dart';
import 'package:fluffychat/pangea/constants/language_constants.dart';
import 'package:fluffychat/utils/platform_infos.dart';
@ -299,11 +298,12 @@ class ChatInputRow extends StatelessWidget {
maxLines: 8,
autofocus: !PlatformInfos.isMobile,
keyboardType: TextInputType.multiline,
textInputAction: AppConfig.sendOnEnter == true &&
PlatformInfos.isMobile
? TextInputAction.send
: null,
// #Pangea
// textInputAction: AppConfig.sendOnEnter == true &&
// PlatformInfos.isMobile
// ? TextInputAction.send
// : null,
textInputAction: TextInputAction.send,
// onSubmitted: controller.onInputBarSubmitted,
onSubmitted: (String value) =>
controller.onInputBarSubmitted(value, context),
@ -336,36 +336,36 @@ class ChatInputRow extends StatelessWidget {
height: height,
width: height,
alignment: Alignment.center,
child: PlatformInfos.platformCanRecord &&
controller.sendController.text.isEmpty
? FloatingActionButton.small(
tooltip: L10n.of(context)!.voiceMessage,
onPressed: controller.voiceMessageAction,
elevation: 0,
heroTag: null,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(height),
),
backgroundColor: theme.colorScheme.primary,
foregroundColor: theme.colorScheme.onPrimary,
child: const Icon(Icons.mic_none_outlined),
)
:
child:
// #Pangea
// PlatformInfos.platformCanRecord &&
// controller.sendController.text.isEmpty
// ? FloatingActionButton.small(
// tooltip: L10n.of(context)!.voiceMessage,
// onPressed: controller.voiceMessageAction,
// elevation: 0,
// heroTag: null,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(height),
// ),
// backgroundColor: theme.colorScheme.primary,
// foregroundColor: theme.colorScheme.onPrimary,
// child: const Icon(Icons.mic_none_outlined),
// )
// : FloatingActionButton.small(
// tooltip: L10n.of(context)!.send,
// onPressed: controller.send,
// elevation: 0,
// heroTag: null,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(height),
// ),
// backgroundColor:
// theme.colorScheme.onPrimaryContainer,
// foregroundColor: theme.colorScheme.onPrimary,
// child: const Icon(Icons.send_outlined),
// ),
ChoreographerSendButton(controller: controller),
// FloatingActionButton.small(
// tooltip: L10n.of(context)!.send,
// onPressed: controller.send,
// elevation: 0,
// heroTag: null,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(height),
// ),
// backgroundColor:
// theme.colorScheme.onPrimaryContainer,
// foregroundColor: theme.colorScheme.onPrimary,
// child: const Icon(Icons.send_outlined),
// ),
// Pangea#
),
],

View file

@ -68,7 +68,12 @@ class Choreographer {
}
void send(BuildContext context) {
if (!canSendMessage) return;
if (!canSendMessage) {
if (igc.igcTextData != null) {
igc.showFirstMatch(context);
}
return;
}
if (pangeaController.subscriptionController.subscriptionStatus ==
SubscriptionStatus.showPaywall) {
@ -84,7 +89,7 @@ class Choreographer {
return;
}
if (!igc.hasRelevantIGCTextData) {
if (!igc.hasRelevantIGCTextData && !itController.dismissed) {
getLanguageHelp().then((value) => _sendWithIGC(context));
} else {
_sendWithIGC(context);
@ -201,7 +206,8 @@ class Choreographer {
return;
}
if (_textController.editType == EditType.igc) {
if (_textController.editType == EditType.igc ||
_textController.editType == EditType.itDismissed) {
_lastChecked = _textController.text;
_textController.editType = EditType.keyboard;
return;
@ -603,7 +609,9 @@ class Choreographer {
if (isFetching) return false;
// they're supposed to run IGC but haven't yet, don't let them send
if (isAutoIGCEnabled && igc.igcTextData == null) return false;
if (igc.igcTextData == null) {
return itController.dismissed;
}
// if they have relevant matches, don't let them send
final hasITMatches =

View file

@ -5,6 +5,7 @@ import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart';
import 'package:fluffychat/pangea/constants/choreo_constants.dart';
import 'package:fluffychat/pangea/controllers/my_analytics_controller.dart';
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
import 'package:fluffychat/pangea/enum/edit_type.dart';
import 'package:fluffychat/pangea/models/pangea_token_model.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:flutter/foundation.dart';
@ -26,6 +27,7 @@ class ITController {
bool _willOpen = false;
bool _isEditingSourceText = false;
bool showChoiceFeedback = false;
bool dismissed = false;
ITStartData? _itStartData;
String? sourceText;
@ -42,6 +44,7 @@ class ITController {
_willOpen = false;
showChoiceFeedback = false;
_isEditingSourceText = false;
dismissed = false;
_itStartData = null;
sourceText = null;
@ -71,9 +74,11 @@ class ITController {
void closeIT() {
// if the user hasn't gone through any IT steps, reset the text
if (completedITSteps.isEmpty && sourceText != null) {
choreographer.textController.editType = EditType.itDismissed;
choreographer.textController.text = sourceText!;
}
clear();
dismissed = true;
}
/// if IGC isn't positive that text is full L1 then translate to L1
@ -201,6 +206,7 @@ class ITController {
final ITResponseModel res =
await _customInputTranslation(currentText + nextText);
if (sourceText == null) return;
nextITStep = CurrentITStep(
sourceText: sourceText!,

View file

@ -56,10 +56,7 @@ class ChoreographerSendButtonState extends State<ChoreographerSendButton> {
color: widget.controller.choreographer.assistanceState
.stateColor(context),
onPressed: () {
widget.controller.choreographer.canSendMessage
? widget.controller.choreographer.send(context)
: widget.controller.choreographer.igc
.showFirstMatch(context);
widget.controller.choreographer.send(context);
},
tooltip: L10n.of(context)!.send,
),

View file

@ -5,4 +5,5 @@ enum EditType {
alternativeTranslation,
itGold,
itStart,
itDismissed,
}

View file

@ -70,7 +70,6 @@ class MultipleChoiceActivityState extends State<MultipleChoiceActivity> {
return;
}
// #freeze-activity
MatrixState.pangeaController.myAnalytics.setState(
AnalyticsStream(
// note - this maybe should be the activity event id
@ -113,7 +112,6 @@ class MultipleChoiceActivityState extends State<MultipleChoiceActivity> {
),
),
const SizedBox(height: 8),
// #freeze-activity
if (practiceActivity.activityType ==
ActivityTypeEnum.wordFocusListening)
WordAudioButton(

View file

@ -55,7 +55,6 @@ class WordAudioButtonState extends State<WordAudioButton> {
}
}, // Disable button if language isn't supported
),
// #freeze-activity
widget.ttsController.missingVoiceButton,
],
);