From 59f247d674102db8b6cf255c00de4c0e5baff513 Mon Sep 17 00:00:00 2001 From: hm21 Date: Tue, 21 Jan 2025 17:04:17 +0100 Subject: [PATCH] docs(editors): improve documentation comments in editor components --- lib/core/mixins/standalone_editor.dart | 9 ++- lib/core/models/layers/text_layer.dart | 8 ++- .../multi_threading/thread_request_model.dart | 11 ++++ .../widgets/blur_editor_appbar.dart | 23 ++++++- .../widgets/blur_editor_bottombar.dart | 41 ++++++++++++- .../crop_rotate_editor.dart | 2 +- .../widgets/crop_editor_appbar.dart | 39 ++++++++++++ .../widgets/crop_editor_bottombar.dart | 28 +++++++++ .../widgets/filter_editor_appbar.dart | 15 +++++ lib/features/main_editor/main_editor.dart | 2 +- .../main_editor_state_history_service.dart | 22 +++++++ .../widgets/main_editor_appbar.dart | 41 +++++++++++-- .../widgets/main_editor_background_image.dart | 24 ++++++++ .../widgets/main_editor_bottombar.dart | 43 +++++++++++++ .../widgets/main_editor_font_preloader.dart | 10 +++ .../widgets/main_editor_helper_lines.dart | 22 +++++++ .../main_editor_interactive_content.dart | 58 ++++++++++++++++-- .../widgets/main_editor_layers.dart | 61 +++++++++++++++++-- .../main_editor_remove_layer_area.dart | 30 ++++++++- .../widgets/paint_editor_appbar.dart | 52 ++++++++++++++++ .../widgets/paint_editor_bottombar.dart | 33 +++++++++- .../widgets/paint_editor_color_picker.dart | 16 +++++ .../widgets/text_editor_appbar.dart | 35 +++++++++++ .../widgets/text_editor_color_picker.dart | 29 +++++++++ .../widgets/text_editor_input.dart | 37 +++++++++++ .../widgets/tune_editor_appbar.dart | 27 ++++++++ .../widgets/tune_editor_bottombar.dart | 29 +++++++++ .../content_recorder_controller.dart | 13 +--- lib/shared/widgets/slider_bottom_sheet.dart | 44 +++++++++++++ 29 files changed, 766 insertions(+), 38 deletions(-) diff --git a/lib/core/mixins/standalone_editor.dart b/lib/core/mixins/standalone_editor.dart index bcd65ac8..b5e004be 100644 --- a/lib/core/mixins/standalone_editor.dart +++ b/lib/core/mixins/standalone_editor.dart @@ -210,10 +210,15 @@ mixin StandaloneEditorState uiBlurStream; + + /// Stream controller to handle rebuild events. + final StreamController rebuildController; + + /// The factor by which the blur effect is applied. + final double blurFactor; + + /// Callback function that is called when the blur value changes. + /// + /// [value] The new blur value. final Function(double value) onChanged; + + /// Callback function that is called when the blur value change ends. + /// + /// [value] The final blur value. final Function(double value) onChangedEnd; - final double blurFactor; - final StreamController rebuildController; - final BlurEditorState blurEditorState; @override Widget build(BuildContext context) { diff --git a/lib/features/crop_rotate_editor/crop_rotate_editor.dart b/lib/features/crop_rotate_editor/crop_rotate_editor.dart index 7d7f2288..37aa70f7 100644 --- a/lib/features/crop_rotate_editor/crop_rotate_editor.dart +++ b/lib/features/crop_rotate_editor/crop_rotate_editor.dart @@ -805,7 +805,7 @@ class CropRotateEditorState extends State ? initialTransformConfigs! : activeHistory; - screenshotCtrl.capture( + await screenshotCtrl.capture( imageInfos: imageInfos!, screenshots: screenshotHistory, targetSize: _rotated90deg diff --git a/lib/features/crop_rotate_editor/widgets/crop_editor_appbar.dart b/lib/features/crop_rotate_editor/widgets/crop_editor_appbar.dart index a3d846eb..677b3a71 100644 --- a/lib/features/crop_rotate_editor/widgets/crop_editor_appbar.dart +++ b/lib/features/crop_rotate_editor/widgets/crop_editor_appbar.dart @@ -3,7 +3,31 @@ import 'package:flutter/material.dart'; import '../../../core/models/editor_configs/crop_rotate_editor_configs.dart'; import '../../../core/models/i18n/i18n_crop_rotate_editor.dart'; +/// A custom app bar widget for the crop editor screen. +/// +/// This widget provides an app bar with various controls for the crop editor, +/// including undo, redo, and done actions. +/// +/// Implements [PreferredSizeWidget] to specify the preferred size of the app +/// bar. +/// +/// Parameters: +/// - `configs`: Configuration settings for the crop editor. +/// - `i18n`: Internationalization settings for localization. +/// - `enableCloseButton`: A boolean flag to enable or disable the close button. +/// - `canUndo`: A boolean flag indicating if the undo action is available. +/// - `canRedo`: A boolean flag indicating if the redo action is available. +/// - `onDone`: Callback function to be executed when the done action is +/// triggered. +/// - `onClose`: Callback function to be executed when the close action is +/// triggered. +/// - `onUndo`: Callback function to be executed when the undo action is +/// triggered. +/// - `onRedo`: Callback function to be executed when the redo action is +/// triggered. class CropEditorAppbar extends StatelessWidget implements PreferredSizeWidget { + /// Creates an instance of `CropEditorAppbar`, a custom `AppBar` for the Blur + /// Editor UI. const CropEditorAppbar({ super.key, required this.configs, @@ -17,16 +41,31 @@ class CropEditorAppbar extends StatelessWidget implements PreferredSizeWidget { required this.onRedo, }); + /// Configuration settings for the crop and rotate editor. final CropRotateEditorConfigs configs; + + /// Internationalization settings for the crop and rotate editor. final I18nCropRotateEditor i18n; + /// Indicates whether the close button is enabled. final bool enableCloseButton; + + /// Indicates whether the undo action is available. final bool canUndo; + + /// Indicates whether the redo action is available. final bool canRedo; + /// Callback function to be executed when the done action is triggered. final Function() onDone; + + /// Callback function to be executed when the close action is triggered. final Function() onClose; + + /// Callback function to be executed when the undo action is triggered. final Function() onUndo; + + /// Callback function to be executed when the redo action is triggered. final Function() onRedo; @override diff --git a/lib/features/crop_rotate_editor/widgets/crop_editor_bottombar.dart b/lib/features/crop_rotate_editor/widgets/crop_editor_bottombar.dart index c1d77a8d..ec065302 100644 --- a/lib/features/crop_rotate_editor/widgets/crop_editor_bottombar.dart +++ b/lib/features/crop_rotate_editor/widgets/crop_editor_bottombar.dart @@ -4,7 +4,21 @@ import 'package:flutter/material.dart'; import 'package:pro_image_editor/core/models/editor_configs/pro_image_editor_configs.dart'; import 'package:pro_image_editor/shared/widgets/flat_icon_text_button.dart'; +/// A widget representing the bottom bar for the crop editor, providing +/// options like rotate, flip, aspect ratio, and reset. class CropEditorBottombar extends StatelessWidget { + /// Creates a `CropEditorBottombar` with the provided configurations and + /// callbacks. + /// + /// - [bottomBarScrollCtrl]: Controls the scroll behavior of the bottom bar. + /// - [i18n]: Provides localized strings for tooltips and labels. + /// - [configs]: Contains configurations for the crop and rotate editor. + /// - [theme]: Defines the theme to style the bottom bar. + /// - [onRotate]: Callback invoked when the rotate option is selected. + /// - [onFlip]: Callback invoked when the flip option is selected. + /// - [onOpenAspectRatioOptions]: Callback invoked when the aspect ratio + /// options are opened. + /// - [onReset]: Callback invoked when the reset option is selected. const CropEditorBottombar({ super.key, required this.bottomBarScrollCtrl, @@ -17,14 +31,28 @@ class CropEditorBottombar extends StatelessWidget { required this.onReset, }); + /// Controls the scroll behavior of the bottom bar. final ScrollController bottomBarScrollCtrl; + + /// Provides localized strings for tooltips and labels. final I18nCropRotateEditor i18n; + + /// Configurations for the crop and rotate editor. final CropRotateEditorConfigs configs; + + /// Theme data for styling the bottom bar. final ThemeData theme; + /// Callback for the rotate option. final Function() onRotate; + + /// Callback for the flip option. final Function() onFlip; + + /// Callback for opening the aspect ratio options. final Function() onOpenAspectRatioOptions; + + /// Callback for resetting the editor. final Function() onReset; @override diff --git a/lib/features/filter_editor/widgets/filter_editor_appbar.dart b/lib/features/filter_editor/widgets/filter_editor_appbar.dart index de8bb15f..88533c1f 100644 --- a/lib/features/filter_editor/widgets/filter_editor_appbar.dart +++ b/lib/features/filter_editor/widgets/filter_editor_appbar.dart @@ -3,8 +3,15 @@ import 'package:flutter/material.dart'; import '/core/models/editor_configs/filter_editor_configs.dart'; import '/core/models/i18n/i18n_filter_editor.dart'; +/// A custom AppBar for the Filter Editor, providing close and apply options. class FilterEditorAppBar extends StatelessWidget implements PreferredSizeWidget { + /// Creates a `FilterEditorAppBar` with the provided configurations. + /// + /// - [filterEditorConfigs]: Configurations for styling and behavior. + /// - [i18n]: Localization for tooltips and labels. + /// - [close]: Callback for closing the editor. + /// - [done]: Callback for applying changes. const FilterEditorAppBar({ super.key, required this.filterEditorConfigs, @@ -12,9 +19,17 @@ class FilterEditorAppBar extends StatelessWidget required this.close, required this.done, }); + + /// Configurations for styling and behavior. final FilterEditorConfigs filterEditorConfigs; + + /// Localization for tooltips and labels. final I18nFilterEditor i18n; + + /// Callback for closing the editor. final Function() close; + + /// Callback for applying changes. final Function() done; @override diff --git a/lib/features/main_editor/main_editor.dart b/lib/features/main_editor/main_editor.dart index e9b63b11..c66a091a 100644 --- a/lib/features/main_editor/main_editor.dart +++ b/lib/features/main_editor/main_editor.dart @@ -1634,7 +1634,7 @@ class ProImageEditorState extends State if (!mounted) return; - _controllers.screenshot.capture( + await _controllers.screenshot.capture( imageInfos: _imageInfos!, screenshots: stateManager.screenshots, ); diff --git a/lib/features/main_editor/services/main_editor_state_history_service.dart b/lib/features/main_editor/services/main_editor_state_history_service.dart index 27845256..876d530a 100644 --- a/lib/features/main_editor/services/main_editor_state_history_service.dart +++ b/lib/features/main_editor/services/main_editor_state_history_service.dart @@ -16,7 +16,18 @@ import '../controllers/main_editor_controllers.dart'; import 'sizes_manager.dart'; import 'state_manager.dart'; +/// A service to manage the state history of the main editor, including +/// screenshots and size configurations. class MainEditorStateHistoryService { + /// Creates a `MainEditorStateHistoryService` with the provided configurations + /// and dependencies. + /// + /// - [configs]: Configuration settings for the main editor. + /// - [takeScreenshot]: Callback for capturing a screenshot of the editor. + /// - [sizesManager]: Manages size-related settings and adjustments. + /// - [stateManager]: Handles state changes and history management. + /// - [controllers]: Contains the controllers for managing editor behaviors. + /// - [mainEditorCallbacks]: Optional callbacks for additional editor actions. MainEditorStateHistoryService({ required this.configs, required this.takeScreenshot, @@ -25,12 +36,23 @@ class MainEditorStateHistoryService { required this.controllers, required this.mainEditorCallbacks, }); + + /// Manages size-related settings and adjustments. final SizesManager sizesManager; + + /// Handles state changes and history management. final StateManager stateManager; + + /// Contains the controllers for managing editor behaviors. final MainEditorControllers controllers; + + /// Configuration settings for the main editor. final ProImageEditorConfigs configs; + + /// Optional callbacks for additional editor actions. final MainEditorCallbacks? mainEditorCallbacks; + /// Callback for capturing a screenshot of the editor. final Function() takeScreenshot; /// Imports state history and performs necessary recalculations. diff --git a/lib/features/main_editor/widgets/main_editor_appbar.dart b/lib/features/main_editor/widgets/main_editor_appbar.dart index adee0897..75f998a1 100644 --- a/lib/features/main_editor/widgets/main_editor_appbar.dart +++ b/lib/features/main_editor/widgets/main_editor_appbar.dart @@ -4,7 +4,20 @@ import '/core/models/editor_configs/pro_image_editor_configs.dart'; import '/shared/widgets/platform/platform_circular_progress_indicator.dart'; import '../services/state_manager.dart'; +/// A custom AppBar for the main editor, providing actions for closing, +/// undoing, redoing, and completing editing tasks. class MainEditorAppBar extends StatelessWidget implements PreferredSizeWidget { + /// Creates a `MainEditorAppBar` with the given configurations and actions. + /// + /// - [i18n]: Localization for tooltips and labels. + /// - [configs]: Configuration settings for the editor. + /// - [closeEditor]: Callback for closing the editor. + /// - [undoAction]: Callback for undoing the last action. + /// - [redoAction]: Callback for redoing the last undone action. + /// - [doneEditing]: Callback for applying changes and completing editing. + /// - [isInitialized]: Indicates whether the editor has been fully + /// initialized. + /// - [stateManager]: Manages the editor's state. const MainEditorAppBar({ super.key, required this.i18n, @@ -17,17 +30,35 @@ class MainEditorAppBar extends StatelessWidget implements PreferredSizeWidget { required this.stateManager, }); - final bool isInitialized; + /// Localization for tooltips and labels. final I18n i18n; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; + + /// Manages the editor's state. + final StateManager stateManager; + + /// Retrieves the main editor's specific configurations. + MainEditorConfigs get mainEditorConfigs => configs.mainEditor; + + /// Determines the foreground color for the AppBar. + Color get foregroundColor => mainEditorConfigs.style.appBarColor; + + /// Indicates whether the editor has been fully initialized. + final bool isInitialized; + + /// Callback for closing the editor. final Function() closeEditor; + + /// Callback for undoing the last action. final Function() undoAction; + + /// Callback for redoing the last undone action. final Function() redoAction; - final Function() doneEditing; - Color get foregroundColor => mainEditorConfigs.style.appBarColor; - MainEditorConfigs get mainEditorConfigs => configs.mainEditor; - final StateManager stateManager; + /// Callback for applying changes and completing editing. + final Function() doneEditing; @override Widget build(BuildContext context) { diff --git a/lib/features/main_editor/widgets/main_editor_background_image.dart b/lib/features/main_editor/widgets/main_editor_background_image.dart index 9bab1496..80c28894 100644 --- a/lib/features/main_editor/widgets/main_editor_background_image.dart +++ b/lib/features/main_editor/widgets/main_editor_background_image.dart @@ -9,7 +9,20 @@ import '/shared/widgets/transform/transformed_content_generator.dart'; import '../services/sizes_manager.dart'; import '../services/state_manager.dart'; +/// A widget for displaying the background image in the main editor, +/// supporting color filters and size configurations. class MainEditorBackgroundImage extends StatelessWidget { + /// Creates a `MainEditorBackgroundImage` with the provided configurations + /// and dependencies. + /// + /// - [stateManager]: Manages the state of the editor. + /// - [sizesManager]: Handles size configurations and adjustments. + /// - [configs]: The editor's configuration settings. + /// - [editorImage]: The main image being edited. + /// - [backgroundImageColorFilterKey]: A key for applying color filters + /// to the background image. + /// - [isInitialized]: Indicates whether the editor has been fully + /// initialized. const MainEditorBackgroundImage({ super.key, required this.stateManager, @@ -20,11 +33,22 @@ class MainEditorBackgroundImage extends StatelessWidget { required this.isInitialized, }); + /// The main image being edited in the editor. final EditorImage editorImage; + + /// Manages the state of the editor. final StateManager stateManager; + + /// Handles size configurations and adjustments. final SizesManager sizesManager; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; + + /// A key for managing the color filter applied to the background image. final GlobalKey backgroundImageColorFilterKey; + + /// Indicates whether the editor has been fully initialized. final bool isInitialized; @override diff --git a/lib/features/main_editor/widgets/main_editor_bottombar.dart b/lib/features/main_editor/widgets/main_editor_bottombar.dart index 7fb6c078..e3b41d0c 100644 --- a/lib/features/main_editor/widgets/main_editor_bottombar.dart +++ b/lib/features/main_editor/widgets/main_editor_bottombar.dart @@ -7,7 +7,26 @@ import '/shared/widgets/flat_icon_text_button.dart'; import '../controllers/main_editor_controllers.dart'; import '../services/sizes_manager.dart'; +/// A widget representing the bottom bar for the main editor, providing access +/// to various editing tools like paint, text, crop, filters, and more. class MainEditorBottombar extends StatelessWidget { + /// Creates a `MainEditorBottombar` with the provided configurations, + /// controllers, + /// and callbacks for opening different editor tools. + /// + /// - [controllers]: Manages the main editor's controllers. + /// - [configs]: Configuration settings for the editor. + /// - [sizesManager]: Handles size-related settings for the bottom bar. + /// - [bottomBarKey]: A unique key for managing the bottom bar widget's state. + /// - [theme]: The theme data for styling the bottom bar. + /// - [openPaintEditor]: Callback for opening the paint editor. + /// - [openTextEditor]: Callback for opening the text editor. + /// - [openCropRotateEditor]: Callback for opening the crop and rotate editor. + /// - [openTuneEditor]: Callback for opening the tuning editor. + /// - [openFilterEditor]: Callback for opening the filter editor. + /// - [openBlurEditor]: Callback for opening the blur editor. + /// - [openEmojiEditor]: Callback for opening the emoji editor. + /// - [openStickerEditor]: Callback for opening the sticker editor. const MainEditorBottombar({ super.key, required this.controllers, @@ -25,19 +44,43 @@ class MainEditorBottombar extends StatelessWidget { required this.openStickerEditor, }); + /// Manages the main editor's controllers. final MainEditorControllers controllers; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; + + /// Handles size-related settings for the bottom bar. final SizesManager sizesManager; + + /// A unique key for managing the bottom bar widget's state. final GlobalKey> bottomBarKey; + + /// The theme data for styling the bottom bar. final ThemeData theme; + /// Callback for opening the paint editor. final Function() openPaintEditor; + + /// Callback for opening the text editor. final Function() openTextEditor; + + /// Callback for opening the crop and rotate editor. final Function() openCropRotateEditor; + + /// Callback for opening the tuning editor. final Function() openTuneEditor; + + /// Callback for opening the filter editor. final Function() openFilterEditor; + + /// Callback for opening the blur editor. final Function() openBlurEditor; + + /// Callback for opening the emoji editor. final Function() openEmojiEditor; + + /// Callback for opening the sticker editor. final Function() openStickerEditor; final double _bottomIconSize = 22.0; diff --git a/lib/features/main_editor/widgets/main_editor_font_preloader.dart b/lib/features/main_editor/widgets/main_editor_font_preloader.dart index 39afe1da..3201f7c5 100644 --- a/lib/features/main_editor/widgets/main_editor_font_preloader.dart +++ b/lib/features/main_editor/widgets/main_editor_font_preloader.dart @@ -2,12 +2,22 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:pro_image_editor/core/models/editor_configs/emoji_editor_configs.dart'; +/// A widget responsible for preloading fonts for the main editor, +/// ensuring smooth rendering of text and emoji elements. class MainEditorFontPreloader extends StatelessWidget { + /// Creates a `MainEditorFontPreloader` with the provided emoji editor + /// configurations. + /// + /// - [emojiEditorConfigs]: Configuration settings related to the emoji + /// editor, + /// which include font settings and other necessary configurations. const MainEditorFontPreloader({ super.key, required this.emojiEditorConfigs, }); + /// Configuration settings related to the emoji editor, including font + /// details. final EmojiEditorConfigs emojiEditorConfigs; @override diff --git a/lib/features/main_editor/widgets/main_editor_helper_lines.dart b/lib/features/main_editor/widgets/main_editor_helper_lines.dart index 3d055c88..0949f34e 100644 --- a/lib/features/main_editor/widgets/main_editor_helper_lines.dart +++ b/lib/features/main_editor/widgets/main_editor_helper_lines.dart @@ -6,7 +6,18 @@ import '../controllers/main_editor_controllers.dart'; import '../services/layer_interaction_manager.dart'; import '../services/sizes_manager.dart'; +/// A widget that displays helper lines in the main editor to assist with +/// alignment and positioning of elements. class MainEditorHelperLines extends StatelessWidget { + /// Creates a `MainEditorHelperLines` widget with the necessary managers, + /// controllers, and configurations. + /// + /// - [sizesManager]: Manages size-related settings and adjustments. + /// - [layerInteractionManager]: Handles interactions with editor layers. + /// - [controllers]: Manages the main editor's controllers. + /// - [interactiveViewer]: A key for managing the interactive viewer state. + /// - [helperLines]: Configurations for displaying helper lines. + /// - [configs]: Configuration settings for the editor. const MainEditorHelperLines({ super.key, required this.sizesManager, @@ -17,11 +28,22 @@ class MainEditorHelperLines extends StatelessWidget { required this.configs, }); + /// Manages size-related settings and adjustments. final SizesManager sizesManager; + + /// Handles interactions with editor layers. final LayerInteractionManager layerInteractionManager; + + /// Manages the main editor's controllers. final MainEditorControllers controllers; + + /// A key for managing the interactive viewer state. final GlobalKey interactiveViewer; + + /// Configurations for displaying helper lines. final HelperLineConfigs helperLines; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; final double _lineHeight = 1.25; diff --git a/lib/features/main_editor/widgets/main_editor_interactive_content.dart b/lib/features/main_editor/widgets/main_editor_interactive_content.dart index dcf339f5..b02a29e3 100644 --- a/lib/features/main_editor/widgets/main_editor_interactive_content.dart +++ b/lib/features/main_editor/widgets/main_editor_interactive_content.dart @@ -14,7 +14,29 @@ import '../services/sizes_manager.dart'; import '../services/state_manager.dart'; import 'main_editor_font_preloader.dart'; +/// A widget representing the interactive content area of the main editor, +/// including layers, helper lines, and editing interactions. class MainEditorInteractiveContent extends StatelessWidget { + /// Creates a `MainEditorInteractiveContent` widget with the provided + /// builders, managers, configurations, and callbacks. + /// + /// - [buildImage]: A builder function to create the image widget. + /// - [buildLayers]: A builder function to create the layer widgets. + /// - [buildHelperLines]: A builder function to create the helper lines + /// widget. + /// - [buildRemoveIcon]: A builder function to create the remove icon widget. + /// - [stateManager]: Manages the state of the editor. + /// - [sizesManager]: Handles size-related settings and adjustments. + /// - [state]: Represents the current state of the editor. + /// - [configs]: Configuration settings for the editor. + /// - [callbacks]: Provides callbacks for editor interactions. + /// - [controllers]: Manages the main editor's controllers. + /// - [layerInteractionManager]: Handles interactions with editor layers. + /// - [rebuildController]: A stream controller for triggering UI rebuilds. + /// - [interactiveViewerKey]: A key for managing the interactive viewer state. + /// - [selectedLayerIndex]: The index of the currently selected layer. + /// - [processFinalImage]: Indicates whether the final image is being + /// processed. const MainEditorInteractiveContent({ super.key, required this.buildImage, @@ -34,23 +56,51 @@ class MainEditorInteractiveContent extends StatelessWidget { required this.state, }); + /// A builder function to create the image widget. final Widget Function() buildImage; + + /// A builder function to create the layer widgets. final Widget Function() buildLayers; + + /// A builder function to create the helper lines widget. final Widget Function() buildHelperLines; + + /// A builder function to create the remove icon widget. final Widget Function() buildRemoveIcon; + /// Manages the state of the editor. + final StateManager stateManager; + + /// Handles size-related settings and adjustments. final SizesManager sizesManager; + + /// Represents the current state of the editor. final ProImageEditorState state; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; + + /// Provides callbacks for editor interactions. final ProImageEditorCallbacks callbacks; - final LayerInteractionManager layerInteractionManager; + + /// Manages the main editor's controllers. final MainEditorControllers controllers; - final int selectedLayerIndex; - final bool processFinalImage; + + /// Handles interactions with editor layers. + final LayerInteractionManager layerInteractionManager; + + /// A stream controller for triggering UI rebuilds. final StreamController rebuildController; - final StateManager stateManager; + + /// A key for managing the interactive viewer state. final GlobalKey interactiveViewerKey; + /// The index of the currently selected layer. + final int selectedLayerIndex; + + /// Indicates whether the final image is being processed. + final bool processFinalImage; + @override Widget build(BuildContext context) { return Center( diff --git a/lib/features/main_editor/widgets/main_editor_layers.dart b/lib/features/main_editor/widgets/main_editor_layers.dart index 25ab02c8..6e74441c 100644 --- a/lib/features/main_editor/widgets/main_editor_layers.dart +++ b/lib/features/main_editor/widgets/main_editor_layers.dart @@ -12,7 +12,29 @@ import '/shared/widgets/extended/extended_mouse_cursor.dart'; import '/shared/widgets/layer/layer_widget.dart'; import '../main_editor.dart'; +/// A widget that manages and displays layers in the main editor, handling +/// interactions, configurations, and callbacks for user actions. class MainEditorLayers extends StatelessWidget { + /// Creates a `MainEditorLayers` widget with the necessary configurations, + /// managers, and callbacks. + /// + /// - [state]: Represents the current state of the editor. + /// - [configs]: Configuration settings for the editor. + /// - [callbacks]: Provides callbacks for editor interactions. + /// - [sizesManager]: Manages size-related settings and adjustments. + /// - [controllers]: Manages the main editor's controllers. + /// - [layerInteraction]: Configurations for layer interactions. + /// - [layerInteractionManager]: Handles interactions with editor layers. + /// - [mouseCursorsKey]: Key for managing mouse cursor regions. + /// - [activeLayers]: List of active layers in the editor. + /// - [selectedLayerIndex]: The index of the currently selected layer. + /// - [isSubEditorOpen]: Indicates whether a sub-editor is currently open. + /// - [checkInteractiveViewer]: Callback to check the state of the + /// interactive viewer. + /// - [onTextLayerTap]: Callback triggered when a text layer is tapped. + /// - [setTempLayer]: Callback to temporarily set a layer for interaction. + /// - [onContextMenuToggled]: Callback triggered when the context menu is + /// toggled. const MainEditorLayers({ super.key, required this.controllers, @@ -32,20 +54,49 @@ class MainEditorLayers extends StatelessWidget { required this.onContextMenuToggled, }); - final MainEditorControllers controllers; - final LayerInteractionConfigs layerInteraction; - final LayerInteractionManager layerInteractionManager; + /// Represents the current state of the editor. + final ProImageEditorState state; + + /// Configuration settings for the editor. final ProImageEditorConfigs configs; + + /// Provides callbacks for editor interactions. final ProImageEditorCallbacks callbacks; + + /// Manages size-related settings and adjustments. final SizesManager sizesManager; + + /// Manages the main editor's controllers. + final MainEditorControllers controllers; + + /// Configurations for layer interactions. + final LayerInteractionConfigs layerInteraction; + + /// Handles interactions with editor layers. + final LayerInteractionManager layerInteractionManager; + + /// Key for managing mouse cursor regions. final GlobalKey mouseCursorsKey; - final int selectedLayerIndex; + + /// List of active layers in the editor. final List activeLayers; + + /// The index of the currently selected layer. + final int selectedLayerIndex; + + /// Indicates whether a sub-editor is currently open. final bool isSubEditorOpen; - final ProImageEditorState state; + + /// Callback to check the state of the interactive viewer. final Function() checkInteractiveViewer; + + /// Callback triggered when a text layer is tapped. final Function(TextLayer layer) onTextLayerTap; + + /// Callback to temporarily set a layer for interaction. final Function(Layer layer) setTempLayer; + + /// Callback triggered when the context menu is toggled. final Function(bool isOpen)? onContextMenuToggled; // Helper methods for handling layer interactions diff --git a/lib/features/main_editor/widgets/main_editor_remove_layer_area.dart b/lib/features/main_editor/widgets/main_editor_remove_layer_area.dart index e5bd8392..97e47d1d 100644 --- a/lib/features/main_editor/widgets/main_editor_remove_layer_area.dart +++ b/lib/features/main_editor/widgets/main_editor_remove_layer_area.dart @@ -6,7 +6,20 @@ import '../controllers/main_editor_controllers.dart'; import '../main_editor.dart'; import '../services/layer_interaction_manager.dart'; +/// A widget that defines the area for removing layers in the main editor, +/// facilitating interactions for deleting layers by dragging them into this +/// area. class MainEditorRemoveLayerArea extends StatelessWidget { + /// Creates a `MainEditorRemoveLayerArea` widget with the necessary managers, + /// configurations, and state. + /// + /// - [state]: Represents the current state of the editor. + /// - [mainEditorConfigs]: Configuration settings for the main editor. + /// - [controllers]: Manages the main editor's controllers. + /// - [layerInteraction]: Configurations for layer interactions. + /// - [layerInteractionManager]: Handles layer interaction logic. + /// - [removeAreaKey]: Key for identifying and managing the remove area + /// widget. const MainEditorRemoveLayerArea({ super.key, required this.layerInteraction, @@ -17,12 +30,23 @@ class MainEditorRemoveLayerArea extends StatelessWidget { required this.removeAreaKey, }); - final LayerInteractionConfigs layerInteraction; - final LayerInteractionManager layerInteractionManager; + /// Represents the current state of the editor. + final ProImageEditorState state; + + /// Configuration settings for the main editor. final MainEditorConfigs mainEditorConfigs; + + /// Manages the main editor's controllers. final MainEditorControllers controllers; + + /// Configurations for layer interactions. + final LayerInteractionConfigs layerInteraction; + + /// Handles logic for interacting with layers. + final LayerInteractionManager layerInteractionManager; + + /// Key for identifying and managing the remove area widget. final GlobalKey> removeAreaKey; - final ProImageEditorState state; @override Widget build(BuildContext context) { diff --git a/lib/features/paint_editor/widgets/paint_editor_appbar.dart b/lib/features/paint_editor/widgets/paint_editor_appbar.dart index 03d00e01..b4286ce5 100644 --- a/lib/features/paint_editor/widgets/paint_editor_appbar.dart +++ b/lib/features/paint_editor/widgets/paint_editor_appbar.dart @@ -3,7 +3,31 @@ import 'package:flutter/material.dart'; import '/core/models/editor_configs/pro_image_editor_configs.dart'; import '/shared/widgets/platform/platform_popup_menu.dart'; +/// A custom AppBar for the paint editor, providing controls for undo, redo, +/// toggling fill mode, and accessing additional settings like opacity and +/// line weight. class PaintEditorAppBar extends StatelessWidget implements PreferredSizeWidget { + /// Creates a `PaintEditorAppBar` with the provided configurations, + /// constraints, and callbacks for various actions. + /// + /// - [paintEditorConfigs]: Configuration settings for the paint editor's + /// appearance. + /// - [i18n]: Localization strings for tooltips and labels. + /// - [constraints]: Box constraints for responsive layout adjustments. + /// - [designMode]: Indicates the current design mode of the editor. + /// - [canUndo]: Whether undo action is currently available. + /// - [canRedo]: Whether redo action is currently available. + /// - [isFillMode]: Whether fill mode is currently enabled. + /// - [onTapMenuFill]: Callback triggered when the fill menu is tapped. + /// - [onUndo]: Callback triggered for undoing the last action. + /// - [onRedo]: Callback triggered for redoing the last undone action. + /// - [onToggleFill]: Callback triggered for toggling fill mode. + /// - [onDone]: Callback triggered for completing the paint editing session. + /// - [onClose]: Callback triggered for closing the paint editor. + /// - [onOpenOpacityBottomSheet]: Callback triggered to open the opacity + /// settings. + /// - [onOpenLineWeightBottomSheet]: Callback triggered to open the line + /// weight settings. const PaintEditorAppBar({ super.key, required this.paintEditorConfigs, @@ -22,22 +46,50 @@ class PaintEditorAppBar extends StatelessWidget implements PreferredSizeWidget { required this.isFillMode, required this.designMode, }); + + /// Configuration settings for the paint editor's appearance. final PaintEditorConfigs paintEditorConfigs; + + /// Localization strings for tooltips and labels. final I18nPaintEditor i18n; + + /// Box constraints for responsive layout adjustments. final BoxConstraints constraints; + + /// Indicates the current design mode of the editor. final ImageEditorDesignMode designMode; + /// Whether undo action is currently available. final bool canUndo; + + /// Whether redo action is currently available. final bool canRedo; + + /// Whether fill mode is currently enabled. final bool isFillMode; + /// Callback triggered when the fill menu is tapped. final Function() onTapMenuFill; + + /// Callback triggered for undoing the last action. final Function() onUndo; + + /// Callback triggered for redoing the last undone action. final Function() onRedo; + + /// Callback triggered for toggling fill mode. final Function() onToggleFill; + + /// Callback triggered for completing the paint editing session. final Function() onDone; + + /// Callback triggered for closing the paint editor. final Function() onClose; + + /// Callback triggered to open the opacity settings. final Function() onOpenOpacityBottomSheet; + + /// Callback triggered to open the line weight settings. final Function() onOpenLineWeightBottomSheet; @override diff --git a/lib/features/paint_editor/widgets/paint_editor_bottombar.dart b/lib/features/paint_editor/widgets/paint_editor_bottombar.dart index be88023c..67227f19 100644 --- a/lib/features/paint_editor/widgets/paint_editor_bottombar.dart +++ b/lib/features/paint_editor/widgets/paint_editor_bottombar.dart @@ -7,7 +7,21 @@ import '/features/paint_editor/enums/paint_editor_enum.dart'; import '/shared/widgets/flat_icon_text_button.dart'; import '../models/paint_bottom_bar_item.dart'; +/// A widget representing the bottom bar for the paint editor, providing +/// options for selecting paint modes, enabling zoom, and other related actions. class PaintEditorBottombar extends StatelessWidget { + /// Creates a `PaintEditorBottombar` with the provided configurations, + /// modes, and callbacks for interactions. + /// + /// - [i18n]: Localization strings for tooltips and labels. + /// - [configs]: Configuration settings for the paint editor. + /// - [paintMode]: The current paint mode being used. + /// - [bottomBarScrollCtrl]: Controls the scroll behavior of the bottom bar. + /// - [theme]: Theme data for styling the bottom bar. + /// - [enableZoom]: Whether zoom functionality is enabled. + /// - [paintModes]: A list of available paint modes displayed in the bottom + /// bar. + /// - [setMode]: Callback triggered when a new paint mode is selected. const PaintEditorBottombar({ super.key, required this.configs, @@ -20,13 +34,28 @@ class PaintEditorBottombar extends StatelessWidget { required this.bottomBarScrollCtrl, }); + /// Localization strings for tooltips and labels. + final I18nPaintEditor i18n; + + /// Configuration settings for the paint editor. final PaintEditorConfigs configs; + + /// The current paint mode being used. final PaintMode paintMode; - final I18nPaintEditor i18n; + + /// Controls the scroll behavior of the bottom bar. + final ScrollController bottomBarScrollCtrl; + + /// Theme data for styling the bottom bar. final ThemeData theme; + + /// Whether zoom functionality is enabled. final bool enableZoom; + + /// A list of available paint modes displayed in the bottom bar. final List paintModes; - final ScrollController bottomBarScrollCtrl; + + /// Callback triggered when a new paint mode is selected. final Function(PaintMode mode) setMode; @override diff --git a/lib/features/paint_editor/widgets/paint_editor_color_picker.dart b/lib/features/paint_editor/widgets/paint_editor_color_picker.dart index da7356b5..458fac80 100644 --- a/lib/features/paint_editor/widgets/paint_editor_color_picker.dart +++ b/lib/features/paint_editor/widgets/paint_editor_color_picker.dart @@ -7,7 +7,17 @@ import '/core/models/editor_configs/pro_image_editor_configs.dart'; import '/shared/widgets/color_picker/bar_color_picker.dart'; import '../paint_editor.dart'; +/// A widget for selecting colors in the paint editor, allowing users to +/// customize their brush or fill colors. class PaintEditorColorPicker extends StatelessWidget { + /// Creates a `PaintEditorColorPicker` with the provided state, + /// configurations, and a controller for triggering UI rebuilds. + /// + /// - [state]: Represents the current state of the paint editor. + /// - [configs]: Configuration settings for the paint editor, including + /// available colors and styles. + /// - [rebuildController]: A stream controller for triggering UI updates + /// when the color picker state changes. const PaintEditorColorPicker({ super.key, required this.state, @@ -15,8 +25,14 @@ class PaintEditorColorPicker extends StatelessWidget { required this.rebuildController, }); + /// Represents the current state of the paint editor. final PaintEditorState state; + + /// Configuration settings for the paint editor, including available colors. final ProImageEditorConfigs configs; + + /// A stream controller for triggering UI updates when the color picker + /// changes. final StreamController rebuildController; @override diff --git a/lib/features/text_editor/widgets/text_editor_appbar.dart b/lib/features/text_editor/widgets/text_editor_appbar.dart index ed4ce24d..e4fea1d6 100644 --- a/lib/features/text_editor/widgets/text_editor_appbar.dart +++ b/lib/features/text_editor/widgets/text_editor_appbar.dart @@ -5,7 +5,23 @@ import '/core/models/editor_configs/text_editor_configs.dart'; import '/core/models/i18n/i18n_text_editor.dart'; import '/shared/widgets/platform/platform_popup_menu.dart'; +/// A custom AppBar for the text editor, providing options for text alignment, +/// background mode, and font scaling. class TextEditorAppBar extends StatelessWidget implements PreferredSizeWidget { + /// Creates a `TextEditorAppBar` with the provided configurations, design + /// mode, and callbacks for user interactions. + /// + /// - [textEditorConfigs]: Configuration settings for the text editor's + /// appearance. + /// - [i18n]: Localization strings for tooltips and labels. + /// - [align]: The current text alignment. + /// - [designMode]: Indicates the current design mode of the editor. + /// - [constraints]: Box constraints for responsive layout adjustments. + /// - [onClose]: Callback triggered when the editor is closed. + /// - [onDone]: Callback triggered when editing is completed. + /// - [onToggleTextAlign]: Callback triggered to toggle the text alignment. + /// - [onOpenFontScaleBottomSheet]: Callback to open the font scaling options. + /// - [onToggleBackgroundMode]: Callback triggered to toggle background mode. const TextEditorAppBar({ super.key, required this.textEditorConfigs, @@ -19,16 +35,35 @@ class TextEditorAppBar extends StatelessWidget implements PreferredSizeWidget { required this.designMode, required this.constraints, }); + + /// Configuration settings for the text editor's appearance. final TextEditorConfigs textEditorConfigs; + + /// Localization strings for tooltips and labels. final I18nTextEditor i18n; + + /// The current text alignment. final TextAlign align; + + /// Indicates the current design mode of the editor. final ImageEditorDesignMode designMode; + + /// Box constraints for responsive layout adjustments. final BoxConstraints constraints; + /// Callback triggered when the editor is closed. final Function() onClose; + + /// Callback triggered when editing is completed. final Function() onDone; + + /// Callback triggered to toggle the text alignment. final Function() onToggleTextAlign; + + /// Callback to open the font scaling options. final Function() onOpenFontScaleBottomSheet; + + /// Callback triggered to toggle background mode. final Function() onToggleBackgroundMode; @override diff --git a/lib/features/text_editor/widgets/text_editor_color_picker.dart b/lib/features/text_editor/widgets/text_editor_color_picker.dart index ab0b49c0..7b7b2e13 100644 --- a/lib/features/text_editor/widgets/text_editor_color_picker.dart +++ b/lib/features/text_editor/widgets/text_editor_color_picker.dart @@ -7,7 +7,22 @@ import '/core/models/editor_configs/pro_image_editor_configs.dart'; import '/shared/widgets/color_picker/bar_color_picker.dart'; import '../text_editor.dart'; +/// A widget for selecting and customizing text colors in the text editor, +/// allowing updates to primary and background colors. class TextEditorColorPicker extends StatelessWidget { + /// Creates a `TextEditorColorPicker` with the necessary configurations, + /// state, and callbacks for handling color updates and position changes. + /// + /// - [state]: Represents the current state of the text editor. + /// - [configs]: Configuration settings for the editor, including available + /// colors. + /// - [rebuildController]: A stream controller for triggering UI updates. + /// - [colorPosition]: The position of the selected color in the palette. + /// - [primaryColor]: The current primary color selected for the text. + /// - [selectedTextStyle]: The text style currently applied to the text. + /// - [onUpdateColor]: Callback triggered when the color is updated. + /// - [onPositionChange]: Callback triggered when the color position is + /// changed. const TextEditorColorPicker({ super.key, required this.state, @@ -20,14 +35,28 @@ class TextEditorColorPicker extends StatelessWidget { required this.onPositionChange, }); + /// Represents the current state of the text editor. final TextEditorState state; + + /// Configuration settings for the editor, including available colors. final ProImageEditorConfigs configs; + + /// A stream controller for triggering UI updates. final StreamController rebuildController; + + /// The position of the selected color in the palette. final double colorPosition; + + /// The current primary color selected for the text. final Color primaryColor; + + /// The text style currently applied to the text. final TextStyle selectedTextStyle; + /// Callback triggered when the color is updated. final Function(Color color) onUpdateColor; + + /// Callback triggered when the color position is changed. final Function(double value)? onPositionChange; @override diff --git a/lib/features/text_editor/widgets/text_editor_input.dart b/lib/features/text_editor/widgets/text_editor_input.dart index 764ffeea..e6b030bf 100644 --- a/lib/features/text_editor/widgets/text_editor_input.dart +++ b/lib/features/text_editor/widgets/text_editor_input.dart @@ -5,7 +5,24 @@ import '/core/models/editor_configs/pro_image_editor_configs.dart'; import '/core/models/layers/layer.dart'; import '/plugins/rounded_background_text/src/rounded_background_text_field.dart'; +/// A widget for managing the text input in the text editor, providing a +/// customizable input area with styling and configuration options. class TextEditorInput extends StatelessWidget { + /// Creates a `TextEditorInput` widget with the required configurations, + /// callbacks, and styling for text input management. + /// + /// - [callbacks]: Optional callbacks for text editor interactions. + /// - [configs]: Configuration settings for the text editor. + /// - [i18n]: Localization strings for tooltips and labels. + /// - [heroTag]: Optional tag for hero animations during transitions. + /// - [selectedTextStyle]: The text style applied to the input text. + /// - [align]: The alignment of the text in the input field. + /// - [textFontSize]: The font size of the input text. + /// - [textColor]: The color of the input text. + /// - [backgroundColor]: The background color of the text input field. + /// - [layer]: The text layer being edited, if applicable. + /// - [focusNode]: The focus node for managing input focus. + /// - [textCtrl]: The text editing controller for managing input content. const TextEditorInput({ super.key, required this.callbacks, @@ -22,20 +39,40 @@ class TextEditorInput extends StatelessWidget { required this.textCtrl, }); + /// Optional callbacks for text editor interactions. final TextEditorCallbacks? callbacks; + + /// Configuration settings for the text editor. final TextEditorConfigs configs; + + /// Localization strings for tooltips and labels. final I18nTextEditor i18n; + + /// Optional tag for hero animations during transitions. final String? heroTag; + /// The text style applied to the input text. final TextStyle selectedTextStyle; + + /// The alignment of the text in the input field. final TextAlign align; + + /// The font size of the input text. final double textFontSize; + + /// The color of the input text. final Color textColor; + + /// The background color of the text input field. final Color backgroundColor; + /// The text layer being edited, if applicable. final TextLayer? layer; + /// The focus node for managing input focus. final FocusNode focusNode; + + /// The text editing controller for managing input content. final TextEditingController textCtrl; Widget _flightShuttleBuilder( diff --git a/lib/features/tune_editor/widgets/tune_editor_appbar.dart b/lib/features/tune_editor/widgets/tune_editor_appbar.dart index 542869cc..60f8d42b 100644 --- a/lib/features/tune_editor/widgets/tune_editor_appbar.dart +++ b/lib/features/tune_editor/widgets/tune_editor_appbar.dart @@ -3,7 +3,21 @@ import 'package:flutter/material.dart'; import '/core/models/editor_configs/tune_editor_configs.dart'; import '/core/models/i18n/i18n_tune_editor.dart'; +/// A custom AppBar for the tune editor, providing controls for undo, redo, +/// and completing or closing the tuning process. class TuneEditorAppbar extends StatelessWidget implements PreferredSizeWidget { + /// Creates a `TuneEditorAppbar` with the provided configurations and + /// callbacks. + /// + /// - [tuneEditorConfigs]: Configuration settings for the tune editor's + /// appearance. + /// - [i18n]: Localization strings for tooltips and labels. + /// - [canRedo]: Indicates whether redo action is currently available. + /// - [canUndo]: Indicates whether undo action is currently available. + /// - [onRedo]: Callback triggered for redoing the last undone action. + /// - [onUndo]: Callback triggered for undoing the last action. + /// - [onClose]: Callback triggered for closing the tune editor. + /// - [onDone]: Callback triggered for completing the tuning process. const TuneEditorAppbar({ super.key, required this.tuneEditorConfigs, @@ -16,15 +30,28 @@ class TuneEditorAppbar extends StatelessWidget implements PreferredSizeWidget { required this.onDone, }); + /// Configuration settings for the tune editor's appearance. final TuneEditorConfigs tuneEditorConfigs; + + /// Localization strings for tooltips and labels. final I18nTuneEditor i18n; + /// Indicates whether redo action is currently available. final bool canRedo; + + /// Indicates whether undo action is currently available. final bool canUndo; + /// Callback triggered for redoing the last undone action. final Function() onRedo; + + /// Callback triggered for undoing the last action. final Function() onUndo; + + /// Callback triggered for closing the tune editor. final Function() onClose; + + /// Callback triggered for completing the tuning process. final Function() onDone; @override diff --git a/lib/features/tune_editor/widgets/tune_editor_bottombar.dart b/lib/features/tune_editor/widgets/tune_editor_bottombar.dart index d0066c46..52482bce 100644 --- a/lib/features/tune_editor/widgets/tune_editor_bottombar.dart +++ b/lib/features/tune_editor/widgets/tune_editor_bottombar.dart @@ -8,7 +8,24 @@ import '/shared/widgets/flat_icon_text_button.dart'; import '../models/tune_adjustment_matrix.dart'; import '../tune_editor.dart'; +/// A bottom bar for the tune editor, providing UI for adjusting image +/// properties like brightness, contrast, and other tunable parameters. class TuneEditorBottombar extends StatefulWidget { + /// Creates a `TuneEditorBottombar` with the provided configurations, + /// adjustment options, and callbacks for user interactions. + /// + /// - [tuneEditorConfigs]: Configuration settings for the tune editor. + /// - [tuneAdjustmentList]: A list of available tune adjustment items. + /// - [tuneAdjustmentMatrix]: A list of matrices representing applied + /// adjustments. + /// - [selectedIndex]: The index of the currently selected adjustment item. + /// - [rebuildController]: A stream controller for triggering UI rebuilds. + /// - [bottomBarScrollCtrl]: Controls the scroll behavior of the bottom bar. + /// - [state]: Represents the current state of the tune editor. + /// - [onChangedStart]: Callback triggered at the start of an adjustment. + /// - [onChanged]: Callback triggered during adjustment changes. + /// - [onChangedEnd]: Callback triggered when an adjustment is completed. + /// - [onSelect]: Callback triggered when a tune adjustment item is selected. const TuneEditorBottombar({ super.key, required this.tuneEditorConfigs, @@ -24,6 +41,7 @@ class TuneEditorBottombar extends StatefulWidget { required this.selectedIndex, }); + /// Configuration settings for the tune editor. final TuneEditorConfigs tuneEditorConfigs; /// A list of tune adjustment items available in the editor. @@ -35,14 +53,25 @@ class TuneEditorBottombar extends StatefulWidget { /// The index of the currently selected tune adjustment item. final int selectedIndex; + /// A stream controller for triggering UI rebuilds. final StreamController rebuildController; + + /// Controls the scroll behavior of the bottom bar. final ScrollController bottomBarScrollCtrl; + /// Represents the current state of the tune editor. final TuneEditorState state; + /// Callback triggered at the start of an adjustment. final Function(double value) onChangedStart; + + /// Callback triggered during adjustment changes. final Function(double value) onChanged; + + /// Callback triggered when an adjustment is completed. final Function(double value) onChangedEnd; + + /// Callback triggered when a tune adjustment item is selected. final Function(int index) onSelect; @override diff --git a/lib/shared/services/content_recorder/controllers/content_recorder_controller.dart b/lib/shared/services/content_recorder/controllers/content_recorder_controller.dart index b8d6894a..b0053188 100644 --- a/lib/shared/services/content_recorder/controllers/content_recorder_controller.dart +++ b/lib/shared/services/content_recorder/controllers/content_recorder_controller.dart @@ -17,7 +17,7 @@ import '../services/image_render_service.dart'; import '../services/isolate_manager.dart'; import '../services/thread_manager.dart'; import '../services/web_worker/web_worker_manager_dummy.dart' - if (dart.library.js_interop) '../managers/web_worker/web_worker_manager.dart'; + if (dart.library.js_interop) '../services/web_worker/web_worker_manager.dart'; import '../utils/converters/convert_flutter_ui_to_image.dart'; import '../utils/encoder/encode_image.dart'; @@ -354,15 +354,8 @@ class ContentRecorderController { /// Recapture the image if the output format is incorrect or the output /// size is too large. if (kIsWeb || isOutputSizeTooLarge) { - /// TODO: test - /// currently in the web flutter decode the image wrong so we need - /// to recapture it. - /// bytes = await _webWorkerManager.send( - /// await _generateSendEncodeData( - /// id: id, - /// image: image, - /// ), - /// ); + /// Due to a known issue with image decoding in Flutter web, we need + /// to recapture the image to ensure accuracy. bytes = widget == null ? await _captureImageContent( id: id, diff --git a/lib/shared/widgets/slider_bottom_sheet.dart b/lib/shared/widgets/slider_bottom_sheet.dart index d63d7d8b..3feca24d 100644 --- a/lib/shared/widgets/slider_bottom_sheet.dart +++ b/lib/shared/widgets/slider_bottom_sheet.dart @@ -7,7 +7,27 @@ import '/shared/styles/platform_text_styles.dart'; import '/shared/widgets/bottom_sheets_header_row.dart'; import 'reactive_widgets/reactive_custom_widget.dart'; +/// A bottom sheet widget with a slider, allowing users to adjust values within +/// a specified range. The widget supports customization and dynamic UI updates. class SliderBottomSheet extends StatefulWidget { + /// Creates a `SliderBottomSheet` with the provided parameters for + /// customization and user interaction. + /// + /// - [title]: The title displayed at the top of the bottom sheet. + /// - [headerTextStyle]: The text style for the title. + /// - [resetIcon]: An optional icon for resetting the slider's value. + /// - [closeButton]: A builder function for a custom close button. + /// - [customSlider]: A builder function for a custom slider. + /// - [showFactorInTitle]: Whether to show the factor value in the title. + /// - [min]: The minimum value for the slider. + /// - [max]: The maximum value for the slider. + /// - [divisions]: The number of discrete divisions on the slider. + /// - [rebuildController]: A stream controller for triggering UI updates. + /// - [state]: The state object associated with the bottom sheet. + /// - [designMode]: The design mode of the editor. + /// - [theme]: Theme data for styling the bottom sheet. + /// - [value]: The current value of the slider. + /// - [onValueChanged]: Callback triggered when the slider value changes. const SliderBottomSheet({ super.key, required this.title, @@ -27,10 +47,19 @@ class SliderBottomSheet extends StatefulWidget { this.showFactorInTitle = false, }); + /// The title displayed at the top of the bottom sheet. final String title; + + /// The text style for the title. final TextStyle? headerTextStyle; + + /// An optional icon for resetting the slider's value. final IconData? resetIcon; + + /// A builder function for a custom close button. final Widget Function(T, dynamic Function())? closeButton; + + /// A builder function for a custom slider. final ReactiveWidget Function( T, Stream, @@ -39,19 +68,34 @@ class SliderBottomSheet extends StatefulWidget { dynamic Function(double), )? customSlider; + /// Whether to show the factor value in the title. final bool showFactorInTitle; + + /// The minimum value for the slider. final double min; + + /// The maximum value for the slider. final double max; + + /// The number of discrete divisions on the slider. final int? divisions; + /// A stream controller for triggering UI updates. final StreamController rebuildController; + /// The state object associated with the bottom sheet. final T state; + /// The design mode of the editor. final ImageEditorDesignMode designMode; + + /// Theme data for styling the bottom sheet. final ThemeData theme; + + /// The current value of the slider. final double value; + /// Callback triggered when the slider value changes. final Function(double value) onValueChanged; @override