Skip to content

Commit

Permalink
Subtitle always above bar
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed May 17, 2023
1 parent 9424ad0 commit a1b2134
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
6 changes: 4 additions & 2 deletions yuuna/lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// Generated file. Do not edit.
///
/// Locales: 1
/// Strings: 369
/// Strings: 370
///
/// Built on 2023-05-16 at 07:45 UTC
/// Built on 2023-05-17 at 11:06 UTC
// coverage:ignore-file
// ignore_for_file: type=lint
Expand Down Expand Up @@ -383,6 +383,7 @@ class _StringsEn implements BaseTranslations<AppLocale, _StringsEn> {
String get player_option_subtitle_background_opacity => 'Subtitle background opacity';
String get player_option_subtitle_background_blur_radius => 'Subtitle background blur radius';
String get player_option_outline_width => 'Subtitle outline width';
String get player_option_subtitle_always_above_bottom_bar => 'Always show subtitle above bottom bar area';
String get player_subtitles_transcript_empty => 'Transcript is empty.';
String get player_prepare_export => 'Preparing card...';
String get player_change_player_orientation => 'Change Player Orientation';
Expand Down Expand Up @@ -784,6 +785,7 @@ extension on _StringsEn {
case 'player_option_subtitle_background_opacity': return 'Subtitle background opacity';
case 'player_option_subtitle_background_blur_radius': return 'Subtitle background blur radius';
case 'player_option_outline_width': return 'Subtitle outline width';
case 'player_option_subtitle_always_above_bottom_bar': return 'Always show subtitle above bottom bar area';
case 'player_subtitles_transcript_empty': return 'Transcript is empty.';
case 'player_prepare_export': return 'Preparing card...';
case 'player_change_player_orientation': return 'Change Player Orientation';
Expand Down
2 changes: 2 additions & 0 deletions yuuna/lib/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"player_option_subtitle_background_opacity": "Subtitle background opacity",
"player_option_subtitle_background_blur_radius": "Subtitle background blur radius",
"player_option_outline_width": "Subtitle outline width",
"player_option_subtitle_always_above_bottom_bar": "Always show subtitle above bottom bar area",
"player_subtitles_transcript_empty": "Transcript is empty.",
"player_prepare_export": "Preparing card...",
"player_change_player_orientation": "Change Player Orientation",
Expand Down Expand Up @@ -397,6 +398,7 @@
"other": "Retrying in $n seconds..."
}
},

"view_replies": {
"reply": {
"one": "SHOW $n REPLY",
Expand Down
4 changes: 4 additions & 0 deletions yuuna/lib/src/models/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,8 @@ class AppModel with ChangeNotifier {
_preferences.get('subtitle_outline_width', defaultValue: 3.0);
double subtitleBackgroundBlurRadius =
_preferences.get('subtitle_background_blur_radius', defaultValue: 0.0);
bool alwaysAboveBottomBar =
_preferences.get('subtitle_above_bar', defaultValue: false);

return SubtitleOptions(
audioAllowance: audioAllowance,
Expand All @@ -3167,6 +3169,7 @@ class AppModel with ChangeNotifier {
fontName: fontName,
regexFilter: regexFilter,
subtitleOutlineWidth: subtitleOutlineWidth,
alwaysAboveBottomBar: alwaysAboveBottomBar,
);
}

Expand All @@ -3183,6 +3186,7 @@ class AppModel with ChangeNotifier {
_preferences.put('subtitle_outline_width', options.subtitleOutlineWidth);
_preferences.put('subtitle_background_blur_radius',
options.subtitleBackgroundBlurRadius);
_preferences.put('subtitle_above_bar', options.alwaysAboveBottomBar);
}

/// Gets the last used audio index of a given media item.
Expand Down
3 changes: 2 additions & 1 deletion yuuna/lib/src/pages/implementations/player_source_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,8 @@ class _PlayerSourcePageState extends BaseSourcePageState<PlayerSourcePage>
return Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: _isMenuHidden.value
padding: _isMenuHidden.value &&
!_subtitleOptionsNotifier.value.alwaysAboveBottomBar
? const EdgeInsets.only(bottom: 20)
: const EdgeInsets.only(bottom: _menuHeight + 8),
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class _SubtitleOptionsDialogPage
late final TextEditingController _widthController;
late final TextEditingController _blurController;

late ValueNotifier<bool> _aboveBottomBarNotifier;

@override
void initState() {
super.initState();
Expand All @@ -54,6 +56,8 @@ class _SubtitleOptionsDialogPage
TextEditingController(text: _options.subtitleOutlineWidth.toString());
_blurController = TextEditingController(
text: _options.subtitleBackgroundBlurRadius.toString());
_aboveBottomBarNotifier =
ValueNotifier<bool>(_options.alwaysAboveBottomBar);
}

@override
Expand Down Expand Up @@ -329,6 +333,8 @@ class _SubtitleOptionsDialogPage
),
),
const SizedBox(height: 10),
buildAlwaysAboveBottomBar(),
const SizedBox(height: 10),
],
),
),
Expand All @@ -337,6 +343,25 @@ class _SubtitleOptionsDialogPage
);
}

Widget buildAlwaysAboveBottomBar() {
return Row(
children: [
Expanded(child: Text(t.player_option_subtitle_always_above_bottom_bar)),
ValueListenableBuilder<bool>(
valueListenable: _aboveBottomBarNotifier,
builder: (_, value, __) {
return Switch(
value: value,
onChanged: (value) {
_aboveBottomBarNotifier.value = value;
},
);
},
)
],
);
}

Future<void> setValues({required bool saveOptions}) async {
String allowanceText = _allowanceController.text;
int? newAllowance = int.tryParse(allowanceText);
Expand All @@ -359,6 +384,8 @@ class _SubtitleOptionsDialogPage
String blurText = _blurController.text;
double? newBlur = double.tryParse(blurText);

bool newAlwaysAboveBottomBar = _aboveBottomBarNotifier.value;

if (newDelay != null &&
newAllowance != null &&
newFontSize != null &&
Expand Down Expand Up @@ -386,6 +413,7 @@ class _SubtitleOptionsDialogPage
subtitleOptions.subtitleBackgroundOpacity = newOpacity;
subtitleOptions.subtitleOutlineWidth = newWidth;
subtitleOptions.subtitleBackgroundBlurRadius = newBlur;
subtitleOptions.alwaysAboveBottomBar = newAlwaysAboveBottomBar;

widget.notifier.value = subtitleOptions;

Expand Down
4 changes: 4 additions & 0 deletions yuuna/lib/src/utils/player/subtitle_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SubtitleOptions {
required this.regexFilter,
required this.subtitleOutlineWidth,
required this.subtitleBackgroundBlurRadius,
required this.alwaysAboveBottomBar,
});

/// Audio allowance, used for audio export, in milliseconds.
Expand All @@ -35,4 +36,7 @@ class SubtitleOptions {

/// Regex filter used for the subtitle.
String regexFilter;

/// Whether or not the subtitle should always be above the bottom bar.
bool alwaysAboveBottomBar;
}

0 comments on commit a1b2134

Please sign in to comment.