refactor: simplify color filter handling in image view
This commit is contained in:
parent
4265ba11fe
commit
a89e1b9ba7
3 changed files with 38 additions and 45 deletions
|
|
@ -27,11 +27,13 @@ class ImageViewPaged extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final scaleType = ref.watch(scaleTypeStateProvider);
|
||||
final image = data.getImageProvider(ref, true);
|
||||
final (colorBlendMode, color) = chapterColorFIlterValues(context, ref);
|
||||
return GestureDetector(
|
||||
onLongPress: () => onLongPressData.call(data),
|
||||
child: ColorFilterWidget(
|
||||
child: ExtendedImage(
|
||||
image: image,
|
||||
colorBlendMode: colorBlendMode,
|
||||
color: color,
|
||||
fit: getBoxFit(scaleType),
|
||||
filterQuality: FilterQuality.medium,
|
||||
mode: ExtendedImageMode.gesture,
|
||||
|
|
@ -39,7 +41,6 @@ class ImageViewPaged extends ConsumerWidget {
|
|||
loadStateChanged: loadStateChanged,
|
||||
initGestureConfigHandler: initGestureConfigHandler,
|
||||
onDoubleTap: onDoubleTap),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ class ImageViewVertical extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final (colorBlendMode, color) = chapterColorFIlterValues(context, ref);
|
||||
final imageWidget = ExtendedImage(
|
||||
colorBlendMode: colorBlendMode,
|
||||
color: color,
|
||||
image: data.getImageProvider(ref, true),
|
||||
filterQuality: FilterQuality.medium,
|
||||
handleLoadingProgress: true,
|
||||
|
|
@ -92,7 +95,6 @@ class ImageViewVertical extends ConsumerWidget {
|
|||
});
|
||||
return GestureDetector(
|
||||
onLongPress: () => onLongPressData.call(data),
|
||||
child: ColorFilterWidget(
|
||||
child: isHorizontal
|
||||
? imageWidget
|
||||
: Column(
|
||||
|
|
@ -105,7 +107,6 @@ class ImageViewVertical extends ConsumerWidget {
|
|||
imageWidget
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,27 +6,18 @@ import 'package:mangayomi/modules/manga/reader/providers/color_filter_provider.d
|
|||
import 'package:mangayomi/modules/more/settings/reader/reader_screen.dart';
|
||||
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
||||
|
||||
class ColorFilterWidget extends ConsumerWidget {
|
||||
final Widget child;
|
||||
const ColorFilterWidget({super.key, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
(BlendMode?, Color?) chapterColorFIlterValues(
|
||||
BuildContext context, WidgetRef ref) {
|
||||
final customColorFilter = ref.watch(customColorFilterStateProvider);
|
||||
final colorFilterBlendMode = ref.watch(colorFilterBlendModeStateProvider);
|
||||
return Container(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
backgroundBlendMode:
|
||||
return (
|
||||
getColorFilterBlendMode(colorFilterBlendMode, context),
|
||||
color: customColorFilter == null
|
||||
customColorFilter == null
|
||||
? Colors.transparent
|
||||
: Color.fromARGB(customColorFilter.a ?? 0, customColorFilter.r ?? 0,
|
||||
customColorFilter.g ?? 0, customColorFilter.b ?? 0),
|
||||
),
|
||||
child: child,
|
||||
customColorFilter.g ?? 0, customColorFilter.b ?? 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget customColorFilterListTile(String label, int value,
|
||||
void Function((double, bool, String))? onChanged, BuildContext context) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue