Skip to content

Commit

Permalink
Fix subtitle not s elected on second press for player
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Jun 7, 2023
1 parent 83a3f2d commit fd17f04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions yuuna/lib/src/pages/implementations/player_source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2036,12 +2036,13 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
clearDictionaryResult();
return;
} else {
_selectableTextController.clearSelection();

String searchTerm = appModel.targetLanguage.getSearchTermFromIndex(
text: text,
index: index,
);

_selectableTextController.clearSelection();
setSearchTerm(
searchTerm: searchTerm,
text: text,
Expand Down Expand Up @@ -2122,7 +2123,6 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
int length = appModel.targetLanguage.getGuessHighlightLength(
searchTerm: searchTerm,
);

_selectableTextController.setSelection(offsetIndex, offsetIndex + length);
if (searchTerm.isNotEmpty) {
dialogSmartPause();
Expand All @@ -2137,7 +2137,6 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
searchTerm: searchTerm,
);

_selectableTextController.setSelection(offsetIndex, offsetIndex + length);
final range = TextRange(start: offsetIndex, end: offsetIndex + length);

source.setCurrentSentence(
Expand All @@ -2146,6 +2145,11 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
range: range,
),
);

Future.delayed(const Duration(milliseconds: 50), () {
_selectableTextController.setSelection(
offsetIndex, offsetIndex + length);
});
});
}

Expand Down

0 comments on commit fd17f04

Please sign in to comment.