Skip to content

Commit 4b8b7fb

Browse files
committed
feat:首页增加点击展开收缩功能
1 parent 614bc57 commit 4b8b7fb

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

lib/page/component/index.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class _IndexState extends State<Index> {
6565
return Container(
6666
// padding: EdgeInsets.all(10),
6767
child: ListTile(
68+
onTap: () {
69+
this.tabClick(index);
70+
},
6871
leading: Icon(
6972
IconData(
7073
widgetsItem.code,
@@ -125,6 +128,15 @@ class _IndexState extends State<Index> {
125128
);
126129
}
127130

131+
tabClick (index) {
132+
if (index == this._isExpandedIndex) {
133+
index = -1;
134+
}
135+
setState(() {
136+
this._isExpandedIndex = index;
137+
});
138+
}
139+
128140
Widget build(BuildContext context) {
129141
// 实例化语言包
130142
return Scaffold(
@@ -146,12 +158,7 @@ class _IndexState extends State<Index> {
146158
},
147159
),
148160
expansionCallback: (index, flag) {
149-
if (flag) {
150-
index = -1;
151-
}
152-
setState(() {
153-
this._isExpandedIndex = index;
154-
});
161+
this.tabClick(index);
155162
},
156163
),
157164
),

lib/page/mine/index.dart

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ class _IndexState extends State<Index> {
1616
{
1717
'name': AppLocalizations.$t('common.changeLanguage'),
1818
'icon': 59540, // language
19+
'index': 0
1920
},
2021
{
2122
'name': AppLocalizations.$t('common.changeVersion') + ' ' + _version,
2223
'icon': 58919, // sync
24+
'index': 1
2325
},
2426
{
2527
'name': AppLocalizations.$t('common.changeEnvironment'),
2628
'icon': 57539, // import_export
29+
'index': 2,
30+
'show': !widget.model.config.state.isPro
2731
},
2832
{
2933
'name': AppLocalizations.$t('common.compProgress'),
3034
'icon': 57709, // low_priority
35+
'index': 3
3136
}
3237
];
3338
}
@@ -48,7 +53,7 @@ class _IndexState extends State<Index> {
4853
case 3:
4954
FluroRouter.router.navigateTo(
5055
context,
51-
'/webview?url=${Uri.encodeComponent(widget.model.config.state.env.githubWeb)}&title=${AppLocalizations.$t('common.compProgress')}',
56+
'/webview?url=${Uri.encodeComponent(widget.model.config.state.env.githubWeb)}&title=${Uri.encodeComponent(AppLocalizations.$t('common.compProgress'))}',
5257
);
5358
break;
5459
}
@@ -79,6 +84,7 @@ class _IndexState extends State<Index> {
7984
];
8085
},
8186
body: Builder(builder: (context) {
87+
List list = this._getList();
8288
return CustomScrollView(
8389
slivers: <Widget>[
8490
// SliverOverlapInjector与SliverOverlapAbsorber是相对成立的,
@@ -92,19 +98,24 @@ class _IndexState extends State<Index> {
9298
SliverList(
9399
delegate: SliverChildBuilderDelegate(
94100
(context, index) {
95-
return ListTile(
96-
onTap: () {
97-
this.actionsEvent(index);
98-
},
99-
leading: Icon(
100-
IconData(
101-
this._getList()[index]['icon'],
102-
fontFamily: 'MaterialIcons',
103-
matchTextDirection: true,
101+
dynamic item = list[index];
102+
if (item['show'] ?? true) {
103+
return ListTile(
104+
onTap: () {
105+
this.actionsEvent(item['index']);
106+
},
107+
leading: Icon(
108+
IconData(
109+
item['icon'],
110+
fontFamily: 'MaterialIcons',
111+
matchTextDirection: true,
112+
),
104113
),
105-
),
106-
title: Text('${this._getList()[index]['name']}'),
107-
);
114+
title: Text('${item['name']}'),
115+
);
116+
} else {
117+
return Container();
118+
}
108119
},
109120
childCount: this._getList().length,
110121
),

0 commit comments

Comments
 (0)