Skip to content

Commit

Permalink
Allow custom hint text at DefaultSearchView (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
akvus authored Feb 28, 2024
1 parent 06535dc commit e7e971a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions example/lib/main_whatsapp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ class WhatsAppSearchViewState extends SearchViewState {
child: TextField(
onChanged: onTextInputChanged,
focusNode: focusNode,
decoration: const InputDecoration(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Search',
hintStyle: TextStyle(
hintText: widget.config.searchViewConfig.hintText,
hintStyle: const TextStyle(
color: secondaryColor,
fontWeight: FontWeight.normal,
),
Expand Down
7 changes: 4 additions & 3 deletions lib/src/search_view/default_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ class DefaultSearchViewState extends SearchViewState {
child: TextField(
onChanged: onTextInputChanged,
focusNode: focusNode,
decoration: const InputDecoration(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Search',
contentPadding: EdgeInsets.symmetric(horizontal: 16),
hintText: widget.config.searchViewConfig.hintText,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16),
),
),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/src/search_view/search_view_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SearchViewConfig {
this.backgroundColor = const Color(0xFFEBEFF2),
this.buttonColor = Colors.transparent,
this.buttonIconColor = Colors.black26,
this.hintText = 'Search',
this.customSearchView,
});

Expand All @@ -31,17 +32,22 @@ class SearchViewConfig {
/// Hot reload is not supported
final SearchViewBuilder? customSearchView;

/// Custom hint text
final String? hintText;

@override
bool operator ==(other) {
return (other is SearchViewConfig) &&
other.backgroundColor == backgroundColor &&
other.buttonColor == buttonColor &&
other.buttonIconColor == buttonIconColor;
other.buttonIconColor == buttonIconColor &&
other.hintText == hintText;
}

@override
int get hashCode =>
backgroundColor.hashCode ^
buttonColor.hashCode ^
buttonIconColor.hashCode;
buttonIconColor.hashCode ^
hintText.hashCode;
}

0 comments on commit e7e971a

Please sign in to comment.