Files
game-tracker/lib/presentation/widgets/custom_search_bar.dart
mathiskirchner d16beed490
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m3s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
felix mach jetzt
2025-11-20 21:54:43 +01:00

58 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:game_tracker/core/custom_theme.dart';
class CustomSearchBar extends StatelessWidget {
final TextEditingController controller;
final String hintText;
final ValueChanged<String>? onChanged;
final BoxConstraints? constraints;
final bool trailingButtonEnabled;
final bool trailingButtonShown;
final VoidCallback? onTrailingButtonPressed;
const CustomSearchBar({
super.key,
required this.controller,
required this.hintText,
this.trailingButtonShown = false,
this.trailingButtonEnabled = true,
this.onTrailingButtonPressed,
this.onChanged,
this.constraints,
});
@override
Widget build(BuildContext context) {
return SearchBar(
controller: controller,
constraints:
constraints ?? const BoxConstraints(maxHeight: 45, minHeight: 45),
hintText: hintText,
onChanged: trailingButtonEnabled ? onChanged : null,
hintStyle: WidgetStateProperty.all(const TextStyle(fontSize: 16)),
leading: const Icon(Icons.search),
trailing: [
Visibility(
visible: trailingButtonShown,
child: GestureDetector(
onTap: onTrailingButtonPressed,
child: Icon(
Icons.add_circle,
color: trailingButtonEnabled
? null
: Colors.grey.withValues(alpha: 0.2),
),
),
),
const SizedBox(width: 5),
],
backgroundColor: WidgetStateProperty.all(CustomTheme.boxColor),
side: WidgetStateProperty.all(BorderSide(color: CustomTheme.boxBorder)),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
elevation: WidgetStateProperty.all(0),
);
}
}