fix(reading_assistance): close word zoom on mode change
This commit is contained in:
parent
448fbbf668
commit
b4c1e1aa54
3 changed files with 39 additions and 40 deletions
|
|
@ -1,13 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -31,6 +25,10 @@ import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/morph_sel
|
|||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_positioner.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/reading_assistance_content.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
/// Controls data at the top level of the toolbar (mainly token / toolbar mode selection)
|
||||
class MessageSelectionOverlay extends StatefulWidget {
|
||||
|
|
@ -311,6 +309,12 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
|
||||
void updateToolbarMode(MessageMode mode) => setState(() {
|
||||
selectedChoice = null;
|
||||
|
||||
// close overlay of any selected token
|
||||
if (_selectedSpan != null) {
|
||||
_updateSelectedSpan(_selectedSpan!);
|
||||
}
|
||||
|
||||
toolbarMode = mode;
|
||||
if (toolbarMode != MessageMode.wordMorph) {
|
||||
selectedMorph = null;
|
||||
|
|
@ -347,11 +351,9 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
}
|
||||
|
||||
void onMorphActivitySelect(MorphSelection newMorph) {
|
||||
if (toolbarMode != MessageMode.wordMorph) {
|
||||
updateToolbarMode(MessageMode.wordMorph);
|
||||
}
|
||||
// close overlay of previous token
|
||||
if (_selectedSpan != null) {
|
||||
toolbarMode = MessageMode.wordMorph;
|
||||
// // close overlay of previous token
|
||||
if (_selectedSpan != null && _selectedSpan != newMorph.token.text) {
|
||||
_updateSelectedSpan(_selectedSpan!);
|
||||
}
|
||||
selectedMorph = newMorph;
|
||||
|
|
|
|||
|
|
@ -19,17 +19,29 @@ class WordZoomActivityButton extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget buttonContent = IconButton(
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
iconSize: 24,
|
||||
color: isSelected ? Theme.of(context).colorScheme.primary : null,
|
||||
visualDensity: VisualDensity.compact,
|
||||
// style: IconButton.styleFrom(
|
||||
// backgroundColor: isSelected
|
||||
// ? Theme.of(context).colorScheme.primary.withValues(alpha: 0.25)
|
||||
// : Colors.transparent,
|
||||
// ),
|
||||
Widget buttonContent = AnimatedSize(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: IconButton(
|
||||
onPressed: onPressed,
|
||||
icon: AnimatedBuilder(
|
||||
animation: Listenable.merge([ValueNotifier(isSelected)]),
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: isSelected ? 1.25 : 1.0,
|
||||
child: icon,
|
||||
);
|
||||
},
|
||||
),
|
||||
iconSize: 24, // Keep this constant as scaling handles the size change
|
||||
color: isSelected ? Theme.of(context).colorScheme.primary : null,
|
||||
visualDensity: VisualDensity.compact,
|
||||
// style: IconButton.styleFrom(
|
||||
// backgroundColor: isSelected
|
||||
// ? Theme.of(context).colorScheme.primary.withValues(alpha: 0.25)
|
||||
// : Colors.transparent,
|
||||
// ),
|
||||
),
|
||||
);
|
||||
|
||||
if (opacity != null) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/morphs/get_grammar_copy.dart';
|
||||
import 'package:fluffychat/pangea/morphs/morph_features_enum.dart';
|
||||
|
|
@ -11,6 +7,8 @@ import 'package:fluffychat/pangea/toolbar/enums/message_mode_enum.dart';
|
|||
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/morph_selection.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/word_zoom_activity_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
class MorphologicalListItem extends StatelessWidget {
|
||||
final MorphFeaturesEnum morphFeature;
|
||||
|
|
@ -52,15 +50,6 @@ class MorphologicalListItem extends StatelessWidget {
|
|||
size: const Size(24, 24),
|
||||
),
|
||||
isSelected: isSelected,
|
||||
// onPressed: shouldDoActivity
|
||||
// ? () => overlayController.updateToolbarMode(MessageMode.wordMorph)
|
||||
// : () => (feature) => showDialog<AnalyticsPopupWrapper>(
|
||||
// context: context,
|
||||
// builder: (context) => AnalyticsPopupWrapper(
|
||||
// constructZoom: token.morphIdByFeature(feature),
|
||||
// view: ConstructTypeEnum.vocab,
|
||||
// ),
|
||||
// ),
|
||||
onPressed: () => overlayController
|
||||
.onMorphActivitySelect(MorphSelection(token, morphFeature)),
|
||||
tooltip: shouldDoActivity
|
||||
|
|
@ -70,11 +59,7 @@ class MorphologicalListItem extends StatelessWidget {
|
|||
lemma: morphTag,
|
||||
context: context,
|
||||
),
|
||||
opacity: isSelected
|
||||
? 1
|
||||
: shouldDoActivity
|
||||
? 0.4
|
||||
: 1,
|
||||
opacity: isSelected ? 1 : 0.7,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue