Unfocus search on tap away

This commit is contained in:
2025-04-09 09:01:40 +02:00
parent f841562fa4
commit e32f61a67e
12 changed files with 79 additions and 72 deletions

View File

@@ -28,6 +28,10 @@ class MihApp extends StatefulWidget {
class _MihAppState extends State<MihApp> {
late PageController _pageController;
void unfocusAll() {
FocusScope.of(context).unfocus();
}
@override
void dispose() {
super.dispose();
@@ -55,69 +59,72 @@ class _MihAppState extends State<MihApp> {
@override
Widget build(BuildContext context) {
Size screenSize = MediaQuery.of(context).size;
return Scaffold(
drawer: widget.actionDrawer,
body: SafeArea(
child: Container(
width: screenSize.width,
height: screenSize.height,
//color: Colors.black,
padding: const EdgeInsets.only(top: 5),
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.appActionButton,
Flexible(child: widget.appTools),
],
),
Expanded(
child: PageView.builder(
controller: _pageController,
itemCount: widget.appBody.length,
itemBuilder: (context, index) {
return widget.appBody[index];
},
onPageChanged: (index) {
setState(() {
widget.selectedbodyIndex = index;
widget.onIndexChange(widget.selectedbodyIndex);
});
},
return GestureDetector(
onTap: unfocusAll,
child: Scaffold(
drawer: widget.actionDrawer,
body: SafeArea(
child: Container(
width: screenSize.width,
height: screenSize.height,
//color: Colors.black,
padding: const EdgeInsets.only(top: 5),
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.appActionButton,
Flexible(child: widget.appTools),
],
),
),
// Expanded(
// child: SwipeDetector(
// onSwipeLeft: (offset) {
// if (widget.selectedbodyIndex <
// widget.appTools.tools.length - 1) {
// setState(() {
// widget.selectedbodyIndex += 1;
// widget.onIndexChange(widget.selectedbodyIndex);
// });
// }
// // print("swipe left");
// },
// onSwipeRight: (offset) {
// if (widget.selectedbodyIndex > 0) {
// setState(() {
// widget.selectedbodyIndex -= 1;
// widget.onIndexChange(widget.selectedbodyIndex);
// });
// }
// // print("swipe right");
// },
// child: Row(
// children: [
// Expanded(
// child: widget.appBody[widget.selectedbodyIndex],
// )
// ],
// ),
// )),
],
Expanded(
child: PageView.builder(
controller: _pageController,
itemCount: widget.appBody.length,
itemBuilder: (context, index) {
return widget.appBody[index];
},
onPageChanged: (index) {
setState(() {
widget.selectedbodyIndex = index;
widget.onIndexChange(widget.selectedbodyIndex);
});
},
),
),
// Expanded(
// child: SwipeDetector(
// onSwipeLeft: (offset) {
// if (widget.selectedbodyIndex <
// widget.appTools.tools.length - 1) {
// setState(() {
// widget.selectedbodyIndex += 1;
// widget.onIndexChange(widget.selectedbodyIndex);
// });
// }
// // print("swipe left");
// },
// onSwipeRight: (offset) {
// if (widget.selectedbodyIndex > 0) {
// setState(() {
// widget.selectedbodyIndex -= 1;
// widget.onIndexChange(widget.selectedbodyIndex);
// });
// }
// // print("swipe right");
// },
// child: Row(
// children: [
// Expanded(
// child: widget.appBody[widget.selectedbodyIndex],
// )
// ],
// ),
// )),
],
),
),
),
),

View File

@@ -50,6 +50,7 @@ class _AboutMihState extends State<AboutMih> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -40,6 +40,7 @@ class _MihAccessState extends State<MihAccess> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -41,6 +41,7 @@ class _MIHCalculatorState extends State<MIHCalculator> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -41,6 +41,7 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -25,6 +25,7 @@ class _MzansiAiState extends State<MzansiAi> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -41,6 +41,7 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -41,6 +41,7 @@ class _MzansiProfileState extends State<MzansiProfile> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -49,6 +49,7 @@ class _MihWalletState extends State<MihWallet> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -48,6 +48,7 @@ class _PatManagerState extends State<PatManager> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}

View File

@@ -42,6 +42,7 @@ class _PatientProfileState extends State<PatientProfile> {
iconSize: 35,
onTap: () {
Navigator.of(context).pop();
FocusScope.of(context).unfocus();
},
);
}