feat: add select/deselect icon on Patches Selector View

This commit is contained in:
Alberto Ponces
2022-08-21 02:03:36 +01:00
parent 2f83ea290b
commit b327926219
4 changed files with 50 additions and 18 deletions

View File

@ -3,17 +3,21 @@ import 'package:google_fonts/google_fonts.dart';
class SearchBar extends StatefulWidget {
final String? hintText;
final Color? backgroundColor;
final Color? fillColor;
final bool showSelectIcon;
final Function(bool)? onSelectAll;
final Color? backgroundColor;
final Color? hintTextColor;
const SearchBar({
Key? key,
required this.hintText,
required this.fillColor,
required this.onQueryChanged,
this.onSelectAll,
this.showSelectIcon = false,
this.backgroundColor = const Color(0xff1B222B),
this.hintTextColor = Colors.white,
required this.fillColor,
Key? key,
required this.onQueryChanged,
}) : super(key: key);
final Function(String) onQueryChanged;
@ -24,6 +28,8 @@ class SearchBar extends StatefulWidget {
class _SearchBarState extends State<SearchBar> {
final TextEditingController _textController = TextEditingController();
bool _toggleSelectAll = false;
@override
Widget build(BuildContext context) {
return Container(
@ -40,7 +46,7 @@ class _SearchBarState extends State<SearchBar> {
child: Row(
children: [
Expanded(
child: TextField(
child: TextFormField(
onChanged: widget.onQueryChanged,
controller: _textController,
decoration: InputDecoration(
@ -65,7 +71,22 @@ class _SearchBarState extends State<SearchBar> {
widget.onQueryChanged('');
},
)
: null,
: widget.showSelectIcon
? IconButton(
icon: _toggleSelectAll
? const Icon(Icons.deselect)
: const Icon(Icons.select_all),
iconSize: 24.0,
onPressed: widget.onSelectAll != null
? () {
setState(() {
_toggleSelectAll = !_toggleSelectAll;
});
widget.onSelectAll!(_toggleSelectAll);
}
: () => {},
)
: null,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none,