-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from shinyina/feature/result
feat(Result结果): 新增Result结果组件
- Loading branch information
Showing
15 changed files
with
365 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## API | ||
### TDResult | ||
#### 默认构造方法 | ||
|
||
| 参数 | 类型 | 默认值 | 说明 | | ||
| --- | --- | --- | --- | | ||
| description | String? | - | 描述文本,用于提供额外信息 | | ||
| icon | Widget? | - | 图标组件,用于在结果中显示一个图标 | | ||
| titleStyle | TextStyle? | - | 自定义字体样式,用于设置标题文本的样式 | | ||
| theme | TDResultTheme | - | 主题样式,定义了结果组件的视觉风格 | | ||
| title | String | - | 标题文本,显示结果的主要信息 | |
7 changes: 7 additions & 0 deletions
7
tdesign-component/example/assets/code/result._buildBasicResultDefault.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
TDResult _buildBasicResultDefault(BuildContext context) { | ||
return const TDResult( | ||
title: '默认状态', | ||
theme: TDResultTheme.defaultTheme, | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
tdesign-component/example/assets/code/result._buildBasicResultError.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
TDResult _buildBasicResultError(BuildContext context) { | ||
return const TDResult( | ||
title: '失败状态', | ||
theme: TDResultTheme.error, | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
tdesign-component/example/assets/code/result._buildBasicResultSuccess.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
TDResult _buildBasicResultSuccess(BuildContext context) { | ||
return const TDResult( | ||
title: '成功状态', | ||
theme: TDResultTheme.success, | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
tdesign-component/example/assets/code/result._buildBasicResultWarning.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
TDResult _buildBasicResultWarning(BuildContext context) { | ||
return const TDResult( | ||
title: '警示状态', | ||
theme: TDResultTheme.warning, | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
tdesign-component/example/assets/code/result._buildCustomResultContent.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
Widget _buildCustomResult(BuildContext context) { | ||
return TDResult( | ||
title: '自定义结果', | ||
icon: Image.asset('assets/img/illustration.png'), | ||
description: '描述文字'); | ||
} |
8 changes: 8 additions & 0 deletions
8
tdesign-component/example/assets/code/result._buildResultWithDescriptionDefault.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
TDResult _buildResultWithDescriptionDefault(BuildContext context) { | ||
return const TDResult( | ||
title: '默认状态', | ||
theme: TDResultTheme.defaultTheme, | ||
description: '描述文字', | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
tdesign-component/example/assets/code/result._buildResultWithDescriptionError.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
TDResult _buildResultWithDescriptionError(BuildContext context) { | ||
return const TDResult( | ||
title: '失败状态', | ||
theme: TDResultTheme.error, | ||
description: '描述文字', | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
tdesign-component/example/assets/code/result._buildResultWithDescriptionSuccess.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
TDResult _buildResultWithDescriptionSuccess(BuildContext context) { | ||
return const TDResult( | ||
title: '成功状态', | ||
theme: TDResultTheme.success, | ||
description: '描述文字', | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
tdesign-component/example/assets/code/result._buildResultWithDescriptionWarning.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
TDResult _buildResultWithDescriptionWarning(BuildContext context) { | ||
return const TDResult( | ||
title: '警示状态', | ||
theme: TDResultTheme.warning, | ||
description: '描述文字', | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:tdesign_flutter/tdesign_flutter.dart'; | ||
import '../../base/example_widget.dart'; | ||
import '../annotation/demo.dart'; | ||
|
||
class TDResultPage extends StatefulWidget { | ||
const TDResultPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<TDResultPage> createState() => _TDResultPageState(); | ||
} | ||
|
||
class _TDResultPageState extends State<TDResultPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return ExamplePage( | ||
title: 'Result 结果', | ||
desc: '反馈结果状态。', | ||
exampleCodeGroup: 'result', | ||
children: [ | ||
ExampleModule(title: '组件类型', children: [ | ||
ExampleItem( | ||
desc: '基础结果', ignoreCode: true, builder: _buildBasicResult), | ||
ExampleItem( | ||
desc: '带描述的结果', | ||
ignoreCode: true, | ||
builder: _buildResultWithDescription), | ||
ExampleItem( | ||
desc: '自定义结果', ignoreCode: true, builder: _buildCustomResult), | ||
ExampleItem( | ||
desc: '页面示例', ignoreCode: true, builder: _buildPageExample), | ||
]), | ||
], | ||
); | ||
} | ||
|
||
Widget _buildBasicResult(BuildContext context) { | ||
return Column( | ||
children: [ | ||
CodeWrapper( | ||
builder: _buildBasicResultSuccess, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildBasicResultError, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildBasicResultWarning, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildBasicResultDefault, | ||
), | ||
], | ||
); | ||
} | ||
|
||
Widget _buildResultWithDescription(BuildContext context) { | ||
return Column( | ||
children: [ | ||
CodeWrapper( | ||
builder: _buildResultWithDescriptionSuccess, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildResultWithDescriptionError, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildResultWithDescriptionWarning, | ||
), | ||
const SizedBox(height: 48), | ||
CodeWrapper( | ||
builder: _buildResultWithDescriptionDefault, | ||
), | ||
], | ||
); | ||
} | ||
|
||
Widget _buildCustomResult(BuildContext context) { | ||
return CodeWrapper( | ||
builder: _buildCustomResultContent, | ||
); | ||
} | ||
|
||
Widget _buildPageExample(BuildContext context) { | ||
return TDButton( | ||
text: '页面示例', | ||
theme: TDButtonTheme.primary, | ||
size: TDButtonSize.large, | ||
type: TDButtonType.outline, | ||
isBlock: true, | ||
onTap: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Result 结果'), | ||
), | ||
body: Column( | ||
children: [ | ||
const SizedBox(height: 48), | ||
const TDResult( | ||
title: '成功状态', | ||
theme: TDResultTheme.success, | ||
description: '描述文字', | ||
), | ||
const SizedBox(height: 48), | ||
TDButton( | ||
text: '返回', | ||
theme: TDButtonTheme.primary, | ||
size: TDButtonSize.large, | ||
type: TDButtonType.outline, | ||
isBlock: true, | ||
onTap: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildBasicResultSuccess(BuildContext context) { | ||
return const TDResult( | ||
title: '成功状态', | ||
theme: TDResultTheme.success, | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildBasicResultError(BuildContext context) { | ||
return const TDResult( | ||
title: '失败状态', | ||
theme: TDResultTheme.error, | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildBasicResultWarning(BuildContext context) { | ||
return const TDResult( | ||
title: '警示状态', | ||
theme: TDResultTheme.warning, | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildBasicResultDefault(BuildContext context) { | ||
return const TDResult( | ||
title: '默认状态', | ||
theme: TDResultTheme.defaultTheme, | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildResultWithDescriptionSuccess(BuildContext context) { | ||
return const TDResult( | ||
title: '成功状态', | ||
theme: TDResultTheme.success, | ||
description: '描述文字', | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildResultWithDescriptionError(BuildContext context) { | ||
return const TDResult( | ||
title: '失败状态', | ||
theme: TDResultTheme.error, | ||
description: '描述文字', | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildResultWithDescriptionWarning(BuildContext context) { | ||
return const TDResult( | ||
title: '警示状态', | ||
theme: TDResultTheme.warning, | ||
description: '描述文字', | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildResultWithDescriptionDefault(BuildContext context) { | ||
return const TDResult( | ||
title: '默认状态', | ||
theme: TDResultTheme.defaultTheme, | ||
description: '描述文字', | ||
); | ||
} | ||
|
||
@Demo(group: 'result') | ||
TDResult _buildCustomResultContent(BuildContext context) { | ||
return TDResult( | ||
title: '自定义结果', | ||
icon: Image.asset('assets/img/illustration.png'), | ||
description: '描述文字', | ||
); | ||
} | ||
} |
Oops, something went wrong.