Open
Conversation
# Improved color handling in Croppy widget This is a quick suggestion for improving color handling in the Croppy widget, especially for Cupertino components in light mode. ## Key changes: - Added overlayColor parameter to enable theme-based colors for the crop area overlay - Modified the overlay outside the crop area to use scaffoldBackgroundColor with 98% opacity instead of always being dark - Replaced hardcoded colors in Cupertino components with theme-based alternatives - Added color parameters to various components to enable better theming This implementation is just meant as a suggestion since I needed these features for a personal project. The code was implemented quickly and might not be as clean or optimized as it could be, but perhaps it can serve as inspiration for proper implementation. The changes allow the widget to better adapt to different themes, particularly in light mode where the previous dark overlay didn't work well. ### Thank you for creating this excellent package - it's been very helpful in my projects! 🙏 ## Detailed Changes ### lib/src/model/croppable_image_data.dart: - Added overlayColor parameter to copyWith() method to properly preserve theme colors ### lib/src/widgets/common/croppable_image_widget.dart: - Replaced hardcoded black overlay with theme-based overlay color (98% opacity) - Unified fallback colors for consistent appearance in light/dark mode - Changed blend mode to srcOver for better visibility ### lib/src/pages/cupertino_pages.dart: - Increased overlay opacity to 98% for stronger darkening effect - Added theme color extraction from scaffoldBackgroundColor ### lib/src/pages/material_pages.dart: - Set consistent 98% overlay opacity - Added theme color extraction from scaffoldBackgroundColor ### lib/src/widgets/cupertino/default_cupertino_croppable_image_controller.dart: - Added overlayColor propagation when reusing initialData - Fixed data inheritance to maintain theme colors ### lib/src/widgets/material/default_material_croppable_image_controller.dart: - Added overlayColor propagation when reusing initialData - Fixed data inheritance to maintain theme colors ### lib/src/widgets/cupertino/toolbar/cupertino_knob.dart: - Implemented three-state color logic (positive, neutral, negative) - Added semi-transparent background with scaffoldBackgroundColor (50% opacity) - Used primaryColor for positive values and primaryContrastingColor for neutral/negative ### lib/src/widgets/cupertino/toolbar/cupertino_image_transformation_toolbar.dart: - Applied theme-based colors to all sliders (active/inactive states) - Used primaryColor for active state and textStyle color for inactive state - Improved formatting for better readability ### lib/src/widgets/cupertino/handles/cupertino_image_crop_handles.dart: - Applied theme colors to handles and guide lines - Used primaryColor and primaryContrastingColor instead of hardcoded colors - Improved formatting and alignment ### lib/src/widgets/cupertino/toolbar/cupertino_rotation_slider.dart: - Added color parameters for different states - Used theme colors for better visibility and state indication - Applied consistent color scheme with other UI elements ### lib/src/widgets/cupertino/toolbar/cupertino_image_aspect_ratio_toolbar.dart: - Applied theme-based colors for better visibility and consistency - Improved active/inactive state indication - Aligned with overall UI color scheme ### lib/src/widgets/cupertino/theme/cupertino_image_cropper_theme.dart: - Integrated theme-based color handling - Improved compatibility with light/dark mode - Applied consistent color variables throughout theme ### lib/src/widgets/cupertino/icons/*: - Applied uniform theme colors across all icons - Used primaryContrastingColor for consistent appearance - Improved visibility in both light and dark modes ### lib/src/widgets/cupertino/cupertino_image_cropper_app_bar.dart: - Optimized color scheme for app bar icons - Applied theme colors for better visibility - Aligned with bottom app bar styling ### lib/src/widgets/cupertino/cupertino_image_cropper_bottom_app_bar.dart: - Improved color handling for bottom bar elements - Ensured consistency with the rest of the UI - Applied theme-based colors for buttons and icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improved color handling in Croppy widget
This is a quick suggestion for improving color handling in the Croppy widget, especially for Cupertino components in light mode.
Key changes:
Here is an example in light mode before the changes
This implementation is just meant as a suggestion since I needed these features for a personal project. The code was implemented quickly and might not be as clean or optimized as it could be, but perhaps it can serve as inspiration for proper implementation.
The changes allow the widget to better adapt to different themes, particularly in light mode where the previous dark overlay didn't work well.
Thank you for creating this excellent package - it's very helpful for my current project and will be valuable for future projects too! 🙏
Detailed Changes
lib/src/model/croppable_image_data.dart:
lib/src/widgets/common/croppable_image_widget.dart:
lib/src/pages/cupertino_pages.dart:
lib/src/pages/material_pages.dart:
lib/src/widgets/cupertino/default_cupertino_croppable_image_controller.dart:
lib/src/widgets/material/default_material_croppable_image_controller.dart:
lib/src/widgets/cupertino/toolbar/cupertino_knob.dart:
lib/src/widgets/cupertino/toolbar/cupertino_image_transformation_toolbar.dart:
lib/src/widgets/cupertino/handles/cupertino_image_crop_handles.dart:
lib/src/widgets/cupertino/toolbar/cupertino_rotation_slider.dart:
lib/src/widgets/cupertino/toolbar/cupertino_image_aspect_ratio_toolbar.dart:
lib/src/widgets/cupertino/theme/cupertino_image_cropper_theme.dart:
lib/src/widgets/cupertino/icons/*:
lib/src/widgets/cupertino/cupertino_image_cropper_app_bar.dart:
lib/src/widgets/cupertino/cupertino_image_cropper_bottom_app_bar.dart: