opt: search page
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
// ignore: file_names
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HotKeyword extends StatelessWidget {
|
||||
final double? width;
|
||||
final List? hotSearchList;
|
||||
final Function? onClick;
|
||||
final double width;
|
||||
final List hotSearchList;
|
||||
final Function onClick;
|
||||
|
||||
const HotKeyword({
|
||||
this.width,
|
||||
this.hotSearchList,
|
||||
this.onClick,
|
||||
required this.width,
|
||||
required this.hotSearchList,
|
||||
required this.onClick,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@ -18,45 +18,67 @@ class HotKeyword extends StatelessWidget {
|
||||
return Wrap(
|
||||
runSpacing: 0.4,
|
||||
spacing: 5.0,
|
||||
children: [
|
||||
for (var i in hotSearchList!)
|
||||
SizedBox(
|
||||
width: width! / 2 - 4,
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => onClick!(i.keyword),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 2,
|
||||
right: hotSearchList!.indexOf(i) % 2 == 1 ? 10 : 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 5, 4, 5),
|
||||
child: Text(
|
||||
i.keyword!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (i.icon != null && i.icon != '')
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: i.icon!, height: 15.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
children: hotSearchList.map((item) {
|
||||
return HotKeywordItem(
|
||||
width: width,
|
||||
item: item,
|
||||
onClick: onClick,
|
||||
isRightPadding: hotSearchList.indexOf(item) % 2 == 1,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HotKeywordItem extends StatelessWidget {
|
||||
final double width;
|
||||
final dynamic item;
|
||||
final Function onClick;
|
||||
final bool isRightPadding;
|
||||
|
||||
const HotKeywordItem({
|
||||
required this.width,
|
||||
required this.item,
|
||||
required this.onClick,
|
||||
required this.isRightPadding,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width / 2 - 4,
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
onTap: () => onClick.call(item.keyword),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 2, right: isRightPadding ? 10 : 0),
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(6, 5, 4, 5),
|
||||
child: Text(
|
||||
item.keyword,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (item.icon != null && item.icon != '')
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child:
|
||||
CachedNetworkImage(imageUrl: item.icon!, height: 15.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/utils/feed_back.dart';
|
||||
|
||||
class SearchText extends StatelessWidget {
|
||||
final String? searchText;
|
||||
@ -17,30 +18,31 @@ class SearchText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
return Material(
|
||||
color: isSelect
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
||||
? colorScheme.primaryContainer
|
||||
: colorScheme.surfaceVariant.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.zero,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
onSelect!(searchText);
|
||||
onSelect?.call(searchText);
|
||||
},
|
||||
onLongPress: () {
|
||||
onLongSelect!(searchText);
|
||||
feedBack();
|
||||
onLongSelect?.call(searchText);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 11),
|
||||
child: Text(
|
||||
searchText!,
|
||||
style: TextStyle(
|
||||
color: isSelect
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
? colorScheme.primary
|
||||
: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user