search back button
This commit is contained in:
parent
db4b1f8e00
commit
8291857dac
|
|
@ -95,11 +95,18 @@ class LogoAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Consumer<HomeState>(
|
Consumer<HomeState>(
|
||||||
builder: (context, state, child) => SearchField(
|
builder: (context, state, child) => SearchField(
|
||||||
|
key: ValueKey(state.search),
|
||||||
title: state.currentPageIndex == 3 ? 'رصدهای من' : 'دیدوان',
|
title: state.currentPageIndex == 3 ? 'رصدهای من' : 'دیدوان',
|
||||||
onChanged: (value) => _onChanged(value, context),
|
onChanged: (value) => _onChanged(value, context),
|
||||||
focusNode: FocusNode(),
|
focusNode: FocusNode(),
|
||||||
onFilterButtonPressed: () => _showFilterBottomSheet(context),
|
onFilterButtonPressed: () => _showFilterBottomSheet(context),
|
||||||
isFiltered: state.filtering && state.search == '',
|
isFiltered: state.filtering && state.search == '',
|
||||||
|
onGoBack: state.filtering
|
||||||
|
? () {
|
||||||
|
state.resetFilters(false);
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class SearchField extends StatefulWidget {
|
||||||
final bool? isFiltered;
|
final bool? isFiltered;
|
||||||
final void Function(String value) onChanged;
|
final void Function(String value) onChanged;
|
||||||
final VoidCallback? onFilterButtonPressed;
|
final VoidCallback? onFilterButtonPressed;
|
||||||
|
final VoidCallback? onGoBack;
|
||||||
|
|
||||||
const SearchField({
|
const SearchField({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
|
@ -17,6 +18,7 @@ class SearchField extends StatefulWidget {
|
||||||
required this.focusNode,
|
required this.focusNode,
|
||||||
this.onFilterButtonPressed,
|
this.onFilterButtonPressed,
|
||||||
this.isFiltered,
|
this.isFiltered,
|
||||||
|
this.onGoBack,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -107,10 +109,20 @@ class _SearchFieldState extends State<SearchField> {
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
prefixIcon: Icon(
|
prefix: widget.onGoBack != null
|
||||||
DidvanIcons.search_regular,
|
? DidvanIconButton(
|
||||||
color: Theme.of(context).colorScheme.text,
|
gestureSize: 32,
|
||||||
),
|
icon: DidvanIcons.back_light,
|
||||||
|
color: Theme.of(context).colorScheme.text,
|
||||||
|
onPressed: widget.onGoBack!,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
prefixIcon: widget.onGoBack == null
|
||||||
|
? Icon(
|
||||||
|
DidvanIcons.search_regular,
|
||||||
|
color: Theme.of(context).colorScheme.text,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
prefixIconColor: Theme.of(context).colorScheme.inputText,
|
prefixIconColor: Theme.of(context).colorScheme.inputText,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderRadius: const BorderRadius.all(
|
borderRadius: const BorderRadius.all(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue