fix: overlay not working
This commit is contained in:
parent
6a25c8289c
commit
96135f0bf5
1 changed files with 28 additions and 19 deletions
|
@ -48,6 +48,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
var _filter = ""; // search filter
|
||||
final searchFocus = FocusNode();
|
||||
var sort = SortType.newest;
|
||||
OverlayEntry? overlayEntry;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
|
@ -85,6 +86,7 @@ class _HomeViewState extends State<HomeView> {
|
|||
if (b) return;
|
||||
_searchActive = false;
|
||||
_filter = "";
|
||||
overlayEntry?.remove();
|
||||
setState(() {});
|
||||
},
|
||||
child: Scaffold(
|
||||
|
@ -253,6 +255,32 @@ class _HomeViewState extends State<HomeView> {
|
|||
_searchActive = !_searchActive;
|
||||
if (!_searchActive) {
|
||||
_filter = "";
|
||||
} else {
|
||||
overlayEntry = OverlayEntry(
|
||||
builder: (context) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height:
|
||||
MediaQuery.of(context).size.height - 100,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (!searchFocus.hasFocus) {
|
||||
_searchActive = false;
|
||||
_filter = "";
|
||||
overlayEntry?.remove();
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
searchFocus.unfocus();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
Overlay.of(context).insert(
|
||||
overlayEntry!,
|
||||
);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
@ -574,25 +602,6 @@ class _HomeViewState extends State<HomeView> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (_searchActive)
|
||||
OverlayEntry(
|
||||
builder: (context) => SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (!_searchActive) return;
|
||||
if (!searchFocus.hasFocus) {
|
||||
_searchActive = false;
|
||||
_filter = "";
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
searchFocus.unfocus();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue