Skip to content

Commit

Permalink
feat: 新的搜索外观
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Aug 13, 2023
1 parent 03e288c commit a7d6c13
Showing 1 changed file with 81 additions and 87 deletions.
168 changes: 81 additions & 87 deletions lib/pages/search/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,105 +28,99 @@ class _SearchPageState extends State<SearchPage> {
Widget _buildAndroidSearch(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('common.search'.i18n),
title: TextField(
decoration: InputDecoration(
hintText: 'search.hint-text'.i18n,
border: InputBorder.none,
),
controller: TextEditingController(
text: c.search.value,
),
onChanged: (value) {
if (value.isEmpty) {
c.search.value = '';
}
},
onSubmitted: (value) {
c.search.value = value;
},
),
flexibleSpace: Obx(
() => Column(
children: [
if (c.finishCount != c.searchResultList.length)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: LinearProgressIndicator(
value: (c.finishCount / c.searchResultList.length),
minHeight: 2,
),
),
],
),
),
),
body: NestedScrollView(
physics: const ClampingScrollPhysics(),
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
Obx(
() => SliverAppBar(
backgroundColor: Theme.of(context).colorScheme.background,
flexibleSpace: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextField(
controller: TextEditingController(text: c.search.value),
decoration: InputDecoration(
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
hintText: "search.hint-text".i18n,
prefixIcon: const Icon(Icons.search),
),
onChanged: (value) {
if (value.isEmpty) {
c.search.value = '';
SliverAppBar(
flexibleSpace: Obx(
() => SizedBox(
height: 60,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
children: [
ChoiceChip(
label: Text('search.all'.i18n),
selected: c.cuurentExtensionType.value == null,
onSelected: (value) {
if (value) {
c.getRuntime();
}
},
onSubmitted: (value) {
c.search(value);
),
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.video'.i18n),
selected: c.cuurentExtensionType.value ==
ExtensionType.bangumi,
onSelected: (value) {
if (value) {
c.getRuntime(type: ExtensionType.bangumi);
}
},
),
),
const SizedBox(height: 8),
SizedBox(
height: 60,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
children: [
ChoiceChip(
label: Text('search.all'.i18n),
selected: c.cuurentExtensionType.value == null,
onSelected: (value) {
if (value) {
c.getRuntime();
}
},
),
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.video'.i18n),
selected: c.cuurentExtensionType.value ==
ExtensionType.bangumi,
onSelected: (value) {
if (value) {
c.getRuntime(type: ExtensionType.bangumi);
}
},
),
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.comic'.i18n),
selected: c.cuurentExtensionType.value ==
ExtensionType.manga,
onSelected: (value) {
if (value) {
c.getRuntime(type: ExtensionType.manga);
}
},
),
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.novel'.i18n),
selected: c.cuurentExtensionType.value ==
ExtensionType.fikushon,
onSelected: (value) {
if (value) {
c.getRuntime(
type: ExtensionType.fikushon,
);
}
},
),
],
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.comic'.i18n),
selected:
c.cuurentExtensionType.value == ExtensionType.manga,
onSelected: (value) {
if (value) {
c.getRuntime(type: ExtensionType.manga);
}
},
),
),
// 进度
if (c.finishCount != c.searchResultList.length)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: LinearProgressIndicator(
value: (c.finishCount / c.searchResultList.length),
),
const SizedBox(width: 8),
ChoiceChip(
label: Text('extension-type.novel'.i18n),
selected: c.cuurentExtensionType.value ==
ExtensionType.fikushon,
onSelected: (value) {
if (value) {
c.getRuntime(
type: ExtensionType.fikushon,
);
}
},
),
],
],
),
),
expandedHeight: 140,
collapsedHeight: 140,
),
floating: true,
snap: true,
)
];
},
Expand Down

0 comments on commit a7d6c13

Please sign in to comment.