diff --git a/packages/box_transform/lib/src/enums.dart b/packages/box_transform/lib/src/enums.dart index c8f420c..aa0bac5 100644 --- a/packages/box_transform/lib/src/enums.dart +++ b/packages/box_transform/lib/src/enums.dart @@ -65,6 +65,14 @@ enum HandlePosition { bool get influencesBottomOrRight => this == bottomRight || this == bottom || this == right; + /// Whether the handle is either on the left or right, or any diagonal side + /// of the rect. + bool get influencesHorizontal => isHorizontal || isDiagonal; + + /// Whether the handle is either on the top or bottom, or any diagonal side + /// of the rect. + bool get influencesVertical => isVertical || isDiagonal; + /// Whether the handle is on the corner of the rect. bool get isDiagonal => this == topLeft || diff --git a/packages/box_transform/lib/src/transformer.dart b/packages/box_transform/lib/src/transformer.dart index 98f73f5..06872a2 100644 --- a/packages/box_transform/lib/src/transformer.dart +++ b/packages/box_transform/lib/src/transformer.dart @@ -171,7 +171,7 @@ class BoxTransformer { initialRect: initialRect, clampingRect: clampingRect, constraints: constraints, - delta: delta, + handle: handle, ); return ResizeResult( @@ -203,13 +203,13 @@ class BoxTransformer { required Box initialRect, required Box clampingRect, required Constraints constraints, - required Vector2 delta, + required HandlePosition handle, }) { bool minWidthReached = false; bool maxWidthReached = false; bool minHeightReached = false; bool maxHeightReached = false; - if (delta.x != 0) { + if (handle.influencesHorizontal) { if (rect.width <= initialRect.width && rect.width == constraints.minWidth) { minWidthReached = true; @@ -220,14 +220,14 @@ class BoxTransformer { maxWidthReached = true; } } - if (delta.y != 0) { + if (handle.influencesVertical) { if (rect.height <= initialRect.height && rect.height == constraints.minHeight) { minHeightReached = true; } if (rect.height >= initialRect.height && - rect.height == constraints.maxHeight || - rect.height == clampingRect.height) { + (rect.height == constraints.maxHeight || + rect.height == clampingRect.height)) { maxHeightReached = true; } } diff --git a/packages/flutter_box_transform/example/pubspec.yaml b/packages/flutter_box_transform/example/pubspec.yaml index 275e446..6a6cba9 100644 --- a/packages/flutter_box_transform/example/pubspec.yaml +++ b/packages/flutter_box_transform/example/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: ^4.0.0 flutter: uses-material-design: true diff --git a/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/project.pbxproj b/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/project.pbxproj index 506e496..2bf17b0 100644 --- a/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/project.pbxproj @@ -204,7 +204,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb7259e..5b055a3 100644 --- a/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/flutter_box_transform/playground/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@