From 8493e28d9633bd4f403d105568e04bba000dd61c Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 15 Jul 2025 10:43:25 -0400 Subject: [PATCH] chore: make IGC button more prominent and added tooltip, set auto-IGC false by default (#3461) --- lib/l10n/intl_en.arb | 3 +- .../enums/assistance_state_enum.dart | 1 + .../widgets/start_igc_button.dart | 121 +++++++++++------- lib/pangea/common/constants/model_keys.dart | 2 + lib/pangea/user/models/user_model.dart | 6 +- 5 files changed, 85 insertions(+), 48 deletions(-) diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 870de370e..e7f885b47 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -5091,5 +5091,6 @@ "pleaseReload": "Please reload and try again.", "translationError": "Translation error", "errorFetchingTranslation": "Failed to fetch translation", - "errorFetchingActivity": "Failed to fetch activity" + "errorFetchingActivity": "Failed to fetch activity", + "check": "Check" } diff --git a/lib/pangea/choreographer/enums/assistance_state_enum.dart b/lib/pangea/choreographer/enums/assistance_state_enum.dart index e30272b82..92884d1cb 100644 --- a/lib/pangea/choreographer/enums/assistance_state_enum.dart +++ b/lib/pangea/choreographer/enums/assistance_state_enum.dart @@ -20,6 +20,7 @@ extension AssistanceStateExtension on AssistanceState { switch (this) { case AssistanceState.noSub: case AssistanceState.noMessage: + return Theme.of(context).disabledColor; case AssistanceState.notFetched: case AssistanceState.fetching: return Theme.of(context).colorScheme.primary; diff --git a/lib/pangea/choreographer/widgets/start_igc_button.dart b/lib/pangea/choreographer/widgets/start_igc_button.dart index a1d2b34c0..6daac042a 100644 --- a/lib/pangea/choreographer/widgets/start_igc_button.dart +++ b/lib/pangea/choreographer/widgets/start_igc_button.dart @@ -3,6 +3,8 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; +import 'package:fluffychat/config/themes.dart'; +import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/pangea/choreographer/enums/assistance_state_enum.dart'; import 'package:fluffychat/pangea/choreographer/widgets/igc/paywall_card.dart'; import 'package:fluffychat/pangea/common/utils/overlay.dart'; @@ -68,8 +70,12 @@ class StartIGCButtonState extends State } bool get _enableFeedback { - return assistanceState != AssistanceState.fetching && - assistanceState != AssistanceState.complete; + return ![ + AssistanceState.fetching, + AssistanceState.fetched, + AssistanceState.complete, + AssistanceState.noMessage, + ].contains(assistanceState); } Future _onTap() async { @@ -106,52 +112,79 @@ class StartIGCButtonState extends State } } + Color get _backgroundColor { + switch (assistanceState) { + case AssistanceState.noSub: + case AssistanceState.noMessage: + case AssistanceState.fetched: + case AssistanceState.complete: + return Theme.of(context).colorScheme.surfaceContainerHighest; + case AssistanceState.notFetched: + case AssistanceState.fetching: + return Theme.of(context).colorScheme.primaryContainer; + } + } + @override Widget build(BuildContext context) { - return SizedBox( - child: InkWell( - enableFeedback: _enableFeedback, - onTap: _enableFeedback ? _onTap : null, - customBorder: const CircleBorder(), - onLongPress: _enableFeedback - ? () => showDialog( - context: context, - builder: (c) => const SettingsLearning(), - barrierDismissible: false, - ) - : null, - child: Stack( - alignment: Alignment.center, - children: [ - _controller != null - ? RotationTransition( - turns: Tween(begin: 0.0, end: math.pi * 2) - .animate(_controller!), - child: Icon( - size: 36, - Icons.autorenew_rounded, - color: assistanceState.stateColor(context), - ), + final icon = Icon( + size: 36, + Icons.autorenew_rounded, + color: assistanceState.stateColor(context), + ); + + return Tooltip( + message: _enableFeedback ? L10n.of(context).check : "", + child: Material( + elevation: _enableFeedback ? 4.0 : 0.0, + borderRadius: BorderRadius.circular(99.0), + shadowColor: Theme.of(context).colorScheme.surface.withAlpha(128), + child: InkWell( + enableFeedback: _enableFeedback, + onTap: _enableFeedback ? _onTap : null, + customBorder: const CircleBorder(), + onLongPress: _enableFeedback + ? () => showDialog( + context: context, + builder: (c) => const SettingsLearning(), + barrierDismissible: false, ) - : Icon( - size: 36, - Icons.autorenew_rounded, - color: assistanceState.stateColor(context), - ), - Container( - width: 20, - height: 20, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.surfaceContainerHighest, + : null, + child: Stack( + alignment: Alignment.center, + children: [ + AnimatedContainer( + height: 40.0, + width: 40.0, + duration: FluffyThemes.animationDuration, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _backgroundColor, + ), ), - ), - Icon( - size: 16, - Icons.check, - color: assistanceState.stateColor(context), - ), - ], + _controller != null + ? RotationTransition( + turns: Tween(begin: 0.0, end: math.pi * 2) + .animate(_controller!), + child: icon, + ) + : icon, + AnimatedContainer( + width: 20, + height: 20, + duration: FluffyThemes.animationDuration, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _backgroundColor, + ), + ), + Icon( + size: 16, + Icons.check, + color: assistanceState.stateColor(context), + ), + ], + ), ), ), ); diff --git a/lib/pangea/common/constants/model_keys.dart b/lib/pangea/common/constants/model_keys.dart index 22b360c8d..0f9e33f54 100644 --- a/lib/pangea/common/constants/model_keys.dart +++ b/lib/pangea/common/constants/model_keys.dart @@ -177,4 +177,6 @@ class ModelKey { static const String activityRequestCount = "count"; static const String activityRequestNumberOfParticipants = "number_of_participants"; + + static const String autoIGC = "auto_igc"; } diff --git a/lib/pangea/user/models/user_model.dart b/lib/pangea/user/models/user_model.dart index f2c9e98f5..bd71a14d5 100644 --- a/lib/pangea/user/models/user_model.dart +++ b/lib/pangea/user/models/user_model.dart @@ -174,7 +174,7 @@ class UserToolSettings { this.interactiveGrammar = true, this.immersionMode = false, this.definitions = true, - this.autoIGC = true, + this.autoIGC = false, this.enableTTS = true, this.enableAutocorrect = false, }); @@ -187,7 +187,7 @@ class UserToolSettings { json[ToolSetting.interactiveGrammar.toString()] ?? true, immersionMode: false, definitions: json[ToolSetting.definitions.toString()] ?? true, - autoIGC: json[ToolSetting.autoIGC.toString()] ?? true, + autoIGC: json[ModelKey.autoIGC] ?? false, enableTTS: json[ToolSetting.enableTTS.toString()] ?? true, enableAutocorrect: json["enableAutocorrect"] ?? false, ); @@ -198,7 +198,7 @@ class UserToolSettings { data[ToolSetting.interactiveGrammar.toString()] = interactiveGrammar; data[ToolSetting.immersionMode.toString()] = immersionMode; data[ToolSetting.definitions.toString()] = definitions; - data[ToolSetting.autoIGC.toString()] = autoIGC; + data[ModelKey.autoIGC] = autoIGC; data[ToolSetting.enableTTS.toString()] = enableTTS; data["enableAutocorrect"] = enableAutocorrect; return data;