Skip to content

Commit

Permalink
Custom SearchDelegate AppBar.
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed Jul 11, 2021
1 parent 145dbb5 commit aba4a47
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.12+56"
version: "0.2.16+61"
font_awesome_flutter:
dependency: transitive
description:
Expand Down
53 changes: 51 additions & 2 deletions lib/crud/abstract_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ abstract class AbstractList<
)? onLongPress;
final Map<AbstractRoute,
Future<bool> Function(BuildContext context, T model)>? actionFunctions;
final String? searchFieldLabel;
final TextStyle? searchFieldStyle;
final InputDecorationTheme? searchFieldDecorationTheme;
final TextInputType? searchKeyboardType;
final TextInputAction searchTextInputAction;

///
///
Expand Down Expand Up @@ -79,7 +84,13 @@ abstract class AbstractList<
this.actionRoutes = const <AbstractRoute>[],
this.onLongPress,
this.actionFunctions,
}) : super(key: key);
this.searchFieldLabel,
this.searchFieldStyle,
this.searchFieldDecorationTheme,
this.searchKeyboardType,
this.searchTextInputAction = TextInputAction.search,
}) : assert(searchFieldStyle == null || searchFieldDecorationTheme == null),
super(key: key);

///
///
Expand Down Expand Up @@ -327,6 +338,12 @@ class _AbstractListState<
itemsPerPage: widget.itemsPerPage,
uiBuilder: widget.uiBuilder,
consumer: widget.consumer,
searchFieldLabel: widget.searchFieldLabel,
searchFieldStyle: widget.searchFieldStyle,
searchFieldDecorationTheme:
widget.searchFieldDecorationTheme,
keyboardType: widget.searchKeyboardType,
textInputAction: widget.searchTextInputAction,
),
).then((T? entity) {
if (entity != null) {
Expand Down Expand Up @@ -743,7 +760,39 @@ class InternalSearch<
required this.qsParam,
required this.forceOffline,
required this.itemsPerPage,
});
required String? searchFieldLabel,
required TextStyle? searchFieldStyle,
required InputDecorationTheme? searchFieldDecorationTheme,
required TextInputType? keyboardType,
required TextInputAction textInputAction,
}) : super(
searchFieldLabel: searchFieldLabel,
searchFieldStyle: searchFieldStyle,
searchFieldDecorationTheme: searchFieldDecorationTheme,
keyboardType: keyboardType,
textInputAction: textInputAction,
);

///
///
///
@override
ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context);
return theme.copyWith(
appBarTheme: AppBarTheme(
brightness: theme.colorScheme.brightness,
backgroundColor: theme.colorScheme.surface,
iconTheme: theme.primaryIconTheme.copyWith(color: Colors.grey),
textTheme: theme.textTheme,
),
inputDecorationTheme: searchFieldDecorationTheme ??
InputDecorationTheme(
hintStyle: searchFieldStyle ?? theme.inputDecorationTheme.hintStyle,
border: InputBorder.none,
),
);
}

///
///
Expand Down

0 comments on commit aba4a47

Please sign in to comment.