Skip to content

Commit

Permalink
update v2.1.0 (nslogx#59, nslogx#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
nslogx committed Nov 11, 2020
1 parent af11880 commit ffaae47
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 252 deletions.
8 changes: 7 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"name": "flutter_easyloading",
"request": "launch",
"type": "dart"
},
{
"name": "example",
"cwd": "example",
"request": "launch",
"type": "dart"
}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.1.0] - 2020.11.11

* add loading status callback
* add dismissOnTap option [#59](https://github.com/huangjianke/flutter_easyloading/issues/59)
* fixed [#61](https://github.com/huangjianke/flutter_easyloading/issues/61)
* fixed bugs

## [2.0.1] - 2020.11.06

* fixed [#58](https://github.com/huangjianke/flutter_easyloading/issues/58)
Expand Down
40 changes: 31 additions & 9 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flutter_easyloading
# Flutter EasyLoading

[![pub package](https://img.shields.io/pub/v/flutter_easyloading?style=flat)](https://pub.dev/packages/flutter_easyloading) [![pub points](https://badges.bar/flutter_easyloading/pub%20points)](https://pub.dev/packages/flutter_easyloading/score) [![popularity](https://badges.bar/flutter_easyloading/popularity)](https://pub.dev/packages/flutter_easyloading/score) [![likes](https://badges.bar/flutter_easyloading/likes)](https://pub.dev/packages/flutter_easyloading/score) [![license](https://img.shields.io/github/license/huangjianke/flutter_easyloading?style=flat)](https://github.com/huangjianke/flutter_easyloading) [![stars](https://img.shields.io/github/stars/huangjianke/flutter_easyloading?style=social)](https://github.com/huangjianke/flutter_easyloading)

Expand All @@ -16,7 +16,7 @@

```yaml
dependencies:
flutter_easyloading: ^2.0.1
flutter_easyloading: ^2.1.0
```
## 导入
Expand Down Expand Up @@ -66,8 +66,30 @@ EasyLoading.showToast('Toast');
EasyLoading.dismiss();
```

添加 Loading 状态回调

```dart
EasyLoading.addStatusCallback((status) {
print('EasyLoading Status $status');
});
```

移除 Loading 状态回调

```dart
EasyLoading.removeCallback(statusCallback);
EasyLoading.removeAllCallbacks();
```

## 自定义

❗️**注意:**

- **`textColor``indicatorColor``progressColor``backgroundColor` 仅对 `EasyLoadingStyle.custom`有效。**

- **`maskColor` 仅对 `EasyLoadingMaskType.custom`有效。**

```dart
/// loading的样式, 默认[EasyLoadingStyle.dark].
EasyLoadingStyle loadingStyle;
Expand Down Expand Up @@ -138,6 +160,9 @@ Color maskColor;
/// 当loading展示的时候,是否允许用户操作.
bool userInteractions;
/// 点击背景是否关闭.
bool dismissOnTap;
/// 指示器自定义组件
Widget indicatorWidget;
Expand All @@ -151,12 +176,6 @@ Widget errorWidget;
Widget infoWidget;
```

❗️**注意:**

- **`textColor``indicatorColor``progressColor``backgroundColor` 仅对 `EasyLoadingStyle.custom`有效。**

- **`maskColor` 仅对 `EasyLoadingMaskType.custom`有效。**

因为 `EasyLoading` 是一个全局单例, 所以你可以在任意一个地方自定义它的样式:

```dart
Expand All @@ -166,11 +185,14 @@ EasyLoading.instance
..loadingStyle = EasyLoadingStyle.dark
..indicatorSize = 45.0
..radius = 10.0
..progressColor = Colors.yellow
..backgroundColor = Colors.green
..indicatorColor = Colors.yellow
..textColor = Colors.yellow
..maskColor = Colors.blue.withOpacity(0.5)
..userInteractions = true;
..userInteractions = true
..dismissOnTap = false
..customAnimation = CustomAnimation();
```

更多的指示器类型可查看 👉 [flutter_spinkit showcase](https://github.com/jogboms/flutter_spinkit#-showcase)
Expand Down
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flutter_easyloading
# Flutter EasyLoading

[![pub package](https://img.shields.io/pub/v/flutter_easyloading?style=flat)](https://pub.dev/packages/flutter_easyloading) [![pub points](https://badges.bar/flutter_easyloading/pub%20points)](https://pub.dev/packages/flutter_easyloading/score) [![popularity](https://badges.bar/flutter_easyloading/popularity)](https://pub.dev/packages/flutter_easyloading/score) [![likes](https://badges.bar/flutter_easyloading/likes)](https://pub.dev/packages/flutter_easyloading/score) [![license](https://img.shields.io/github/license/huangjianke/flutter_easyloading?style=flat)](https://github.com/huangjianke/flutter_easyloading) [![stars](https://img.shields.io/github/stars/huangjianke/flutter_easyloading?style=social)](https://github.com/huangjianke/flutter_easyloading)

Expand All @@ -16,7 +16,7 @@ Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
flutter_easyloading: ^2.0.1
flutter_easyloading: ^2.1.0
```
## Import
Expand Down Expand Up @@ -67,8 +67,30 @@ EasyLoading.showToast('Toast');
EasyLoading.dismiss();
```

Add loading status callback

```dart
EasyLoading.addStatusCallback((status) {
print('EasyLoading Status $status');
});
```

Remove loading status callback(s)

```dart
EasyLoading.removeCallback(statusCallback);
EasyLoading.removeAllCallbacks();
```

## Customize

❗️**Note:**

- **`textColor``indicatorColor``progressColor``backgroundColor` only used for `EasyLoadingStyle.custom`.**

- **`maskColor` only used for `EasyLoadingMaskType.custom`.**

```dart
/// loading style, default [EasyLoadingStyle.dark].
EasyLoadingStyle loadingStyle;
Expand Down Expand Up @@ -139,6 +161,9 @@ Color maskColor;
/// should allow user interactions while loading is displayed.
bool userInteractions;
/// should dismiss on user tap.
bool dismissOnTap;
/// indicator widget of loading
Widget indicatorWidget;
Expand All @@ -152,13 +177,6 @@ Widget errorWidget;
Widget infoWidget;
```

❗️**Note:**

- **`textColor``indicatorColor``progressColor``backgroundColor` only used for `EasyLoadingStyle.custom`.**

- **`maskColor` only used for `EasyLoadingMaskType.custom`.**


Because of `EasyLoading` is a singleton, so you can custom loading style any where like this:

```dart
Expand All @@ -168,11 +186,14 @@ EasyLoading.instance
..loadingStyle = EasyLoadingStyle.dark
..indicatorSize = 45.0
..radius = 10.0
..progressColor = Colors.yellow
..backgroundColor = Colors.green
..indicatorColor = Colors.yellow
..textColor = Colors.yellow
..maskColor = Colors.blue.withOpacity(0.5)
..userInteractions = true;
..userInteractions = true
..dismissOnTap = false
..customAnimation = CustomAnimation();
```

More indicatorType can see in 👉 [flutter_spinkit showcase](https://github.com/jogboms/flutter_spinkit#-showcase)
Expand Down
1 change: 1 addition & 0 deletions example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
967974c66177fcaca35ee5d47917254d
3 changes: 0 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -320,7 +319,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -376,7 +374,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down
26 changes: 20 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void configLoading() {
..textColor = Colors.yellow
..maskColor = Colors.blue.withOpacity(0.5)
..userInteractions = true
..dismissOnTap = false
..customAnimation = CustomAnimation();
}

Expand Down Expand Up @@ -63,7 +64,14 @@ class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
EasyLoading.addStatusCallback((status) {
print('EasyLoading Status $status');
if (status == EasyLoadingStatus.dismiss) {
_timer?.cancel();
}
});
EasyLoading.showSuccess('Use in initState');
// EasyLoading.removeCallbacks();
}

@override
Expand Down Expand Up @@ -100,17 +108,22 @@ class _MyHomePageState extends State<MyHomePage> {
FlatButton(
textColor: Colors.blue,
child: Text('dismiss'),
onPressed: () {
onPressed: () async {
_timer?.cancel();
EasyLoading.dismiss();
await EasyLoading.dismiss();
print('EasyLoading dismiss');
},
),
FlatButton(
textColor: Colors.blue,
child: Text('show'),
onPressed: () {
onPressed: () async {
_timer?.cancel();
EasyLoading.show(status: 'loading...');
await EasyLoading.show(
status: 'loading...',
maskType: EasyLoadingMaskType.black,
);
print('EasyLoading show');
},
),
FlatButton(
Expand All @@ -126,9 +139,10 @@ class _MyHomePageState extends State<MyHomePage> {
FlatButton(
textColor: Colors.blue,
child: Text('showSuccess'),
onPressed: () {
onPressed: () async {
_timer?.cancel();
EasyLoading.showSuccess('Great Success!');
await EasyLoading.showSuccess('Great Success!');
print('EasyLoading showSuccess');
},
),
FlatButton(
Expand Down
9 changes: 8 additions & 1 deletion example/lib/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ class _TestPageState extends State<TestPage> {
@override
void initState() {
super.initState();
// EasyLoading.show();
// EasyLoading.dismiss();
EasyLoading.showSuccess('Use in initState');
EasyLoading.addStatusCallback(statusCallback);
}

@override
void deactivate() {
EasyLoading.dismiss();
EasyLoading.removeCallback(statusCallback);
super.deactivate();
}

void statusCallback(EasyLoadingStatus status) {
print('Test EasyLoading Status $status');
}

void loadData() async {
try {
EasyLoading.show();
Expand Down
Loading

0 comments on commit ffaae47

Please sign in to comment.