diff --git a/Musgravite.xcodeproj/project.pbxproj b/Musgravite.xcodeproj/project.pbxproj index 88ca262..243a146 100644 --- a/Musgravite.xcodeproj/project.pbxproj +++ b/Musgravite.xcodeproj/project.pbxproj @@ -947,7 +947,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = Musgravite/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -968,7 +968,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = Musgravite/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1029,7 +1029,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = MusgraviteUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1049,7 +1049,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = MusgraviteUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1070,7 +1070,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; IBSC_MODULE = WMusgravite_Extension; INFOPLIST_FILE = WMusgravite/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = com.aabotech.Musgravite.watchkitapp; @@ -1089,7 +1089,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; IBSC_MODULE = WMusgravite_Extension; INFOPLIST_FILE = WMusgravite/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = com.aabotech.Musgravite.watchkitapp; @@ -1108,7 +1108,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_ENTITLEMENTS = "WMusgravite Extension/WMusgravite Extension.entitlements"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = "WMusgravite Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1131,7 +1131,7 @@ ASSETCATALOG_COMPILER_COMPLICATION_NAME = Complication; CODE_SIGN_ENTITLEMENTS = "WMusgravite Extension/WMusgravite Extension.entitlements"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = R3KUK9JKD6; + DEVELOPMENT_TEAM = R935X42Z66; INFOPLIST_FILE = "WMusgravite Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate index 8431648..456eb34 100644 Binary files a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate and b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Musgravite/Controller/LaboratorySearchViewController.swift b/Musgravite/Controller/LaboratorySearchViewController.swift index 5e777a9..0b4ba25 100644 --- a/Musgravite/Controller/LaboratorySearchViewController.swift +++ b/Musgravite/Controller/LaboratorySearchViewController.swift @@ -66,33 +66,32 @@ extension UITableView { }) }) - self.backgroundView = emptyView self.separatorStyle = .none } - func restore() { - self.backgroundView = nil self.separatorStyle = .singleLine - } - } -class LaboratorySearchViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDataSource, UITableViewDelegate { + +class LaboratorySearchViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate { /* Elements on the interface */ @IBOutlet weak var bigImageOutlet: UIImageView! @IBOutlet weak var bigTitleOutlet: UILabel! @IBOutlet weak var descriptionOutlet: UITextView! @IBOutlet weak var floorsCollectionView: UICollectionView! @IBOutlet weak var labsTableView: UITableView! + @IBOutlet weak var searchBar: UISearchBar! /* Information for the interface */ var floorData:JSON? var labByFloorData:[JSON]? var labData:JSON? var superFiltered:[JSON]? + var searchFiltered:[JSON]? + var isSearching = false /* Selected floor variable - To show information in the table view */ var selectedFloor = -1 @@ -103,6 +102,8 @@ class LaboratorySearchViewController: UIViewController, UICollectionViewDelegate override func viewDidLoad() { super.viewDidLoad() + searchBar.delegate = self + searchBar.returnKeyType = UIReturnKeyType.done retrieveData() } @@ -113,6 +114,11 @@ class LaboratorySearchViewController: UIViewController, UICollectionViewDelegate labByFloorData = filterLabArray() } + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + view.endEditing(true) + super.touchesBegan(touches, with: event) + } + /* Dont allow the ViewController to appear */ override func viewWillDisappear(_ animated: Bool) { if isMovingFromParent { @@ -150,25 +156,61 @@ class LaboratorySearchViewController: UIViewController, UICollectionViewDelegate } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if (labByFloorData?.count)! == 0 { - tableView.setEmptyView(title: "Sin laboratorios", message: "Aún no has seleccionado un piso", messageImage: UIImage(named: "Nautilus")!) - }else{ - tableView.restore() + + if isSearching { + if (searchFiltered?.count)! == 0 { + tableView.setEmptyView(title: "Sin laboratorios", message: "No hay laboratorios con ese nombre", messageImage: UIImage(named: "Nautilus")!) + }else{ + tableView.restore() + } + return (searchFiltered?.count)! + } else { + if (labByFloorData?.count)! == 0 { + tableView.setEmptyView(title: "Sin laboratorios", message: "Aún no has seleccionado un piso", messageImage: UIImage(named: "Nautilus")!) + }else{ + tableView.restore() + } + return (labByFloorData?.count)! } - return (labByFloorData?.count)! } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "labCells", for: indexPath) as! LabTableViewCell - cell.title.text = labByFloorData![indexPath.item]["nombre"].stringValue - cell.location.text = labByFloorData![indexPath.item]["ubicacion"].stringValue - return cell + if isSearching { + let cell = tableView.dequeueReusableCell(withIdentifier: "labCells", for: indexPath) as! LabTableViewCell + cell.title.text = searchFiltered![indexPath.item]["nombre"].stringValue + cell.location.text = searchFiltered![indexPath.item]["ubicacion"].stringValue + + return cell + } else { + let cell = tableView.dequeueReusableCell(withIdentifier: "labCells", for: indexPath) as! LabTableViewCell + cell.title.text = labByFloorData![indexPath.item]["nombre"].stringValue + cell.location.text = labByFloorData![indexPath.item]["ubicacion"].stringValue + + return cell + } + } + + func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { + if searchBar.text == nil || searchBar.text == "" { + isSearching = false + view.endEditing(true) + labsTableView.reloadData() + } else { + isSearching = true + searchFiltered = labData?.arrayValue.filter({$0["nombre"].stringValue.contains(searchText)}) + labsTableView.reloadData() + } } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let vc = segue.destination as! DetailViewController - let selectedLab = labByFloorData![(labsTableView.indexPathForSelectedRow?.row)!] + var selectedLab:JSON? + if isSearching { + selectedLab = searchFiltered![(labsTableView.indexPathForSelectedRow?.row)!] + } else { + selectedLab = labByFloorData![(labsTableView.indexPathForSelectedRow?.row)!] + } vc.labInformation = selectedLab } } diff --git a/Musgravite/View/Base.lproj/Main.storyboard b/Musgravite/View/Base.lproj/Main.storyboard index 79450dd..c5fb401 100644 --- a/Musgravite/View/Base.lproj/Main.storyboard +++ b/Musgravite/View/Base.lproj/Main.storyboard @@ -422,7 +422,7 @@ - + @@ -469,6 +469,10 @@ + + + + @@ -478,7 +482,9 @@ + + @@ -498,7 +504,8 @@ - + + @@ -514,11 +521,12 @@ + - + @@ -1118,7 +1126,7 @@ - + @@ -1165,7 +1173,7 @@ - +