Skip to content

Commit a7d6c13

Browse files
committed
feat: 新的搜索外观
1 parent 03e288c commit a7d6c13

File tree

1 file changed

+81
-87
lines changed

1 file changed

+81
-87
lines changed

lib/pages/search/view.dart

Lines changed: 81 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -28,105 +28,99 @@ class _SearchPageState extends State<SearchPage> {
2828
Widget _buildAndroidSearch(BuildContext context) {
2929
return Scaffold(
3030
appBar: AppBar(
31-
title: Text('common.search'.i18n),
31+
title: TextField(
32+
decoration: InputDecoration(
33+
hintText: 'search.hint-text'.i18n,
34+
border: InputBorder.none,
35+
),
36+
controller: TextEditingController(
37+
text: c.search.value,
38+
),
39+
onChanged: (value) {
40+
if (value.isEmpty) {
41+
c.search.value = '';
42+
}
43+
},
44+
onSubmitted: (value) {
45+
c.search.value = value;
46+
},
47+
),
48+
flexibleSpace: Obx(
49+
() => Column(
50+
children: [
51+
if (c.finishCount != c.searchResultList.length)
52+
Padding(
53+
padding: const EdgeInsets.symmetric(horizontal: 16),
54+
child: LinearProgressIndicator(
55+
value: (c.finishCount / c.searchResultList.length),
56+
minHeight: 2,
57+
),
58+
),
59+
],
60+
),
61+
),
3262
),
3363
body: NestedScrollView(
34-
physics: const ClampingScrollPhysics(),
3564
headerSliverBuilder: (context, innerBoxIsScrolled) {
3665
return [
37-
Obx(
38-
() => SliverAppBar(
39-
backgroundColor: Theme.of(context).colorScheme.background,
40-
flexibleSpace: Column(
41-
children: [
42-
Padding(
43-
padding: const EdgeInsets.symmetric(horizontal: 16),
44-
child: TextField(
45-
controller: TextEditingController(text: c.search.value),
46-
decoration: InputDecoration(
47-
border: const OutlineInputBorder(
48-
borderRadius: BorderRadius.all(Radius.circular(20)),
49-
),
50-
hintText: "search.hint-text".i18n,
51-
prefixIcon: const Icon(Icons.search),
52-
),
53-
onChanged: (value) {
54-
if (value.isEmpty) {
55-
c.search.value = '';
66+
SliverAppBar(
67+
flexibleSpace: Obx(
68+
() => SizedBox(
69+
height: 60,
70+
child: ListView(
71+
padding: const EdgeInsets.symmetric(horizontal: 16),
72+
scrollDirection: Axis.horizontal,
73+
children: [
74+
ChoiceChip(
75+
label: Text('search.all'.i18n),
76+
selected: c.cuurentExtensionType.value == null,
77+
onSelected: (value) {
78+
if (value) {
79+
c.getRuntime();
5680
}
5781
},
58-
onSubmitted: (value) {
59-
c.search(value);
82+
),
83+
const SizedBox(width: 8),
84+
ChoiceChip(
85+
label: Text('extension-type.video'.i18n),
86+
selected: c.cuurentExtensionType.value ==
87+
ExtensionType.bangumi,
88+
onSelected: (value) {
89+
if (value) {
90+
c.getRuntime(type: ExtensionType.bangumi);
91+
}
6092
},
6193
),
62-
),
63-
const SizedBox(height: 8),
64-
SizedBox(
65-
height: 60,
66-
child: ListView(
67-
padding: const EdgeInsets.symmetric(horizontal: 16),
68-
scrollDirection: Axis.horizontal,
69-
children: [
70-
ChoiceChip(
71-
label: Text('search.all'.i18n),
72-
selected: c.cuurentExtensionType.value == null,
73-
onSelected: (value) {
74-
if (value) {
75-
c.getRuntime();
76-
}
77-
},
78-
),
79-
const SizedBox(width: 8),
80-
ChoiceChip(
81-
label: Text('extension-type.video'.i18n),
82-
selected: c.cuurentExtensionType.value ==
83-
ExtensionType.bangumi,
84-
onSelected: (value) {
85-
if (value) {
86-
c.getRuntime(type: ExtensionType.bangumi);
87-
}
88-
},
89-
),
90-
const SizedBox(width: 8),
91-
ChoiceChip(
92-
label: Text('extension-type.comic'.i18n),
93-
selected: c.cuurentExtensionType.value ==
94-
ExtensionType.manga,
95-
onSelected: (value) {
96-
if (value) {
97-
c.getRuntime(type: ExtensionType.manga);
98-
}
99-
},
100-
),
101-
const SizedBox(width: 8),
102-
ChoiceChip(
103-
label: Text('extension-type.novel'.i18n),
104-
selected: c.cuurentExtensionType.value ==
105-
ExtensionType.fikushon,
106-
onSelected: (value) {
107-
if (value) {
108-
c.getRuntime(
109-
type: ExtensionType.fikushon,
110-
);
111-
}
112-
},
113-
),
114-
],
94+
const SizedBox(width: 8),
95+
ChoiceChip(
96+
label: Text('extension-type.comic'.i18n),
97+
selected:
98+
c.cuurentExtensionType.value == ExtensionType.manga,
99+
onSelected: (value) {
100+
if (value) {
101+
c.getRuntime(type: ExtensionType.manga);
102+
}
103+
},
115104
),
116-
),
117-
// 进度
118-
if (c.finishCount != c.searchResultList.length)
119-
Padding(
120-
padding: const EdgeInsets.symmetric(horizontal: 16),
121-
child: LinearProgressIndicator(
122-
value: (c.finishCount / c.searchResultList.length),
123-
),
105+
const SizedBox(width: 8),
106+
ChoiceChip(
107+
label: Text('extension-type.novel'.i18n),
108+
selected: c.cuurentExtensionType.value ==
109+
ExtensionType.fikushon,
110+
onSelected: (value) {
111+
if (value) {
112+
c.getRuntime(
113+
type: ExtensionType.fikushon,
114+
);
115+
}
116+
},
124117
),
125-
],
118+
],
119+
),
126120
),
127-
expandedHeight: 140,
128-
collapsedHeight: 140,
129121
),
122+
floating: true,
123+
snap: true,
130124
)
131125
];
132126
},

0 commit comments

Comments
 (0)