Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add attribute emptyImage #344

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/content_failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/network_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/no_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ group:
# BrnAbnormalStateWidget

## 一、效果总览

![](./img/empty_state_intro.png)

<img src="./img/empty_state_1.png" style="zoom:50%;" /><img src="./img/empty_state_2.png" style="zoom:50%;" /><img src="./img/empty_state_3.png" style="zoom:50%;" /><img src="./img/empty_state_4.png" style="zoom:50%;" /><img src="./img/empty_state_5.png" style="zoom:50%;" />

## 二、描述

Expand Down Expand Up @@ -76,7 +74,7 @@ BrnAbnormalStateWidget({
```dart
BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/content_failed.png',
scale: 3.0,
),
isCenterVertical: true,
Expand All @@ -95,13 +93,12 @@ BrnAbnormalStateWidget(

```dart
BrnAbnormalStateWidget(
isCenterVertical: true,
img: Image.asset(
'assets/image/empty_state.png',
scale: 3.0,
),
title: BrnStrings.noData,
)
img: Image.asset(
'assets/image/network_error.png',
scale: 3.0,
),
title: '网络数据异常',
);
```

### 效果 3:大模块空态
Expand All @@ -110,12 +107,12 @@ BrnAbnormalStateWidget(

```dart
BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
scale: 3.0,
),
content: '您的门店暂无用户',
)
img: Image.asset(
'assets/image/no_data.png',
scale: 3.0,
),
content: '您的门店暂无用户',
);
```

### 效果 4:单按钮效果
Expand All @@ -124,18 +121,18 @@ BrnAbnormalStateWidget(

```dart
BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
scale: 3.0,
),
title: "这是副标题内容这是副标题内容这是副标",
content: '您的门店暂无用户',
operateAreaType: OperateAreaType.SingleButton,
operateTexts: ["切换账号"],
action: (_) {
BrnToast.show("第$_个按钮被点击了", context);
},
)
img: Image.asset(
'assets/image/no_data.png',
scale: 3.0,
),
title: "这是副标题内容这是副标题内容这是副标",
content: '您的门店暂无用户',
operateAreaType: OperateAreaType.singleButton,
operateTexts: ["切换账号"],
action: (_) {
BrnToast.show("第$_个按钮被点击了", context);
},
);
```

### 效果 5:双按钮效果
Expand All @@ -144,16 +141,16 @@ BrnAbnormalStateWidget(

```dart
BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
scale: 3.0,
),
title: "暂无",
content: '您还没有在维护的信息哦',
operateAreaType: OperateAreaType.DoubleButton,
operateTexts: ['去添加', '去修改'],
action: (_) {
BrnToast.show("第$_个按钮被点击了", context);
},
)
img: Image.asset(
'assets/image/no_data.png',
scale: 3.0,
),
title: "暂无",
content: '您还没有在维护的信息哦',
operateAreaType: OperateAreaType.doubleButton,
operateTexts: ['去添加', '去修改'],
action: (_) {
BrnToast.show("第$_个按钮被点击了", context);
},
);
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ BrnSingleSelectCityPage({
this.showSearchBar = true,
this.locationText = '',
this.onValueChanged,
this.emptyImage,
});
```

Expand All @@ -46,6 +47,7 @@ BrnSingleSelectCityPage({
| cityList | `List<BrnSelectCityModel>?` | 城市列表 | 否 | |
| onValueChanged | ValueChanged<BrnSelectCityModel>? | 点击时间 | 否 | |
| hotCityList | `List<BrnSelectCityModel>?` | 热门推荐城市列表 | 否 | |
| emptyImage | `Image?` | 暂无搜索结果页面占位图 | 否 | |

### 其它数据

Expand All @@ -72,6 +74,9 @@ final List<BrnSelectCityModel> hotCityList;

/// 单选项 点击的回调
final ValueChanged<BrnSelectCityModel>? onValueChanged;

/// 空页面中间展位图展示
final Image? emptyImage;

///城市信息
BrnSelectCityModel {
Expand Down
Binary file added example/assets/image/content_failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/assets/image/network_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/assets/image/no_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions example/lib/sample/components/empty/abnormal_state_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AbnomalStateExample extends StatelessWidget {
case 0:
widget = BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/content_failed.png',
scale: 3.0,
),
isCenterVertical: true,
Expand All @@ -39,25 +39,25 @@ class AbnomalStateExample extends StatelessWidget {
widget = BrnAbnormalStateWidget(
isCenterVertical: true,
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/no_data.png',
scale: 3.0,
),
title: BrnStrings.noData,
title: '暂无数据',
);
break;
case 2:
widget = BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/network_error.png',
scale: 3.0,
),
title: '暂无数据',
title: '网络数据异常',
);
break;
case 3:
widget = BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/no_data.png',
scale: 3.0,
),
content: '您的门店暂无用户',
Expand All @@ -66,7 +66,7 @@ class AbnomalStateExample extends StatelessWidget {
case 4:
widget = BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/no_data.png',
scale: 3.0,
),
title: "这是副标题内容这是副标题内容这是副标",
Expand All @@ -81,7 +81,7 @@ class AbnomalStateExample extends StatelessWidget {
case 5:
widget = BrnAbnormalStateWidget(
img: Image.asset(
'assets/image/empty_state.png',
'assets/image/no_data.png',
scale: 3.0,
),
title: "暂无",
Expand Down
6 changes: 3 additions & 3 deletions lib/src/components/empty/brn_empty_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ class BrnAbnormalStateUtils {
{Image? img, BrnEmptyStatusIndexedActionClickCallback? action}) {
if (AbnormalState.getDataFailed == status) {
return BrnAbnormalStateWidget(
img: img ?? BrunoTools.getAssetImage(BrnAsset.emptyState),
img: img ?? BrunoTools.getAssetImage(BrnAsset.contentFailed),
title: BrnStrings.getDateFailed,
operateTexts: <String>[BrnStrings.clickPageRetry],
action: action,
);
} else if (AbnormalState.networkConnectError == status) {
return BrnAbnormalStateWidget(
img: img ?? BrunoTools.getAssetImage(BrnAsset.emptyState),
img: img ?? BrunoTools.getAssetImage(BrnAsset.networkError),
title: BrnStrings.networkConnectError,
operateTexts: <String>[BrnStrings.clickPageRetry],
action: action,
);
} else if (AbnormalState.noData == status) {
return BrnAbnormalStateWidget(
img: img ?? BrunoTools.getAssetImage(BrnAsset.emptyState),
img: img ?? BrunoTools.getAssetImage(BrnAsset.noData),
title: BrnStrings.noData,
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class BrnSingleSelectCityPage extends StatefulWidget {
/// 单选项 点击的回调
final ValueChanged<BrnSelectCityModel>? onValueChanged;

/// 空页面中间展位图展示
final Image? emptyImage;

BrnSingleSelectCityPage({
this.appBarTitle = '',
this.hotCityTitle = '',
Expand All @@ -46,6 +49,7 @@ class BrnSingleSelectCityPage extends StatefulWidget {
this.showSearchBar = true,
this.locationText = '',
this.onValueChanged,
this.emptyImage,
});

@override
Expand Down Expand Up @@ -359,7 +363,7 @@ class _BrnSingleSelectCityPageState extends State<BrnSingleSelectCityPage> {
Widget _noDataWidget() {
return Container(
child: BrnAbnormalStateWidget(
img: BrunoTools.getAssetImage(BrnAsset.emptyState),
img: widget.emptyImage ?? BrunoTools.getAssetImage(BrnAsset.noData),
title: BrnStrings.noSearchData,
),
);
Expand Down
5 changes: 4 additions & 1 deletion lib/src/constants/brn_asset_constants.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
class BrnAsset {
const BrnAsset._();

static const String emptyState = "images/empty_state.png";
static const String contentFailed = "images/content_failed.png";
static const String noData = "images/no_data.png";
static const String networkError = "images/network_error.png";

static const String stepTitle = 'images/img_step_title.png';

static const String refreshArrowUp = "images/refresh_arrow_up.png";
Expand Down