Add app search o home screen
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:google_nav_bar/google_nav_bar.dart';
|
import 'package:google_nav_bar/google_nav_bar.dart';
|
||||||
import 'package:patient_manager/components/homeTile.dart';
|
import 'package:patient_manager/components/homeTile.dart';
|
||||||
|
import 'package:patient_manager/components/inputsAndButtons/mihSearchInput.dart';
|
||||||
import 'package:patient_manager/components/mihAppBar.dart';
|
import 'package:patient_manager/components/mihAppBar.dart';
|
||||||
import 'package:patient_manager/components/mihAppDrawer.dart';
|
import 'package:patient_manager/components/mihAppDrawer.dart';
|
||||||
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
|
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
|
||||||
@@ -31,11 +33,14 @@ class HomeTileGrid extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomeTileGridState extends State<HomeTileGrid> {
|
class _HomeTileGridState extends State<HomeTileGrid> {
|
||||||
|
final TextEditingController searchController = TextEditingController();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
late List<HomeTile> persHTList = [];
|
late List<HomeTile> persHTList = [];
|
||||||
late List<HomeTile> busHTList = [];
|
late List<HomeTile> busHTList = [];
|
||||||
late List<List<HomeTile>> pbswitch;
|
late List<List<HomeTile>> pbswitch;
|
||||||
late bool businessUserSwitch;
|
late bool businessUserSwitch;
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
String appSearch = "";
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
final baseAPI = AppEnviroment.baseApiUrl;
|
||||||
|
|
||||||
void setAppsNewPersonal(List<HomeTile> tileList) {
|
void setAppsNewPersonal(List<HomeTile> tileList) {
|
||||||
@@ -302,6 +307,20 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<HomeTile> searchApp(List<HomeTile> appList, String searchString) {
|
||||||
|
if (searchString == "") {
|
||||||
|
return appList;
|
||||||
|
} else {
|
||||||
|
List<HomeTile> temp = [];
|
||||||
|
for (var item in appList) {
|
||||||
|
if (item.tileName.toLowerCase().contains(appSearch.toLowerCase())) {
|
||||||
|
temp.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<List<HomeTile>> setApps(
|
List<List<HomeTile>> setApps(
|
||||||
List<HomeTile> personalTileList, List<HomeTile> businessTileList) {
|
List<HomeTile> personalTileList, List<HomeTile> businessTileList) {
|
||||||
if (widget.signedInUser.fname == "") {
|
if (widget.signedInUser.fname == "") {
|
||||||
@@ -348,7 +367,8 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
searchController.dispose();
|
||||||
|
_focusNode.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,70 +392,75 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
drawer: MIHAppDrawer(
|
drawer: MIHAppDrawer(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.signedInUser,
|
||||||
),
|
),
|
||||||
body:
|
body: Column(
|
||||||
// Column(
|
children: [
|
||||||
// children: [
|
const SizedBox(height: 10),
|
||||||
// Padding(
|
Padding(
|
||||||
// padding: const EdgeInsets.only(top: 10.0, right: 15.0),
|
padding: EdgeInsets.symmetric(horizontal: width / 10),
|
||||||
// child: Row(
|
child: Row(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisSize: MainAxisSize.min,
|
||||||
// children: [
|
children: [
|
||||||
// IconButton(
|
IconButton(
|
||||||
// onPressed: () {
|
onPressed: () {
|
||||||
// if (!businessUserSwitch) {
|
setState(() {
|
||||||
// setState(() {
|
appSearch = "";
|
||||||
// businessUserSwitch = true;
|
searchController.clear();
|
||||||
// _selectedIndex = 1;
|
});
|
||||||
// });
|
},
|
||||||
// } else {
|
icon: const Icon(
|
||||||
// setState(() {
|
Icons.apps,
|
||||||
// businessUserSwitch = false;
|
size: 50,
|
||||||
// _selectedIndex = 0;
|
),
|
||||||
// });
|
),
|
||||||
// }
|
KeyboardListener(
|
||||||
// },
|
focusNode: _focusNode,
|
||||||
// icon: const Icon(
|
autofocus: true,
|
||||||
// Icons.swap_horizontal_circle_outlined,
|
onKeyEvent: (event) async {
|
||||||
// size: 35,
|
if (event is KeyDownEvent &&
|
||||||
// ),
|
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
// ),
|
setState(() {
|
||||||
// ],
|
appSearch = searchController.text;
|
||||||
// ),
|
});
|
||||||
// ),
|
}
|
||||||
// const SizedBox(
|
},
|
||||||
// height: 20,
|
child: SizedBox(
|
||||||
// ),
|
width: width - ((width / 10) * 2) - 70,
|
||||||
// Text(
|
child: MIHSearchField(
|
||||||
// getHeading(_selectedIndex),
|
controller: searchController,
|
||||||
// textAlign: TextAlign.center,
|
hintText: "Search Apps",
|
||||||
// style: TextStyle(
|
required: false,
|
||||||
// fontWeight: FontWeight.bold,
|
editable: true,
|
||||||
// fontSize: 35.0,
|
onTap: () {
|
||||||
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
setState(() {
|
||||||
// ),
|
appSearch = searchController.text;
|
||||||
// ),
|
});
|
||||||
// const SizedBox(
|
},
|
||||||
// height: 20,
|
),
|
||||||
// ),
|
),
|
||||||
//Expanded(
|
),
|
||||||
//child:
|
],
|
||||||
|
),
|
||||||
GridView.builder(
|
),
|
||||||
padding: EdgeInsets.only(
|
Expanded(
|
||||||
left: width / 7,
|
child: GridView.builder(
|
||||||
right: width / 7,
|
padding: EdgeInsets.only(
|
||||||
//bottom: height / 5,
|
left: width / 10,
|
||||||
top: 20,
|
right: width / 10,
|
||||||
),
|
//bottom: height / 5,
|
||||||
// physics: ,
|
top: 20,
|
||||||
// shrinkWrap: true,
|
),
|
||||||
itemCount: pbswitch[_selectedIndex].length,
|
// physics: ,
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
// shrinkWrap: true,
|
||||||
maxCrossAxisExtent: 200),
|
itemCount: searchApp(pbswitch[_selectedIndex], appSearch).length,
|
||||||
itemBuilder: (context, index) {
|
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
return pbswitch[_selectedIndex][index];
|
maxCrossAxisExtent: 200),
|
||||||
},
|
itemBuilder: (context, index) {
|
||||||
|
return searchApp(pbswitch[_selectedIndex], appSearch)[index];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
//),
|
//),
|
||||||
|
|||||||
Reference in New Issue
Block a user