From c92d44d62b9b4d0cd94715b919450082c9f349e5 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 29 Jun 2016 13:53:08 -0400 Subject: [PATCH 1/3] Storyboard: Separate Search from Main --- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOS/Storyboard/Main.storyboard | 888 ------------------------ Kiwix-iOS/Storyboard/Search.storyboard | 901 +++++++++++++++++++++++++ Kiwix-iOS/iOSExtensions.swift | 9 +- Kiwix.xcodeproj/project.pbxproj | 6 +- 5 files changed, 915 insertions(+), 891 deletions(-) create mode 100644 Kiwix-iOS/Storyboard/Search.storyboard diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index c889d127..b2144794 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -36,7 +36,7 @@ CFBundleSignature ???? CFBundleVersion - 800 + 806 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/Storyboard/Main.storyboard b/Kiwix-iOS/Storyboard/Main.storyboard index ce87e6eb..505f605a 100644 --- a/Kiwix-iOS/Storyboard/Main.storyboard +++ b/Kiwix-iOS/Storyboard/Main.storyboard @@ -93,513 +93,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -866,188 +359,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1066,208 +377,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Kiwix-iOS/Storyboard/Search.storyboard b/Kiwix-iOS/Storyboard/Search.storyboard new file mode 100644 index 00000000..b04f6a56 --- /dev/null +++ b/Kiwix-iOS/Storyboard/Search.storyboard @@ -0,0 +1,901 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiwix-iOS/iOSExtensions.swift b/Kiwix-iOS/iOSExtensions.swift index bc5b051b..2ff76bba 100644 --- a/Kiwix-iOS/iOSExtensions.swift +++ b/Kiwix-iOS/iOSExtensions.swift @@ -36,11 +36,13 @@ extension NSManagedObjectContext { // MARK: - UI extension UIStoryboard { - class var main: UIStoryboard {get {return UIStoryboard(name: "Main", bundle: nil)}} class var library: UIStoryboard {get {return UIStoryboard(name: "Library", bundle: nil)}} + class var main: UIStoryboard {get {return UIStoryboard(name: "Main", bundle: nil)}} + class var search: UIStoryboard {get {return UIStoryboard(name: "Search", bundle: nil)}} class var setting: UIStoryboard {get {return UIStoryboard(name: "Setting", bundle: nil)}} class var help: UIStoryboard {get {return UIStoryboard(name: "Help", bundle: nil)}} + // @available(*, deprecated=1.7, obsoleted=2.0, message="Use newer API") func initViewController(type: T.Type) -> T? { guard let className = NSStringFromClass(T).componentsSeparatedByString(".").last else { print("NSManagedObjectExtension: Unable to get class name") @@ -52,6 +54,11 @@ extension UIStoryboard { func initViewController(identifier: String, type: T.Type) -> T? { return instantiateViewControllerWithIdentifier(identifier) as? T } + + func controller(type: T.Type) -> T? { + return instantiateViewControllerWithIdentifier(String(T)) as? T + } + } extension UIColor { diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj index e4b93ba8..b7962751 100644 --- a/Kiwix.xcodeproj/project.pbxproj +++ b/Kiwix.xcodeproj/project.pbxproj @@ -267,6 +267,7 @@ 97E60A021D10423A00EBCB9D /* ShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A011D10423A00EBCB9D /* ShadowView.swift */; }; 97E60A061D10504000EBCB9D /* LibraryBackupTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */; }; 97E891691CA976E90001CA32 /* FileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E891681CA976E90001CA32 /* FileManager.swift */; }; + 97F03CE21D2440470040D26E /* Search.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97F03CE11D2440470040D26E /* Search.storyboard */; }; AEFF409D8D5B53BC90700424 /* Pods_Kiwix_OSX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DBAF14EE0505901A1570F23F /* Pods_Kiwix_OSX.framework */; }; BECDBCEF4720E3E86FE63989 /* Pods_Kiwix_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CEA715EBFC96C75E73447A7 /* Pods_Kiwix_iOS.framework */; }; /* End PBXBuildFile section */ @@ -547,6 +548,7 @@ 97E60A011D10423A00EBCB9D /* ShadowView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShadowView.swift; sourceTree = ""; }; 97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibraryBackupTBVC.swift; path = "Kiwix-iOS/Controller/LibraryBackupTBVC.swift"; sourceTree = SOURCE_ROOT; }; 97E891681CA976E90001CA32 /* FileManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FileManager.swift; path = Kiwix/FileManager.swift; sourceTree = ""; }; + 97F03CE11D2440470040D26E /* Search.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Search.storyboard; path = "Kiwix-iOS/Storyboard/Search.storyboard"; sourceTree = SOURCE_ROOT; }; B14E5F8A97964014F99EAD4E /* Pods-Kiwix-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kiwix-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Kiwix-iOS/Pods-Kiwix-iOS.debug.xcconfig"; sourceTree = ""; }; B3B41D59F4B010C559B18D3D /* Pods-Kiwix-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kiwix-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Kiwix-iOS/Pods-Kiwix-iOS.release.xcconfig"; sourceTree = ""; }; DBAF14EE0505901A1570F23F /* Pods_Kiwix_OSX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Kiwix_OSX.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -853,6 +855,7 @@ isa = PBXGroup; children = ( 971A10511D022D9D007FC62C /* AppDelegate.swift */, + 975B90FD1CEB909100D13906 /* iOSExtensions.swift */, 978C587A1C1CCC9C0077AE47 /* Storyboards */, 978C58821C1CCDAF0077AE47 /* Controllers */, 971A10221D022AD5007FC62C /* View */, @@ -1012,6 +1015,7 @@ children = ( 975227C91D0227E8001D1DDE /* Library.storyboard */, 975227CA1D0227E8001D1DDE /* Main.storyboard */, + 97F03CE11D2440470040D26E /* Search.storyboard */, 975227CB1D0227E8001D1DDE /* Setting.storyboard */, ); name = Storyboards; @@ -1036,7 +1040,6 @@ 978C588B1C1CD1E30077AE47 /* Model */ = { isa = PBXGroup; children = ( - 975B90FD1CEB909100D13906 /* iOSExtensions.swift */, 971904A41CA3204B002E9CFF /* Network */, 971A106B1D022E50007FC62C /* Utilities.swift */, ); @@ -1525,6 +1528,7 @@ 971A10811D022F74007FC62C /* Pic_P.png in Resources */, 971A101D1D0228E8007FC62C /* adjustlayoutiPad.js in Resources */, 975227D01D022814001D1DDE /* LaunchScreen.storyboard in Resources */, + 97F03CE21D2440470040D26E /* Search.storyboard in Resources */, 971A10181D0228E0007FC62C /* about.html in Resources */, 971A10161D022872007FC62C /* Assets.xcassets in Resources */, 971A10771D022F05007FC62C /* Localizable.stringsdict in Resources */, From b8b8270e53b33e02f0e462b2e39222a4299ab76a Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 29 Jun 2016 15:38:29 -0400 Subject: [PATCH 2/3] Finished Storyboard, rounded rect view with shadow --- Kiwix-iOS/Controller/MainVC.swift | 34 +-- Kiwix-iOS/Controller/MainVCDelegates.swift | 4 +- .../Controller/Search/RecentSearchCVC.swift | 4 +- ...{SearchVC.swift => SearchController.swift} | 6 +- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOS/Storyboard/Search.storyboard | 221 +++++++++++++----- Kiwix-iOS/View/ShadowView.swift | 22 +- Kiwix-iOS/iOSExtensions.swift | 2 - Kiwix.xcodeproj/project.pbxproj | 10 +- 9 files changed, 211 insertions(+), 94 deletions(-) rename Kiwix-iOS/Controller/{SearchVC.swift => SearchController.swift} (93%) diff --git a/Kiwix-iOS/Controller/MainVC.swift b/Kiwix-iOS/Controller/MainVC.swift index 38451610..251497a1 100644 --- a/Kiwix-iOS/Controller/MainVC.swift +++ b/Kiwix-iOS/Controller/MainVC.swift @@ -15,7 +15,7 @@ class MainVC: UIViewController { var bookmarkController: UIViewController? var libraryController: UIViewController? var settingController: UIViewController? - var searchVC: SearchVC? + var searchController: SearchController? let searchBar = SearchBar() var context: UnsafeMutablePointer = nil @@ -58,7 +58,7 @@ class MainVC: UIViewController { bookmarkController = nil libraryController = nil settingController = nil - searchVC = nil + searchController = nil } override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) { @@ -143,28 +143,28 @@ class MainVC: UIViewController { // MARK: - UIViewAnimations func animateInSearchResultController() { - guard let searchVC = self.searchVC ?? UIStoryboard.main.initViewController(SearchVC.self) else {return} - self.searchVC = searchVC - guard !childViewControllers.contains(searchVC) else {return} - addChildViewController(searchVC) - searchVC.view.translatesAutoresizingMaskIntoConstraints = false - view.addSubview(searchVC.view) - searchVC.didMoveToParentViewController(self) - searchVC.view.alpha = 0.5 - searchVC.view.transform = CGAffineTransformMakeScale(0.94, 0.94) + guard let searchController = searchController ?? UIStoryboard.search.instantiateInitialViewController() as? SearchController else {return} + self.searchController = searchController + guard !childViewControllers.contains(searchController) else {return} + addChildViewController(searchController) + searchController.view.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(searchController.view) + searchController.didMoveToParentViewController(self) + searchController.view.alpha = 0.5 + searchController.view.transform = CGAffineTransformMakeScale(0.94, 0.94) - let views = ["searchVC": searchVC.view] - self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[searchVC]|", options: .AlignAllCenterY, metrics: nil, views: views)) - self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[searchVC]|", options: .AlignAllCenterX, metrics: nil, views: views)) + let views = ["SearchController": searchController.view] + self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[SearchController]|", options: .AlignAllCenterY, metrics: nil, views: views)) + self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[SearchController]|", options: .AlignAllCenterX, metrics: nil, views: views)) UIView.animateWithDuration(0.15, delay: 0.0, options: .CurveEaseOut, animations: { () -> Void in - searchVC.view.alpha = 1.0 - searchVC.view.transform = CGAffineTransformIdentity + searchController.view.alpha = 1.0 + searchController.view.transform = CGAffineTransformIdentity }, completion: nil) } func animateOutSearchResultController() { - guard let searchResultVC = searchVC else {return} + guard let searchResultVC = searchController else {return} UIView.animateWithDuration(0.15, delay: 0.0, options: .BeginFromCurrentState, animations: { () -> Void in searchResultVC.view.alpha = 0.0 searchResultVC.view.transform = CGAffineTransformMakeScale(0.96, 0.96) diff --git a/Kiwix-iOS/Controller/MainVCDelegates.swift b/Kiwix-iOS/Controller/MainVCDelegates.swift index 9dcc0af0..2fbd803c 100644 --- a/Kiwix-iOS/Controller/MainVCDelegates.swift +++ b/Kiwix-iOS/Controller/MainVCDelegates.swift @@ -50,11 +50,11 @@ extension MainVC: LPTBarButtonItemDelegate, TableOfContentsDelegate, UISearchBar } func searchBar(searchBar: UISearchBar, textDidChange searchText: String) { - searchVC?.searchText = searchText + searchController?.searchText = searchText } func searchBarSearchButtonClicked(searchBar: UISearchBar) { - searchVC?.searchResultTBVC?.selectFirstResultIfPossible() + searchController?.searchResultTBVC?.selectFirstResultIfPossible() } // MARK: - UIPopoverPresentationControllerDelegate diff --git a/Kiwix-iOS/Controller/Search/RecentSearchCVC.swift b/Kiwix-iOS/Controller/Search/RecentSearchCVC.swift index 8280039e..01203862 100644 --- a/Kiwix-iOS/Controller/Search/RecentSearchCVC.swift +++ b/Kiwix-iOS/Controller/Search/RecentSearchCVC.swift @@ -59,11 +59,11 @@ class RecentSearchCVC: UIViewController, UICollectionViewDataSource, UICollectio func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { guard let mainVC = parentViewController?.parentViewController?.parentViewController as? MainVC, - let searchVC = parentViewController?.parentViewController as? SearchVC, + let SearchController = parentViewController?.parentViewController as? SearchController, let cell = collectionView.cellForItemAtIndexPath(indexPath) as? LocalLangCell, let text = cell.label.text else {return} mainVC.searchBar.text = text - searchVC.searchText = text + SearchController.searchText = text collectionView.deselectItemAtIndexPath(indexPath, animated: true) } diff --git a/Kiwix-iOS/Controller/SearchVC.swift b/Kiwix-iOS/Controller/SearchController.swift similarity index 93% rename from Kiwix-iOS/Controller/SearchVC.swift rename to Kiwix-iOS/Controller/SearchController.swift index 26afaed7..5dc35569 100644 --- a/Kiwix-iOS/Controller/SearchVC.swift +++ b/Kiwix-iOS/Controller/SearchController.swift @@ -1,5 +1,5 @@ // -// SearchVC.swift +// SearchController.swift // Kiwix // // Created by Chris Li on 1/30/16. @@ -8,7 +8,7 @@ import UIKit -class SearchVC: UIViewController, UISearchBarDelegate, UIGestureRecognizerDelegate { +class SearchController: UIViewController, UISearchBarDelegate, UIGestureRecognizerDelegate { @IBOutlet weak var tabControllerContainer: UIView! @IBOutlet weak var searchResultTBVCContainer: UIView! @@ -24,7 +24,7 @@ class SearchVC: UIViewController, UISearchBarDelegate, UIGestureRecognizerDelega override func viewDidLoad() { super.viewDidLoad() - tapGestureRecognizer.addTarget(self, action: #selector(SearchVC.handleTap(_:))) + tapGestureRecognizer.addTarget(self, action: #selector(SearchController.handleTap(_:))) tapGestureRecognizer.delegate = self } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index b2144794..8b3f8477 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -36,7 +36,7 @@ CFBundleSignature ???? CFBundleVersion - 806 + 849 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/Storyboard/Search.storyboard b/Kiwix-iOS/Storyboard/Search.storyboard index b04f6a56..2e76f997 100644 --- a/Kiwix-iOS/Storyboard/Search.storyboard +++ b/Kiwix-iOS/Storyboard/Search.storyboard @@ -7,10 +7,10 @@ - + - + @@ -19,48 +19,46 @@ - + + + + + - - + + - - - + - + - - + - + - - - + + - - + - + - - + @@ -68,10 +66,16 @@ - + + + + + + + @@ -79,75 +83,155 @@ - - + + + + + - + + + + + + + - + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - + - - + - - - + + + + + + + + + + + + + + + + + + + - - + + + @@ -164,7 +248,7 @@ - + @@ -308,6 +392,9 @@ + + + @@ -321,6 +408,9 @@ + + + @@ -446,7 +539,6 @@ - @@ -559,6 +651,9 @@ + + + @@ -616,6 +711,9 @@ + + + diff --git a/Kiwix-iOS/View/ShadowView.swift b/Kiwix-iOS/View/ShadowView.swift index 9045b9a5..6f98de05 100644 --- a/Kiwix-iOS/View/ShadowView.swift +++ b/Kiwix-iOS/View/ShadowView.swift @@ -9,7 +9,6 @@ import UIKit class DropShadowView: UIView { - override func drawRect(rect: CGRect) { layer.masksToBounds = false layer.shadowOffset = CGSizeMake(0, 0) @@ -21,5 +20,26 @@ class DropShadowView: UIView { super.layoutSubviews() layer.shadowPath = UIBezierPath(rect: bounds).CGPath } +} +class SearchHRegularDropShadowView: UIView { + override func awakeFromNib() { + layer.masksToBounds = false + layer.cornerRadius = 10.0 + layer.shadowOffset = CGSizeMake(0, 0) + layer.shadowRadius = 50.0 + layer.shadowOpacity = 0.1 + } + + override func layoutSubviews() { + super.layoutSubviews() + layer.shadowPath = UIBezierPath(rect: bounds).CGPath + } +} + +class SearchRoundedCornerView: UIView { + override func awakeFromNib() { + layer.masksToBounds = true + layer.cornerRadius = 10.0 + } } \ No newline at end of file diff --git a/Kiwix-iOS/iOSExtensions.swift b/Kiwix-iOS/iOSExtensions.swift index 2ff76bba..ba683035 100644 --- a/Kiwix-iOS/iOSExtensions.swift +++ b/Kiwix-iOS/iOSExtensions.swift @@ -42,7 +42,6 @@ extension UIStoryboard { class var setting: UIStoryboard {get {return UIStoryboard(name: "Setting", bundle: nil)}} class var help: UIStoryboard {get {return UIStoryboard(name: "Help", bundle: nil)}} - // @available(*, deprecated=1.7, obsoleted=2.0, message="Use newer API") func initViewController(type: T.Type) -> T? { guard let className = NSStringFromClass(T).componentsSeparatedByString(".").last else { print("NSManagedObjectExtension: Unable to get class name") @@ -58,7 +57,6 @@ extension UIStoryboard { func controller(type: T.Type) -> T? { return instantiateViewControllerWithIdentifier(String(T)) as? T } - } extension UIColor { diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj index b7962751..45eb1d41 100644 --- a/Kiwix.xcodeproj/project.pbxproj +++ b/Kiwix.xcodeproj/project.pbxproj @@ -82,7 +82,7 @@ 971A103F1D022C42007FC62C /* LibraryAutoRefreshTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A103D1D022C42007FC62C /* LibraryAutoRefreshTBVC.swift */; }; 971A10401D022C42007FC62C /* LibraryUseCellularDataTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A103E1D022C42007FC62C /* LibraryUseCellularDataTBVC.swift */; }; 971A10431D022C54007FC62C /* SettingTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10411D022C54007FC62C /* SettingTBVC.swift */; }; - 971A10461D022CB2007FC62C /* SearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10451D022CB2007FC62C /* SearchVC.swift */; }; + 971A10461D022CB2007FC62C /* SearchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10451D022CB2007FC62C /* SearchController.swift */; }; 971A104A1D022CBE007FC62C /* SearchResultTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10471D022CBE007FC62C /* SearchResultTBVC.swift */; }; 971A104B1D022CBE007FC62C /* SearchBooksVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10481D022CBE007FC62C /* SearchBooksVC.swift */; }; 971A10521D022D9D007FC62C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A10511D022D9D007FC62C /* AppDelegate.swift */; }; @@ -396,7 +396,7 @@ 971A103D1D022C42007FC62C /* LibraryAutoRefreshTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibraryAutoRefreshTBVC.swift; path = "Kiwix-iOS/Controller/LibraryAutoRefreshTBVC.swift"; sourceTree = SOURCE_ROOT; }; 971A103E1D022C42007FC62C /* LibraryUseCellularDataTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LibraryUseCellularDataTBVC.swift; path = "Kiwix-iOS/Controller/LibraryUseCellularDataTBVC.swift"; sourceTree = SOURCE_ROOT; }; 971A10411D022C54007FC62C /* SettingTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SettingTBVC.swift; path = "Kiwix-iOS/Controller/SettingTBVC.swift"; sourceTree = SOURCE_ROOT; }; - 971A10451D022CB2007FC62C /* SearchVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchVC.swift; path = "Kiwix-iOS/Controller/SearchVC.swift"; sourceTree = SOURCE_ROOT; }; + 971A10451D022CB2007FC62C /* SearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchController.swift; path = "Kiwix-iOS/Controller/SearchController.swift"; sourceTree = SOURCE_ROOT; }; 971A10471D022CBE007FC62C /* SearchResultTBVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchResultTBVC.swift; path = "Kiwix-iOS/Controller/SearchResultTBVC.swift"; sourceTree = SOURCE_ROOT; }; 971A10481D022CBE007FC62C /* SearchBooksVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchBooksVC.swift; path = "Kiwix-iOS/Controller/SearchBooksVC.swift"; sourceTree = SOURCE_ROOT; }; 971A10511D022D9D007FC62C /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -535,7 +535,6 @@ 97BA32A31CEBC29500339A47 /* RootWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RootWindowController.swift; path = "Kiwix-OSX/Controllers/RootWindowController.swift"; sourceTree = SOURCE_ROOT; }; 97D452BB1D16FF010033666F /* RecentSearchCVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RecentSearchCVC.swift; path = "Kiwix-iOS/Controller/Search/RecentSearchCVC.swift"; sourceTree = SOURCE_ROOT; }; 97D452BD1D1723FF0033666F /* CollectionViewCells.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCells.swift; sourceTree = ""; }; - 97D452BF1D1871E70033666F /* SearchHistoryTBVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchHistoryTBVC.swift; path = "Kiwix-iOS/Controller/Search/SearchHistoryTBVC.swift"; sourceTree = SOURCE_ROOT; }; 97D452C01D1871E70033666F /* SearchLocalBooksCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchLocalBooksCVC.swift; path = "Kiwix-iOS/Controller/Search/SearchLocalBooksCVC.swift"; sourceTree = SOURCE_ROOT; }; 97D452C11D1871E70033666F /* SearchTabController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchTabController.swift; path = "Kiwix-iOS/Controller/Search/SearchTabController.swift"; sourceTree = SOURCE_ROOT; }; 97D55EF51D2075180081B523 /* TableOfContentController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentController.swift; path = "Kiwix-iOS/Controller/TableOfContentController.swift"; sourceTree = SOURCE_ROOT; }; @@ -976,7 +975,6 @@ 9768957A1CB6A35E00F02686 /* Old */ = { isa = PBXGroup; children = ( - 97D452BF1D1871E70033666F /* SearchHistoryTBVC.swift */, 97D452C01D1871E70033666F /* SearchLocalBooksCVC.swift */, 97D452C11D1871E70033666F /* SearchTabController.swift */, ); @@ -1247,7 +1245,7 @@ 97E108221C5D5A0D00E27FD3 /* Search */ = { isa = PBXGroup; children = ( - 971A10451D022CB2007FC62C /* SearchVC.swift */, + 971A10451D022CB2007FC62C /* SearchController.swift */, 97D452BB1D16FF010033666F /* RecentSearchCVC.swift */, 971A10481D022CBE007FC62C /* SearchBooksVC.swift */, 971A10471D022CBE007FC62C /* SearchResultTBVC.swift */, @@ -1860,7 +1858,7 @@ 974570F41C2DABB500680E43 /* ZIMMultiReaderAPI.swift in Sources */, 979CB6511D05C44F005E1BA1 /* PassbookCapability.swift in Sources */, 971A105C1D022DAD007FC62C /* LibraryTabBarController.swift in Sources */, - 971A10461D022CB2007FC62C /* SearchVC.swift in Sources */, + 971A10461D022CB2007FC62C /* SearchController.swift in Sources */, 9779987B1C1E1C9600B1DD5E /* Extensions.swift in Sources */, 979CB6551D05C44F005E1BA1 /* PushCapability-iOS.swift in Sources */, 979CB6831D05C44F005E1BA1 /* OperationObserver.swift in Sources */, From 952e31098291b6f4675886d1951374d5004d0e9e Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 29 Jun 2016 16:36:04 -0400 Subject: [PATCH 3/3] finished! finish recent search bar shadow & background transition when hSizeClass change --- Kiwix-iOS/Info.plist | 2 +- Kiwix-iOS/Storyboard/Search.storyboard | 12 +++++--- Kiwix-iOS/View/ShadowView.swift | 39 ++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 8b3f8477..d525c818 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -36,7 +36,7 @@ CFBundleSignature ???? CFBundleVersion - 849 + 878 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOS/Storyboard/Search.storyboard b/Kiwix-iOS/Storyboard/Search.storyboard index 2e76f997..0d276a78 100644 --- a/Kiwix-iOS/Storyboard/Search.storyboard +++ b/Kiwix-iOS/Storyboard/Search.storyboard @@ -75,7 +75,9 @@ - + + + @@ -112,7 +114,9 @@ - + + + @@ -938,7 +942,7 @@ - + @@ -975,7 +979,7 @@ - + diff --git a/Kiwix-iOS/View/ShadowView.swift b/Kiwix-iOS/View/ShadowView.swift index 6f98de05..278821de 100644 --- a/Kiwix-iOS/View/ShadowView.swift +++ b/Kiwix-iOS/View/ShadowView.swift @@ -9,17 +9,50 @@ import UIKit class DropShadowView: UIView { + var bottomBorder: CALayer? override func drawRect(rect: CGRect) { + switch traitCollection.horizontalSizeClass { + case .Regular: + layer.shadowRadius = 0.0 + layer.shadowOpacity = 0.0 + layer.backgroundColor = UIColor.whiteColor().CGColor + + let border: CALayer = { + if let border = bottomBorder { + return border + } else { + let border = CALayer() + bottomBorder = border + border.backgroundColor = UIColor.lightGrayColor().colorWithAlphaComponent(0.75).CGColor + border.frame = CGRectMake(0, rect.height - 0.5, rect.width, 0.5) + return border + } + }() + layer.addSublayer(border) + case .Compact: + layer.shadowRadius = 2.0 + layer.shadowOpacity = 0.5 + layer.backgroundColor = UIColor(red: 240/255, green: 240/255, blue: 240/255, alpha: 1.0).CGColor + if let border = bottomBorder {border.removeFromSuperlayer()} + default: + break + } + } + + override func awakeFromNib() { layer.masksToBounds = false layer.shadowOffset = CGSizeMake(0, 0) - layer.shadowRadius = 2.0 - layer.shadowOpacity = 0.5 } override func layoutSubviews() { super.layoutSubviews() layer.shadowPath = UIBezierPath(rect: bounds).CGPath } + + override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) { + guard previousTraitCollection != traitCollection else {return} + setNeedsDisplay() + } } class SearchHRegularDropShadowView: UIView { @@ -28,7 +61,7 @@ class SearchHRegularDropShadowView: UIView { layer.cornerRadius = 10.0 layer.shadowOffset = CGSizeMake(0, 0) layer.shadowRadius = 50.0 - layer.shadowOpacity = 0.1 + layer.shadowOpacity = 0.2 } override func layoutSubviews() {