forked from yaso_meth/mih-project
Unfocus search on tap away
This commit is contained in:
@@ -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],
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// )),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -50,6 +50,7 @@ class _AboutMihState extends State<AboutMih> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class _MihAccessState extends State<MihAccess> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class _MIHCalculatorState extends State<MIHCalculator> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ class _MzansiAiState extends State<MzansiAi> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class _MzansiBusinessProfileState extends State<MzansiBusinessProfile> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class _MzansiProfileState extends State<MzansiProfile> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ class _MihWalletState extends State<MihWallet> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class _PatManagerState extends State<PatManager> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class _PatientProfileState extends State<PatientProfile> {
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user