From 74dbcecbfaf9be357e45edf31e8d555b12d7f06f Mon Sep 17 00:00:00 2001 From: hackware Date: Sat, 14 May 2022 06:59:51 +0800 Subject: [PATCH] release v1.3.0-stable --- CHANGELOG.md | 4 ++++ README.md | 36 ++++++++++++++++++++++------------ README_CN.md | 36 ++++++++++++++++++++++------------ example/circle_position.dart | 15 ++++++-------- lib/src/constraint_layout.dart | 7 +++++++ pubspec.yaml | 2 +- 6 files changed, 64 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a215ba..f67b6ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.3.0-stable + +enhance base constraints. + # v1.2.0-stable add arbitrary position support. diff --git a/README.md b/README.md index e8aba05..0b634e5 100644 --- a/README.md +++ b/README.md @@ -60,17 +60,27 @@ two-way constraints, such as chains(not yet supported, please use with Flex). # Feature 1. build flexible layouts with constraints - 1. leftToLeft - 2. leftToRight - 3. rightToLeft - 4. rightToRight - 5. topToTop - 6. topToBottom - 7. bottomToTop - 8. bottomToBottom - 9. baselineToTop - 10. baselineToBottom - 11. baselineToBaseline + 1. left + 1. toLeft + 2. toCenter(with bias, the default value is 0.5) + 3. toRight + 2. right + 1. toLeft + 2. toCenter(with bias, the default value is 0.5) + 3. toRight + 3. top + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBottom + 4. bottom + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBottom + 5. baseline + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBaseline + 4. toBottom 2. margin and goneMargin(when the visibility of the dependent element is gone or the actual size of one side is 0, the goneMargin will take effect, otherwise the margin will take effect, even if its own visibility is gone) @@ -173,12 +183,12 @@ dependencies: flutter_constraintlayout: git: url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git' - ref: 'v1.2.0-stable' + ref: 'v1.3.0-stable' ``` ```yaml dependencies: - flutter_constraintlayout: ^1.2.0-stable + flutter_constraintlayout: ^1.3.0-stable ``` ```dart diff --git a/README_CN.md b/README_CN.md index 80579f7..e549cf7 100644 --- a/README_CN.md +++ b/README_CN.md @@ -43,17 +43,27 @@ build 耗时有时甚至超过渲染耗时。 # Feature 1. 基本约束 - 1. leftToLeft - 2. leftToRight - 3. rightToLeft - 4. rightToRight - 5. topToTop - 6. topToBottom - 7. bottomToTop - 8. bottomToBottom - 9. baselineToTop - 10. baselineToBottom - 11. baselineToBaseline + 1. left + 1. toLeft + 2. toCenter(with bias, the default value is 0.5) + 3. toRight + 2. right + 1. toLeft + 2. toCenter(with bias, the default value is 0.5) + 3. toRight + 3. top + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBottom + 4. bottom + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBottom + 5. baseline + 1. toTop + 2. toCenter(with bias, the default value is 0.5) + 3. toBaseline + 4. toBottom 2. margin and goneMargin(当依赖的元素的可见性为 gone 或者其某一边的实际大小为 0 时,goneMargin 就会生效,否则 margin 会生效,即便其自身的可见性为 gone) 3. clickPadding( @@ -147,12 +157,12 @@ dependencies: flutter_constraintlayout: git: url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git' - ref: 'v1.2.0-stable' + ref: 'v1.3.0-stable' ``` ```yaml dependencies: - flutter_constraintlayout: ^1.2.0-stable + flutter_constraintlayout: ^1.3.0-stable ``` ```dart diff --git a/example/circle_position.dart b/example/circle_position.dart index 2f0439c..fc8e5a2 100644 --- a/example/circle_position.dart +++ b/example/circle_position.dart @@ -115,9 +115,8 @@ class CirclePositionExampleState extends State { ).applyConstraint( width: 5, height: 80, - centerTo: rId(0), - translate: const Offset(0, 0.5), - percentageTranslate: true, + top: rId(0).center, + centerHorizontalTo: rId(0), ), Transform.rotate( angle: pi + pi * (minute * 6 / 180), @@ -128,9 +127,8 @@ class CirclePositionExampleState extends State { ).applyConstraint( width: 5, height: 120, - centerTo: rId(0), - translate: const Offset(0, 0.5), - percentageTranslate: true, + top: rId(0).center, + centerHorizontalTo: rId(0), ), Transform.rotate( angle: pi + pi * (second * 6 / 180), @@ -141,9 +139,8 @@ class CirclePositionExampleState extends State { ).applyConstraint( width: 5, height: 180, - centerTo: rId(0), - translate: const Offset(0, 0.5), - percentageTranslate: true, + top: rId(0).center, + centerHorizontalTo: rId(0), ), Text( '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}', diff --git a/lib/src/constraint_layout.dart b/lib/src/constraint_layout.dart index abedbbc..a7916dc 100644 --- a/lib/src/constraint_layout.dart +++ b/lib/src/constraint_layout.dart @@ -4580,6 +4580,13 @@ class ConstrainedNode { map['pinnedConstraint'] = pinnedConstraint!.toJson(); } } + if (anchors != null) { + List> anchorsJson = []; + for (final element in anchors!) { + anchorsJson.add(element.toJson()); + } + map['anchors'] = anchorsJson; + } } map['depth'] = getDepth(null, null, null); return map; diff --git a/pubspec.yaml b/pubspec.yaml index 2d92056..712c985 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.2.0-stable +version: 1.3.0-stable anthor: hackware homepage: https://github.com/hackware1993/Flutter-ConstraintLayout