Skip to content

Commit

Permalink
release v1.5.0-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
hackware1993 committed May 15, 2022
1 parent 73181a3 commit d453010
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 258 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.5.0-stable

1. refactor debug function.
2. add a lot of comments.
3. fix the click problem caused by pinned translate.
4. optimize constraint version implementation.

# v1.4.4-stable

optimize rotate.
Expand Down
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ two-way constraints, such as chains(not yet supported, please use with Flex).
1. fixed size(>=0)
2. matchParent(default)
3. wrapContent(minimum and maximum are temporarily not supported)
23. layout debugging

Follow-up development plan:

1. chain
2. constraints visualization
3. more...
3. provides a visual editor to create layouts by dragging and dropping
4. more...

Support platform:

Expand All @@ -185,12 +187,12 @@ dependencies:
flutter_constraintlayout:
git:
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
ref: 'v1.4.4-stable'
ref: 'v1.5.0-stable'
```
```yaml
dependencies:
flutter_constraintlayout: ^1.4.4-stable
flutter_constraintlayout: ^1.5.0-stable
```
```dart
Expand Down Expand Up @@ -1335,24 +1337,24 @@ class BarrierExample extends StatelessWidget {
5. Do you need to rearrange the order of event distribution?

These comparisons will not be a performance bottleneck, but will increase CPU usage. If you know
enough about the internals of ConstraintLayout, you can use ConstraintVersion to manually trigger
these operations to stop parameter comparison.
enough about the internals of ConstraintLayout, you can use ConstraintLayoutController to manually
trigger these operations to stop parameter comparison.

```dart
class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
class ConstraintControllerExampleState extends State<ConstraintControllerExample> {
double x = 0;
double y = 0;
ConstraintVersion constraintVersion = ConstraintVersion();
ConstraintLayoutController controller = ConstraintLayoutController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const CustomAppBar(
title: 'Constraint Version',
codePath: 'example/constraint_version.dart',
title: 'Constraint Controller',
codePath: 'example/constraint_controller.dart',
),
body: ConstraintLayout(
constraintVersion: constraintVersion,
controller: controller,
children: [
GestureDetector(
child: Container(
Expand All @@ -1364,14 +1366,14 @@ class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
setState(() {
x += details.delta.dx;
y += details.delta.dy;
constraintVersion.incPaintVersion();
controller.markNeedsPaint();
});
},
).applyConstraint(
size: 200,
centerTo: parent,
translate: Offset(x, y),
),
)
],
),
);
Expand Down
25 changes: 14 additions & 11 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ build 耗时有时甚至超过渲染耗时。
1. 固定大小(>=0)
2. matchParent(default)
3. wrapContent(暂不支持最大、最小设置)
23. 布局调试

后续开发计划:

1.
2. 约束可视化
3. 更多...
3. 提供可视化编辑器,通过拖拽创建布局
4. 更多...

支持的平台:

Expand All @@ -159,12 +161,12 @@ dependencies:
flutter_constraintlayout:
git:
url: 'https://github.com/hackware1993/Flutter-ConstraintLayout.git'
ref: 'v1.4.4-stable'
ref: 'v1.5.0-stable'
```
```yaml
dependencies:
flutter_constraintlayout: ^1.4.4-stable
flutter_constraintlayout: ^1.5.0-stable
```
```dart
Expand Down Expand Up @@ -1302,23 +1304,24 @@ class BarrierExample extends StatelessWidget {
4. 是否需要重排绘制顺序?
5. 是否需要重排事件分发顺序?

这些比对不会成为性能瓶颈,但会提高 CPU 占用率。如果你对 ConstraintLayout 内部原理足够了解,你可以使用 ConstraintVersion 来手动触发这些操作,停止参数比对。
这些比对不会成为性能瓶颈,但会提高 CPU 占用率。如果你对 ConstraintLayout 内部原理足够了解,你可以使用 ConstraintLayoutController
来手动触发这些操作,停止参数比对。

```dart
class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
class ConstraintControllerExampleState extends State<ConstraintControllerExample> {
double x = 0;
double y = 0;
ConstraintVersion constraintVersion = ConstraintVersion();
ConstraintLayoutController controller = ConstraintLayoutController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const CustomAppBar(
title: 'Constraint Version',
codePath: 'example/constraint_version.dart',
title: 'Constraint Controller',
codePath: 'example/constraint_controller.dart',
),
body: ConstraintLayout(
constraintVersion: constraintVersion,
controller: controller,
children: [
GestureDetector(
child: Container(
Expand All @@ -1330,14 +1333,14 @@ class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
setState(() {
x += details.delta.dx;
y += details.delta.dy;
constraintVersion.incPaintVersion();
controller.markNeedsPaint();
});
},
).applyConstraint(
size: 200,
centerTo: parent,
translate: Offset(x, y),
),
)
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ import 'package:flutter_constraintlayout/flutter_constraintlayout.dart';

import 'custom_app_bar.dart';

class ConstraintVersionExample extends StatefulWidget {
const ConstraintVersionExample({Key? key}) : super(key: key);
class ConstraintControllerExample extends StatefulWidget {
const ConstraintControllerExample({Key? key}) : super(key: key);

@override
State createState() => ConstraintVersionExampleState();
State createState() => ConstraintControllerExampleState();
}

class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
class ConstraintControllerExampleState
extends State<ConstraintControllerExample> {
double x = 0;
double y = 0;
ConstraintVersion constraintVersion = ConstraintVersion();
ConstraintLayoutController controller = ConstraintLayoutController();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const CustomAppBar(
title: 'Constraint Version',
codePath: 'example/constraint_version.dart',
title: 'Constraint Controller',
codePath: 'example/constraint_controller.dart',
),
body: ConstraintLayout(
constraintVersion: constraintVersion,
controller: controller,
children: [
GestureDetector(
child: Container(
Expand All @@ -35,7 +36,7 @@ class ConstraintVersionExampleState extends State<ConstraintVersionExample> {
setState(() {
x += details.delta.dx;
y += details.delta.dy;
constraintVersion.incPaintVersion();
controller.markNeedsPaint();
});
},
).applyConstraint(
Expand Down
4 changes: 2 additions & 2 deletions example/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'charts.dart';
import 'circle_position.dart';
import 'coming_soon.dart';
import 'complex_list.dart';
import 'constraint_version.dart';
import 'constraint_controller.dart';
import 'dimension_ratio.dart';
import 'grid.dart';
import 'guideline.dart';
Expand Down Expand Up @@ -44,7 +44,7 @@ class ExampleHome extends StatelessWidget {
'Circle Position': const CirclePositionExample(),
'Pinned Position': const PinnedPositionExample(),
'Arbitrary Position': const ArbitraryPositionExample(),
'Constraint Version': const ConstraintVersionExample(),
'Constraint Controller': const ConstraintControllerExample(),
'Self wrapContent': const SelfWrapContentExample(),
'Margin': const MarginExample(),
'Translate': const TranslateExample(),
Expand Down
2 changes: 1 addition & 1 deletion lib/flutter_constraintlayout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ library flutter_constraintlayout;

export 'src/core.dart';
export 'src/extensions.dart';
export 'src/utils.dart';
export 'src/auxiliary.dart';
4 changes: 2 additions & 2 deletions lib/src/utils.dart → lib/src/auxiliary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ bool debugEnsureNotEmptyString(String name, String? value) {

bool debugEnsurePercent(String name, double? percent) {
if (percent == null || percent < 0 || percent > 1) {
throw ConstraintLayoutException('$name is between [0,1].');
throw ConstraintLayoutException('$name is between [0.0,1.0].');
}
return true;
}

bool debugEnsureNegativePercent(String name, double? percent) {
if (percent == null || percent < -1 || percent > 1) {
throw ConstraintLayoutException('$name is between [-1,1].');
throw ConstraintLayoutException('$name is between [-1.0,1.0].');
}
return true;
}
Expand Down
Loading

0 comments on commit d453010

Please sign in to comment.