tiktok_header.dart
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import 'package:flutter/material.dart';
import 'package:tapped/tapped.dart';
import 'select_text.dart';
class TikTokHeader extends StatefulWidget {
final Function? onSearch;
const TikTokHeader({
Key? key,
this.onSearch,
}) : super(key: key);
@override
_TikTokHeaderState createState() => _TikTokHeaderState();
}
class _TikTokHeaderState extends State<TikTokHeader> {
int currentSelect = 0;
@override
Widget build(BuildContext context) {
List<String> list = ['推荐', '本地'];
List<Widget> headList = [];
for (var i = 0; i < list.length; i++) {
headList.add(Expanded(
child: GestureDetector(
child: SelectText(
title: list[i],
isSelect: i == currentSelect,
),
onTap: () {
setState(() {
currentSelect = i;
});
},
),
));
}
Widget headSwitch = Row(
children: headList,
);
return Container(
// color: Colors.black.withOpacity(0.3),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Tapped(
child: Container(
color: Colors.black.withOpacity(0),
padding: const EdgeInsets.all(4),
alignment: Alignment.centerLeft,
child: Icon(
Icons.star,
color: Colors.white.withOpacity(0.66),
),
),
onTap: widget.onSearch,
),
),
Expanded(
flex: 1,
child: Container(
color: Colors.black.withOpacity(0),
alignment: Alignment.center,
child: headSwitch,
),
),
Expanded(
child: Tapped(
child: Container(
color: Colors.black.withOpacity(0),
padding: const EdgeInsets.all(4),
alignment: Alignment.centerRight,
child: Icon(
Icons.ios_share,
color: Colors.white.withOpacity(0.66),
),
),
),
),
],
),
);
}
}