Skip to content

Commit

Permalink
docs(editors): improve documentation comments in editor components
Browse files Browse the repository at this point in the history
  • Loading branch information
hm21 committed Jan 21, 2025
1 parent 50cb399 commit 59f247d
Show file tree
Hide file tree
Showing 29 changed files with 766 additions and 38 deletions.
9 changes: 7 additions & 2 deletions lib/core/mixins/standalone_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,15 @@ mixin StandaloneEditorState<T extends StatefulWidget,
if (!initConfigs.convertToUint8List) return;

await setImageInfos();

screenshotHistory.removeRange(
screenshotHistoryPosition, screenshotHistory.length);
screenshotHistoryPosition,
screenshotHistory.length,
);

screenshotHistoryPosition++;
screenshotCtrl.capture(

await screenshotCtrl.capture(
imageInfos: imageInfos!,
screenshots: screenshotHistory,
);
Expand Down
8 changes: 7 additions & 1 deletion lib/core/models/layers/text_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ class TextLayer extends Layer {
scale: layer.scale,
text: map[keyConverter('text')] ?? '-',
fontScale: map[keyConverter('fontScale')] ?? 1.0,
textStyle: map[keyConverter('fontFamily')] != null
textStyle: fontFamily != null ||
wordSpacing != null ||
height != null ||
letterSpacing != null ||
fontWeight != null ||
fontStyle != null ||
decoration != null
? TextStyle(
fontFamily: fontFamily,
height: height,
Expand Down
11 changes: 11 additions & 0 deletions lib/core/models/multi_threading/thread_request_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ class ThreadRequest {
this.generateOnlyImageBounds,
});

/// Creates a [ThreadRequest] instance from the provided configurations.
///
/// The [id] parameter is a unique identifier for the thread request.
///
/// The [image] parameter is the image to be processed.
///
/// The [configs] parameter contains the configuration settings for image
/// generation.
///
/// Returns a [ThreadRequest] object initialized with the provided
/// configurations.
factory ThreadRequest.fromConfigs({
required String id,
required img.Image image,
Expand Down
23 changes: 22 additions & 1 deletion lib/features/blur_editor/widgets/blur_editor_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,39 @@ import 'package:flutter/material.dart';
import '/core/models/editor_configs/blur_editor_configs.dart';
import '/core/models/i18n/i18n_blur_editor.dart';

/// A custom AppBar widget for the Blur Editor feature.
///
/// This widget is a stateless widget that implements the PreferredSizeWidget
/// interface, making it suitable for use as an AppBar in a Scaffold.
///
/// The [BlurEditorAppBar] requires the following parameters:
///
/// * [blurEditorConfigs]: Configuration settings for the blur editor.
/// * [i18n]: Internationalization object for localized strings.
/// * [close]: Callback function to be executed when the close button is
/// pressed.
/// * [done]: Callback function to be executed when the done button is pressed.
class BlurEditorAppBar extends StatelessWidget implements PreferredSizeWidget {

/// Creates an instance of `BlurEditorAppBar`, a custom `AppBar` for the Blur
/// Editor UI.
const BlurEditorAppBar({
super.key,
required this.blurEditorConfigs,
required this.i18n,
required this.close,
required this.done,
});

/// Configuration settings for the blur editor.
final BlurEditorConfigs blurEditorConfigs;

/// Internationalization support for the blur editor.
final I18nBlurEditor i18n;

/// Callback function to close the blur editor.
final Function() close;

/// Callback function to indicate completion of the blur editing process.
final Function() done;

@override
Expand Down
41 changes: 38 additions & 3 deletions lib/features/blur_editor/widgets/blur_editor_bottombar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@ import 'package:pro_image_editor/core/models/editor_configs/blur_editor_configs.

import '../blur_editor.dart';

/// A widget that represents the bottom bar of the blur editor.
///
/// This widget provides controls for adjusting the blur effect in the editor.
///
/// The [BlurEditorBottombar] requires the following parameters:
///
/// * [blurEditorConfigs]: Configuration settings for the blur editor.
/// * [uiBlurStream]: A stream that provides updates to the UI for the blur
/// effect.
/// * [blurFactor]: The current factor by which the blur effect is applied.
/// * [rebuildController]: A controller to manage rebuilding of the widget.
/// * [blurEditorState]: The current state of the blur editor.
/// * [onChanged]: A callback function that is called when the blur factor
/// changes.
/// * [onChangedEnd]: A callback function that is called when the blur factor
/// change ends.
class BlurEditorBottombar extends StatelessWidget {
/// Creates an instance of `BlurEditorBottombar`, a custom `BottomBar` for
/// the Blur-Editor UI.
const BlurEditorBottombar({
super.key,
required this.blurEditorConfigs,
Expand All @@ -17,13 +35,30 @@ class BlurEditorBottombar extends StatelessWidget {
required this.onChangedEnd,
});

/// Represents the state of the blur editor.
final BlurEditorState blurEditorState;

/// Configuration settings for the blur editor.
final BlurEditorConfigs blurEditorConfigs;

/// Stream controller to handle UI blur updates.
final StreamController<void> uiBlurStream;

/// Stream controller to handle rebuild events.
final StreamController<void> 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<void> rebuildController;
final BlurEditorState blurEditorState;

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/crop_rotate_editor/crop_rotate_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ class CropRotateEditorState extends State<CropRotateEditor>
? initialTransformConfigs!
: activeHistory;

screenshotCtrl.capture(
await screenshotCtrl.capture(
imageInfos: imageInfos!,
screenshots: screenshotHistory,
targetSize: _rotated90deg
Expand Down
39 changes: 39 additions & 0 deletions lib/features/crop_rotate_editor/widgets/crop_editor_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
28 changes: 28 additions & 0 deletions lib/features/crop_rotate_editor/widgets/crop_editor_bottombar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions lib/features/filter_editor/widgets/filter_editor_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@ 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,
required this.i18n,
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
Expand Down
2 changes: 1 addition & 1 deletion lib/features/main_editor/main_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ class ProImageEditorState extends State<ProImageEditor>

if (!mounted) return;

_controllers.screenshot.capture(
await _controllers.screenshot.capture(
imageInfos: _imageInfos!,
screenshots: stateManager.screenshots,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
Loading

0 comments on commit 59f247d

Please sign in to comment.