buildCaptionFilterButton method

Widget buildCaptionFilterButton(
  1. {required BuildContext context,
  2. required WidgetRef ref,
  3. required AppModel appModel}
)

Allows user to toggle whether or not to filter for videos with closed captions.

Implementation

Widget buildCaptionFilterButton({
  required BuildContext context,
  required WidgetRef ref,
  required AppModel appModel,
}) {
  ValueNotifier<bool> notifier = ValueNotifier<bool>(isCaptionFilterOn);

  return FloatingSearchBarAction(
    showIfOpened: true,
    showIfClosed: false,
    child: ValueListenableBuilder<bool>(
      valueListenable: notifier,
      builder: (context, value, child) {
        return JidoujishoIconButton(
          size: Theme.of(context).textTheme.titleLarge?.fontSize,
          tooltip: t.caption_filter,
          enabledColor: value ? Colors.red : null,
          icon: Icons.closed_caption,
          onTap: () {
            toggleCaptionFilter();
            notifier.value = !value;
          },
        );
      },
    ),
  );
}