Files
pilipala/lib/pages/search/widgets/search_text.dart
2024-10-03 14:44:27 +08:00

55 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
class SearchText extends StatelessWidget {
final String? searchText;
final Function? onSelect;
final int? searchTextIdx;
final Function? onLongSelect;
final bool isSelect;
const SearchText({
super.key,
this.searchText,
this.onSelect,
this.searchTextIdx,
this.onLongSelect,
this.isSelect = false,
});
@override
Widget build(BuildContext context) {
return Material(
color: isSelect
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context)
.colorScheme
.surfaceContainerHighest
.withOpacity(0.5),
borderRadius: BorderRadius.circular(6),
child: Padding(
padding: EdgeInsets.zero,
child: InkWell(
onTap: () {
onSelect!(searchText);
},
onLongPress: () {
onLongSelect!(searchText);
},
borderRadius: BorderRadius.circular(6),
child: Padding(
padding:
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
child: Text(
searchText!,
style: TextStyle(
color: isSelect
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
),
),
);
}
}