Skip to content

Commit

Permalink
add pinned & circle translate support.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackware1993 committed May 14, 2022
1 parent 1afe82e commit ae86014
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.4.1-stable

1. add pinned & circle translate support.

# v1.4.0-stable

1. code refactoring, extracting non-core functions.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ dependencies:
flutter_constraintlayout:
git:
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
ref: 'v1.4.0-stable'
ref: 'v1.4.1-stable'
```
```yaml
dependencies:
flutter_constraintlayout: ^1.4.0-stable
flutter_constraintlayout: ^1.4.1-stable
```
```dart
Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ dependencies:
flutter_constraintlayout:
git:
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
ref: 'v1.4.0-stable'
ref: 'v1.4.1-stable'
```
```yaml
dependencies:
flutter_constraintlayout: ^1.4.0-stable
flutter_constraintlayout: ^1.4.1-stable
```
```dart
Expand Down
23 changes: 22 additions & 1 deletion example/translate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,31 @@ class TranslateExampleState extends State<TranslateExample> {
size: wrapContent,
centerTo: anchor,
translate: circleTranslate(
radius: 150,
radius: 100,
angle: angle,
),
),
Container(
decoration: const BoxDecoration(
color: Colors.cyan,
),
child: const Text('pinned & circle translate'),
).applyConstraint(
size: wrapContent,
centerTo: anchor,
translate: PinnedTranslate(
PinnedInfo(
null,
Anchor(0.5, AnchorType.percent, 0.5, AnchorType.percent),
null,
angle: angle,
),
) +
circleTranslate(
radius: 150,
angle: angle,
),
),
Container(
decoration: const BoxDecoration(
color: Colors.orange,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ class PinnedTranslate extends Offset {

PinnedTranslate(this._pinnedInfo) : super(0, 0);

PinnedTranslate._shift(this._pinnedInfo, double x, double y) : super(x, y);

@override
bool operator ==(Object other) =>
identical(this, other) ||
Expand All @@ -506,6 +508,10 @@ class PinnedTranslate extends Offset {
runtimeType == other.runtimeType &&
_pinnedInfo == other._pinnedInfo;

@override
PinnedTranslate operator +(Offset other) =>
PinnedTranslate._shift(_pinnedInfo, other.dx, other.dy);

@override
int get hashCode => super.hashCode ^ _pinnedInfo.hashCode;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_constraintlayout
description: A super powerful Stack, build flexible layouts with constraints. Similar to ConstraintLayout for Android and AutoLayout for iOS.
version: 1.4.0-stable
version: 1.4.1-stable
anthor: hackware
homepage: https://github.com/hackware1993/Flutter-ConstraintLayout

Expand Down
Binary file modified translate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ae86014

Please sign in to comment.