From e7ef5f3594b60c7482c67ee1ecaedc5b77a49b8a Mon Sep 17 00:00:00 2001 From: Afshin Hoseini Date: Fri, 3 May 2019 22:57:02 +0430 Subject: [PATCH 1/5] Resolves #9 --- .../LimberTabbar/Tabbar/AHLimberTabbar.swift | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/LimberTabbar/LimberTabbar/Tabbar/AHLimberTabbar.swift b/LimberTabbar/LimberTabbar/Tabbar/AHLimberTabbar.swift index a9301a8..2000718 100644 --- a/LimberTabbar/LimberTabbar/Tabbar/AHLimberTabbar.swift +++ b/LimberTabbar/LimberTabbar/Tabbar/AHLimberTabbar.swift @@ -15,7 +15,13 @@ import UIKit @IBDesignable public class AHLimberTabbar : UITabBar { + @IBInspectable + var observeSafeAreaInsets : Bool = true + var boundObserver : NSKeyValueObservation? + var safeViewInsetsObserver : NSKeyValueObservation? + var itemObserver : NSKeyValueObservation? + /** Since both background and bar tint colors will be null, this variable will capture the color on initialization. */ @@ -60,10 +66,17 @@ public class AHLimberTabbar : UITabBar { } - var itemObserver : NSKeyValueObservation? + deinit { + + itemObserver = nil + safeViewInsetsObserver = nil + boundObserver = nil + } + func commonInit() { + //Observes the selected item property and animates the selection. itemObserver = observe(\.selectedItem, changeHandler: { (ob, v) in if let selectedItem = self.selectedItem, let index = self.items?.firstIndex(of: selectedItem) { @@ -82,13 +95,41 @@ public class AHLimberTabbar : UITabBar { self.shadowImage = UIImage() } + /** + Calculates the maximum depth of the pit. + */ private func getPitDepth() -> CGFloat { - return bounds.height * 0.8 + var percentage = CGFloat(0.8) + var safeAreaBottomInset = CGFloat(0) + + //Calculates the depth according to safeArea insets + if observeSafeAreaInsets, #available(iOS 11, *) { + + safeAreaBottomInset = CGFloat(self.safeAreaInsets.bottom) + percentage = safeAreaBottomInset > 0 ? 1 : percentage + } + + return (bounds.height - safeAreaBottomInset) * percentage } + public override func awakeFromNib() { + + //Observes the safe area insets change if determined + if observeSafeAreaInsets, #available(iOS 11.0, *) { + + self.safeViewInsetsObserver = observe(\.safeAreaInsets, options: .init(arrayLiteral: .new, .old)) { (context, value) in + + if value.oldValue?.bottom != value.newValue?.bottom { + + print("Recalc pit height") + self.reselectCurrentTab() + } + } + } + //Initializes the selected tab holder view. (That circle view) self.selectedTabHolder = AHSelectedTabItem(size: getPitDepth()) self.selectedTabHolder.tintColor = self.tintColor From 3b745650986f55ac6736a1f2dfa5f03bf5dbd2ab Mon Sep 17 00:00:00 2001 From: Afshin Hoseini Date: Fri, 3 May 2019 22:58:02 +0430 Subject: [PATCH 2/5] Completed example according to #9 --- LimberTabbar.podspec | 2 +- .../Base.lproj/Main.storyboard | 22 +++++++++++-------- LimberTabbarExample/Podfile | 1 + LimberTabbarExample/Podfile.lock | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/LimberTabbar.podspec b/LimberTabbar.podspec index 7080602..bf3dbac 100644 --- a/LimberTabbar.podspec +++ b/LimberTabbar.podspec @@ -23,7 +23,7 @@ TODO: Add long description of the pod here. s.homepage = 'https://github.com/afshin-hoseini/LimberTabbar.iOS' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' - s.license = { :type => 'MIT', :file => 'LICENSE' } + s.license = { :type => 'MIT', :file => 'LimberTabbar/LICENSE' } s.author = { 'afshin.hoseini@gmail.com' => 'afshin.hoseini@gmail.com' } s.source = { :git => 'https://github.com/afshin.hoseini@gmail.com/LimberTabbar.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/hoseini_afshin' diff --git a/LimberTabbarExample/LimberTabbarExample/Base.lproj/Main.storyboard b/LimberTabbarExample/LimberTabbarExample/Base.lproj/Main.storyboard index 51c62de..8dbcdf5 100644 --- a/LimberTabbarExample/LimberTabbarExample/Base.lproj/Main.storyboard +++ b/LimberTabbarExample/LimberTabbarExample/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -273,9 +273,10 @@ - + + @@ -291,13 +292,16 @@ + + + - + @@ -339,10 +343,10 @@ - - - - - + + + + + diff --git a/LimberTabbarExample/Podfile b/LimberTabbarExample/Podfile index a0d767c..c0ebfde 100644 --- a/LimberTabbarExample/Podfile +++ b/LimberTabbarExample/Podfile @@ -7,6 +7,7 @@ target 'LimberTabbarExample' do # Pods for LimberTabbarExample pod 'LimberTabbar', :path => '..' + #pod 'LimberTabbar', :git=> 'https://github.com/afshin-hoseini/LimberTabbar.iOS.git', :tag=> '0.1.0' end diff --git a/LimberTabbarExample/Podfile.lock b/LimberTabbarExample/Podfile.lock index 4d9655c..6ee4506 100644 --- a/LimberTabbarExample/Podfile.lock +++ b/LimberTabbarExample/Podfile.lock @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - LimberTabbar: 93a9503010616cda00f6f673e87a39649091299d + LimberTabbar: d6a21c71b79f603b282e4af4ff3abd3637a8e5f6 -PODFILE CHECKSUM: edaa0b8682e6b6666e50f2cd811b0269ba5b08c8 +PODFILE CHECKSUM: 0de60538cbbe212e2f7eec2df818676647d1f6b2 COCOAPODS: 1.6.0.beta.2 From e3603027409e472d65a86b9cb565c02bf5d90bde Mon Sep 17 00:00:00 2001 From: Afshin Hoseini Date: Wed, 24 Apr 2019 23:47:45 +0430 Subject: [PATCH 3/5] Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4173fbc..2df186a 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,15 @@ Currently there isn't many thing to do but you can: You can also specify background and icon tint color for each tab bar item, through changing the tabbarItem's class to `AHLimberTabbarItem` on identity inspector tab, in interface builder. # NOTICE -1.The `AHLimberTabbarController` just overrides the definition of `tabBar(_: didSelect:)` function in order to change the default behaviour of `UITabbarController`. Therefore, it may corrupt you custom code and disable specific delegation. -2. Current version is just a concept an is not fully tested. Please test it completely along side your development and make sure that meets your needs. +1. The `AHLimberTabbarController` just overrides the definition of `tabBar(_: didSelect:)` function in order to change the default behaviour of `UITabbarController`. Therefore, it may corrupt you custom code and disable specific delegation. + +2. Current version is just a concept an is not fully tested. Please test it completely along side your development and make sure that meets your needs. + +3. [#9](https://github.com/afshin-hoseini/LimberTabbar.iOS/issues/9) # To do 1. Better `AHLimberTabbarController`. 2. Multiple animations for `AHLimberTabbar`. 3. Custom transition animations for `AHLimberTabbarController`. -4. Showing badges. \ No newline at end of file +4. Showing badges. From b6b39a7ddd9251cc975c8ade17101a5c5af96bed Mon Sep 17 00:00:00 2001 From: Afshin Hoseini Date: Fri, 3 May 2019 23:07:42 +0430 Subject: [PATCH 4/5] Updated readme based on #9 changes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2df186a..e3e3e52 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ Currently there isn't many thing to do but you can: You can also specify background and icon tint color for each tab bar item, through changing the tabbarItem's class to `AHLimberTabbarItem` on identity inspector tab, in interface builder. +The `AHLimberTabbar` adjusts the the pit's depth according to the safe area insets. If you wish to ignore the safe area insets, make the `observeSafeAreaInsets` option `off` in interface builder. + # NOTICE 1. The `AHLimberTabbarController` just overrides the definition of `tabBar(_: didSelect:)` function in order to change the default behaviour of `UITabbarController`. Therefore, it may corrupt you custom code and disable specific delegation. 2. Current version is just a concept an is not fully tested. Please test it completely along side your development and make sure that meets your needs. -3. [#9](https://github.com/afshin-hoseini/LimberTabbar.iOS/issues/9) - # To do 1. Better `AHLimberTabbarController`. From e75fbca70d2041c5f9a51e79a277d282ee247a18 Mon Sep 17 00:00:00 2001 From: Afshin Hoseini Date: Fri, 3 May 2019 23:11:24 +0430 Subject: [PATCH 5/5] Upgraded version to 0.2.0 --- LimberTabbar.podspec | 4 ++-- LimberTabbar/LimberTabbar/Info.plist | 2 +- README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LimberTabbar.podspec b/LimberTabbar.podspec index bf3dbac..27977fd 100644 --- a/LimberTabbar.podspec +++ b/LimberTabbar.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'LimberTabbar' - s.version = '0.1.0' + s.version = '0.2.0' s.summary = 'Yet another tabbar with smooth animation.' # This description is used to generate tags and improve search results. @@ -28,7 +28,7 @@ TODO: Add long description of the pod here. s.source = { :git => 'https://github.com/afshin.hoseini@gmail.com/LimberTabbar.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/hoseini_afshin' - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.source_files = 'LimberTabbar/**/*.swift' diff --git a/LimberTabbar/LimberTabbar/Info.plist b/LimberTabbar/LimberTabbar/Info.plist index e1fe4cf..e1c33fb 100644 --- a/LimberTabbar/LimberTabbar/Info.plist +++ b/LimberTabbar/LimberTabbar/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 0.2.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/README.md b/README.md index e3e3e52..7130457 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Another iOS tabbar with smooth animation and more limber view. You can implement This is the very first released of this library and it is under test. It soon be available on cocoapod repo. Currenly you can install the first version by adding the line below to your `podfile`. ``` -pod 'LimberTabbar', :git=> 'https://github.com/afshin-hoseini/LimberTabbar.iOS.git', :tag=> '0.1.0' +pod 'LimberTabbar', :git=> 'https://github.com/afshin-hoseini/LimberTabbar.iOS.git', :tag=> '0.2.0' ``` and then do a `pod install`