Skip to content

Commit a389033

Browse files
authored
Merge pull request #38 from efoxTeam/dev
merge dev
2 parents ccf245c + fdcb5f1 commit a389033

File tree

18 files changed

+318
-54
lines changed

18 files changed

+318
-54
lines changed
Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
## **文档完善中**
1+
## **BottomNavigationBar**
2+
> Scaffold的属性,增加底部导航栏tab
3+
4+
### 构造函数
5+
```
6+
BottomNavigationBar({
7+
Key key,
8+
@required this.items,
9+
this.onTap,
10+
this.currentIndex = 0,
11+
BottomNavigationBarType type,
12+
this.fixedColor,
13+
this.iconSize = 24.0,
14+
})
15+
```
16+
17+
### 属性介绍
18+
- items: 数组类型,tab,通过BottomNavigationBarItem实现
19+
- onTap: 点击后回调函数,返回点击的数组下标,从0开始
20+
- currentIndex:当前激活的下标值
21+
- type: BottomNavigationBarType类型,默认fixed(固定位置大小,点击无动画效果),还有shifting(点击时有动画效果)
22+
> fixed: 固定大小,无动画效果。
23+
> shifting: 带有动画效果,只有激活的标签带有主题颜色,可自行增加默认颜色
24+
- fixedColor: 图标与字体颜色,当type的值为BottomNavigationBarType.shifting时,级别比较低。
25+
- iconSize:double类型,图标大小。
26+
27+
### 高级用法
28+
- 可以定义一个变量,通过setState方法改变currentIndex的值。Scaffold中的body属性可以使用PageView,实现body页面切换带动导航栏切换,可导航栏触发body页面切换。
29+
- BottomNavigationBarItem:属性items中的组件
30+
```
31+
BottomNavigationBarItem({
32+
@required this.icon,
33+
this.title,
34+
Widget activeIcon,
35+
this.backgroundColor,
36+
})
37+
```
38+
> title: 定义标题
39+
> icon: 图标
40+
> activeIcon: 选中时图标
Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
## **文档完善中**
1+
## **FloatingActionButton**
2+
> 在Scaffold中属性floatingActionButton实现FloatingActionButton,该组件是个圆形的浮层按钮,一般情况下child可用icon进行绘画。
3+
4+
### 构造函数
5+
```
6+
FloatingActionButton({
7+
Key key,
8+
this.child,
9+
this.tooltip,
10+
this.foregroundColor,
11+
this.backgroundColor,
12+
this.heroTag = const _DefaultHeroTag(),
13+
this.elevation = 6.0,
14+
this.highlightElevation = 12.0,
15+
double disabledElevation,
16+
@required this.onPressed,
17+
this.mini = false,
18+
this.shape = const CircleBorder(),
19+
this.clipBehavior = Clip.none,
20+
this.materialTapTargetSize,
21+
this.isExtended = false,
22+
})
23+
```
24+
25+
### 属性介绍
26+
- onPressed: 必填属性,函数调用,点击按钮后回调事件
27+
- child: 组件子组件内容,可通过Icon简单的增加图标
28+
- elevation:图标下阴影大小
29+
- highlightElevation: 点击后阴影扩散范围
30+
- tooltip:长按提示
31+
- foregroundColor:前景色,如图标、文字的颜色
32+
- backgroundColor:背景填充色
33+
- mini: 默认false,true时为迷你按钮
34+
35+

lib/components/widgetComp.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class IndexState extends State<Index> {
6363
void init() async {
6464
this._bodyList.length = 0;
6565
String mdText = await this.getMdFile(this.mdUrl);
66-
if (mdText.length > 30) {
66+
if (mdText.length > 30 || !this.model.config.state.isPro) {
6767
this
6868
._bodyList
6969
.add(await MarkDownComp.Index(mdText));

lib/config/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'development.dart' as Development;
22
import 'production.dart' as Production;
33

4-
const bool isPro = true;
4+
const bool isPro = false;
55

66
Object env = isPro ? Production.Config() : Development.Config();

lib/page/mine/index.dart

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
33
import 'package:efox_flutter/router/index.dart' show FluroRouter;
44

55
class _IndexState extends State<Index> {
6-
static String _version = '';
7-
86
@override
97
void initState() {
108
super.initState();
11-
_version = widget.model.config.state.version;
129
}
1310

1411
List<dynamic> _getList() {
@@ -19,16 +16,9 @@ class _IndexState extends State<Index> {
1916
'index': 0
2017
},
2118
{
22-
'name': AppLocalizations.$t('common.changeVersion') + ' ' + _version,
23-
'icon': 58919, // sync
24-
'index': 1,
25-
'show': !widget.model.config.state.isPro
26-
},
27-
{
28-
'name': AppLocalizations.$t('common.changeEnvironment'),
19+
'name': widget.model.config.state.isPro ? AppLocalizations.$t('mine.loadLocal') : AppLocalizations.$t('mine.loadNetwork'),
2920
'icon': 57539, // import_export
3021
'index': 2,
31-
'show': !widget.model.config.state.isPro
3222
},
3323
{
3424
'name': AppLocalizations.$t('common.compProgress'),
@@ -43,11 +33,6 @@ class _IndexState extends State<Index> {
4333
case 0:
4434
AppLocalizations.changeLanguage();
4535
break;
46-
case 1:
47-
widget.model.dispatch('config', 'setVersion').then((resp) {
48-
_version = widget.model.config.state.version;
49-
});
50-
break;
5136
case 2:
5237
widget.model.dispatch('config', 'setEnv');
5338
break;

lib/widget/navigator/bottomnavigationbar/demo.dart

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,80 @@ class _IndexState extends State<Index> {
1111
super.initState();
1212
}
1313

14+
int _index = 0;
1415
@override
1516
Widget build(BuildContext context) {
1617
return Scaffold(
1718
appBar: AppBar(
1819
title: Text('BottomNavigationBar'),
1920
),
2021
body: Center(
21-
child: Text('更新中'),
22+
child: Column(
23+
mainAxisAlignment: MainAxisAlignment.center,
24+
children: <Widget>[
25+
Divider(),
26+
Text(
27+
'在Scaffold的bottomNavigationBar属性,增加BottomNavigationBar组件,实现底部导航栏。',
28+
textAlign: TextAlign.center,
29+
),
30+
Divider(),
31+
Text(
32+
'属性children通过BottomNavigationBarItem定义。',
33+
textAlign: TextAlign.center,
34+
),
35+
Divider(),
36+
Text(
37+
'BottomNavigationBar能通过onTap增加点击事件',
38+
textAlign: TextAlign.center,
39+
),
40+
],
41+
),
42+
),
43+
bottomNavigationBar: BottomNavigationBar(
44+
currentIndex: _index,
45+
onTap: (index) {
46+
setState(() {
47+
_index = index;
48+
});
49+
},
50+
fixedColor: Colors.purple,
51+
// type: BottomNavigationBarType.shifting,
52+
items: [
53+
BottomNavigationBarItem(
54+
title: Text(
55+
'导航一',
56+
style: TextStyle(
57+
color: Colors.blue,
58+
),
59+
),
60+
icon: Icon(
61+
Icons.play_circle_filled,
62+
color: Colors.blue,
63+
),
64+
),
65+
BottomNavigationBarItem(
66+
title: Text(
67+
'导航二',
68+
style: TextStyle(
69+
color: Colors.blue,
70+
),
71+
),
72+
icon: Icon(
73+
Icons.pause_circle_filled,
74+
color: Colors.blue,
75+
),
76+
),
77+
BottomNavigationBarItem(
78+
title: Text(
79+
'导航三',
80+
style: TextStyle(
81+
color: Colors.blue,
82+
),
83+
),
84+
icon: Icon(Icons.cloud_circle,
85+
color: Colors.blue,),
86+
),
87+
],
2288
),
2389
);
2490
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Index extends StatefulWidget {
4+
@override
5+
State<StatefulWidget> createState() => _IndexState();
6+
}
7+
8+
class _IndexState extends State<Index> {
9+
@override
10+
void initState() {
11+
super.initState();
12+
}
13+
14+
int _index = 0;
15+
@override
16+
Widget build(BuildContext context) {
17+
return Scaffold(
18+
appBar: AppBar(
19+
title: Text('BottomNavigationBar'),
20+
),
21+
body: PageView(
22+
onPageChanged: (index) {
23+
setState(() {
24+
_index = index;
25+
});
26+
},
27+
children: [
28+
Center(
29+
child: Column(
30+
children: [
31+
Text('页面一'),
32+
Text('左右滑动切换页面哦~~~'),
33+
],
34+
),
35+
),
36+
Center(
37+
child: Column(
38+
mainAxisAlignment: MainAxisAlignment.center,
39+
children: [
40+
Text('页面二'),
41+
Text('左右滑动切换页面哦~~~'),
42+
],
43+
),
44+
),
45+
Center(
46+
child: Column(
47+
mainAxisAlignment: MainAxisAlignment.end,
48+
children: [
49+
Text('页面三'),
50+
Text('左右滑动切换页面哦~~~'),
51+
],
52+
),
53+
),
54+
]),
55+
bottomNavigationBar: BottomNavigationBar(
56+
currentIndex: _index,
57+
type: BottomNavigationBarType.shifting,
58+
onTap: (index) {
59+
setState(() {
60+
_index = index;
61+
});
62+
},
63+
fixedColor: Colors.red,
64+
iconSize: 28,
65+
items: [
66+
BottomNavigationBarItem(
67+
title: Text(
68+
'导航一',
69+
style: TextStyle(color: Colors.red),
70+
),
71+
icon: Icon(
72+
Icons.navigate_before,
73+
color: Colors.redAccent,
74+
),
75+
),
76+
BottomNavigationBarItem(
77+
title: Text(
78+
'导航二',
79+
style: TextStyle(color: Colors.red),
80+
),
81+
icon: Icon(
82+
Icons.notifications_active,
83+
color: Colors.redAccent,
84+
),
85+
),
86+
BottomNavigationBarItem(
87+
title: Text(
88+
'导航三',
89+
style: TextStyle(color: Colors.red),
90+
),
91+
icon: Icon(
92+
Icons.navigate_next,
93+
color: Colors.redAccent,
94+
),
95+
),
96+
],
97+
),
98+
);
99+
}
100+
}

lib/widget/navigator/bottomnavigationbar/index.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
33
import 'demo.dart' as Demo;
4+
import 'demo_with_pageview.dart' as DemoWithPageView;
45

56
class Index extends StatefulWidget {
67
static String title = 'BottomNavigationBar';
78
static String mdUrl = 'docs/widget/navigator/bottomnavigationbar/index.md';
8-
static String originCodeUrl = 'https://docs.flutter.io/flutter/widgets/BottomNavigationBar-class.html';
9+
static String originCodeUrl = 'https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html';
910

1011
@override
1112
_IndexState createState() => new _IndexState();
@@ -20,6 +21,7 @@ class _IndexState extends State<Index> {
2021
mdUrl: Index.mdUrl,
2122
demoChild: [
2223
Demo.Index(),
24+
DemoWithPageView.Index(),
2325
],
2426
);
2527
}

lib/widget/navigator/floatingactionbutton/demo.dart

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Index extends StatefulWidget {
66
}
77

88
class _IndexState extends State<Index> {
9+
int count = 0;
910
@override
1011
void initState() {
1112
super.initState();
@@ -16,9 +17,40 @@ class _IndexState extends State<Index> {
1617
return Scaffold(
1718
appBar: AppBar(
1819
title: Text('FloatingActionButton'),
20+
automaticallyImplyLeading: false,
1921
),
2022
body: Center(
21-
child: Text('更新中'),
23+
child: Column(
24+
mainAxisAlignment: MainAxisAlignment.center,
25+
children: <Widget>[
26+
Text(
27+
'Click FloatingActionButton to add Count',
28+
style: TextStyle(fontSize: 16),
29+
),
30+
Text(
31+
'count: $count',
32+
style: TextStyle(fontSize: 24),
33+
)
34+
],
35+
),
36+
),
37+
floatingActionButton: FloatingActionButton(
38+
clipBehavior: Clip.antiAliasWithSaveLayer,
39+
tooltip: '长按后的提示',
40+
foregroundColor:Colors.blue, // 该颜色被Icon覆盖
41+
backgroundColor: Colors.red, // 背景填充色
42+
elevation: 10, // 下阴影大小
43+
highlightElevation: 50, // 阴影扩散范围
44+
mini: true,
45+
child: Icon(
46+
Icons.notifications_active,
47+
color: Colors.white,
48+
),
49+
onPressed: () {
50+
setState(() {
51+
count++;
52+
});
53+
},
2254
),
2355
);
2456
}

0 commit comments

Comments
 (0)