Files
PiliPlus/lib/pages/search/widgets/search_text.dart
bggRGjQaUbCoE ac60ac417b tweak
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
2025-05-21 16:55:44 +08:00

51 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
class SearchText extends StatelessWidget {
final String text;
final ValueChanged<String>? onTap;
final ValueChanged<String>? onLongPress;
final double? fontSize;
final Color? bgColor;
final Color? textColor;
final TextAlign? textAlign;
final EdgeInsetsGeometry? padding;
const SearchText({
super.key,
required this.text,
this.onTap,
this.onLongPress,
this.fontSize,
this.bgColor,
this.textColor,
this.textAlign,
this.padding,
});
@override
Widget build(BuildContext context) {
late final theme = Theme.of(context);
return Material(
color: bgColor ?? theme.colorScheme.onInverseSurface,
borderRadius: const BorderRadius.all(Radius.circular(6)),
child: InkWell(
onTap: () => onTap?.call(text),
onLongPress: onLongPress != null ? () => onLongPress!(text) : null,
borderRadius: const BorderRadius.all(Radius.circular(6)),
child: Padding(
padding: padding ??
const EdgeInsets.symmetric(horizontal: 11, vertical: 5),
child: Text(
text,
textAlign: textAlign,
style: TextStyle(
fontSize: fontSize,
color: textColor ?? theme.colorScheme.onSurfaceVariant,
),
),
),
),
);
}
}