Skip to content

Commit e119df2

Browse files
committed
feature#1.0.2#FFloatController adds setState function to support external partial refresh of FFloat content
1 parent 9aab275 commit e119df2

File tree

6 files changed

+51
-14
lines changed

6 files changed

+51
-14
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
## 1.0.0
1+
## 1.0.2
22

3-
- First version
3+
- FFloatController adds setState function to support external partial refresh of FFloat content
4+
5+
```dart
6+
controller.setState(() {
7+
// update your float ui
8+
});
9+
```
410

511
## 1.0.1
612

713
- Supports `alignment` configuration in absolute position mode
814

915
- Fix FFloatController status monitoring problem
16+
17+
## 1.0.0
18+
19+
- First version

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<p>
1919

2020
<a href="https://pub.dev/packages/ffloat#-readme-tab-">
21-
<img height="20" src="https://img.shields.io/badge/Version-1.0.1-important.svg">
21+
<img height="20" src="https://img.shields.io/badge/Version-1.0.2-important.svg">
2222
</a>
2323

2424

@@ -427,7 +427,7 @@ dependencies:
427427
ffloat:
428428
git:
429429
url: 'git@github.com:Fliggy-Mobile/ffloat.git'
430-
ref: ''<Branch number or tag number>'
430+
ref: '<Branch number or tag number>'
431431
```
432432

433433
> ⚠️ Attention,please refer to [**FFloat**] (https://github.com/Fliggy-Mobile/ffloat) official project for branch number or tag.
@@ -457,7 +457,7 @@ limitations under the License.
457457

458458

459459

460-
--
460+
---
461461

462462
# How to run Demo project?
463463

@@ -470,3 +470,5 @@ flutter create .
470470
```
471471

472472
3. Run the demo in `example`
473+
474+
# [🛸Portal: Update Log](https://github.com/Fliggy-Mobile/ffloat/blob/master/CHANGELOG.md)

README_CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<p>
1919

2020
<a href="https://pub.dev/packages/ffloat#-readme-tab-">
21-
<img height="20" src="https://img.shields.io/badge/Version-1.0.1-important.svg">
21+
<img height="20" src="https://img.shields.io/badge/Version-1.0.2-important.svg">
2222
</a>
2323

2424

@@ -470,3 +470,5 @@ flutter create .
470470
```
471471

472472
3. 运行 `example` 中的 Demo
473+
474+
# [🛸传送门:更新日志](https://github.com/Fliggy-Mobile/ffloat/blob/master/CHANGELOG.md)

example/lib/main.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import 'dart:async';
2-
import 'dart:ffi';
31
import 'dart:math';
42

53
import 'package:fbutton/fbutton.dart';
4+
import 'package:ffloat/ffloat.dart';
65
import 'package:ffloat_example/color.dart';
76
import 'package:flutter/material.dart';
8-
import 'package:ffloat/ffloat.dart';
97
import 'package:fradio/fradio.dart';
108
import 'package:fsuper/fsuper.dart';
119

@@ -805,6 +803,7 @@ class _FFloatPage extends State<FFloatPage> {
805803
);
806804
}
807805

806+
String test = "Surprise😃 !";
808807
Widget backgroundDemo() {
809808
return FSuper(
810809
width: double.infinity,
@@ -814,7 +813,8 @@ class _FFloatPage extends State<FFloatPage> {
814813
children: [
815814
FFloat(
816815
(_) => FSuper(
817-
text: "Surprise😃 !",
816+
// text: "Surprise😃 !",
817+
text: test,
818818
textColor: Colors.white,
819819
),
820820
controller: controller2_1,
@@ -828,12 +828,20 @@ class _FFloatPage extends State<FFloatPage> {
828828
text: "esc",
829829
textColor: Colors.white,
830830
fontSize: 15,
831+
alignment: Alignment.center,
831832
corner: FButtonCorner.all(3),
832833
padding: EdgeInsets.all(0),
833834
color: Color(0xff373737),
834835
effect: true,
835836
onPressed: () {
836-
controller2_1.show();
837+
if (!controller2_1.isShow) {
838+
test = "Surprise😃 !";
839+
controller2_1.show();
840+
} else {
841+
controller2_1.setState(() {
842+
test = "Changed!";
843+
});
844+
}
837845
},
838846
hoverColor: Colors.white60.withOpacity(0.3),
839847
),

lib/ffloat.dart

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ class _FFloat {
521521
realDismiss();
522522
}
523523
});
524+
ffloatContentController = new _FFloatContentController();
524525
controller?._show = () {
525526
show();
526527
};
@@ -530,7 +531,9 @@ class _FFloat {
530531
controller?._rebuildShow = () {
531532
rebuildShow();
532533
};
533-
ffloatContentController = new _FFloatContentController();
534+
controller?._setState = (VoidCallback fn){
535+
ffloatContentController?.setState(fn);
536+
};
534537
}
535538

536539
void update(Size anchorSize, Offset location) {
@@ -1184,8 +1187,14 @@ class _FFloatContentState extends State<_FFloatContent>
11841187
class _FFloatContentController {
11851188
_FFloatContentState state;
11861189

1190+
1191+
setState(VoidCallback fn){
1192+
state?._setState(fn);
1193+
}
1194+
1195+
11871196
update(Size anchorSize, Offset location) {
1188-
state?._setState(() {
1197+
setState(() {
11891198
state.anchorSize = anchorSize;
11901199
state.location = location;
11911200
});
@@ -1263,6 +1272,7 @@ class FFloatController {
12631272
VoidCallback _show;
12641273
VoidCallback _dismiss;
12651274
VoidCallback _rebuildShow;
1275+
StateSetter _setState;
12661276

12671277
/// 隐藏 [FFloat]
12681278
///
@@ -1304,6 +1314,11 @@ class FFloatController {
13041314
setStateChangedListener(VoidCallback listener) {
13051315
_callback = listener;
13061316
}
1317+
1318+
1319+
setState(VoidCallback fn){
1320+
_setState?.call(fn);
1321+
}
13071322
}
13081323

13091324
class _TrianglePainter extends CustomPainter {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ffloat
22
description: FFloat, although simple and easy to use, can satisfy all your imagination of the floating layer.
3-
version: 1.0.1
3+
version: 1.0.2
44
author: CoorChice<coorchice.cb@alibaba-inc.com>
55
homepage: https://github.com/Fliggy-Mobile/ffloat
66

0 commit comments

Comments
 (0)