Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
afshin-hoseini committed May 3, 2019
2 parents e1285ae + e75fbca commit 2620186
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 20 deletions.
6 changes: 3 additions & 3 deletions LimberTabbar.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,12 +23,12 @@ 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'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '9.0'

s.source_files = 'LimberTabbar/**/*.swift'

Expand Down
2 changes: 1 addition & 1 deletion LimberTabbar/LimberTabbar/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.2.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
45 changes: 43 additions & 2 deletions LimberTabbar/LimberTabbar/Tabbar/AHLimberTabbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down
22 changes: 13 additions & 9 deletions LimberTabbarExample/LimberTabbarExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HxE-WB-imS">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HxE-WB-imS">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -273,9 +273,10 @@
<action selector="onGuideSquaresSwitchValueChanged:" destination="qhp-3K-jku" eventType="valueChanged" id="JBq-UD-6bC"/>
</connections>
</switch>
<tabBar contentMode="scaleToFill" itemPositioning="fill" translatesAutoresizingMaskIntoConstraints="NO" id="vLJ-1s-lDG" customClass="AHLimberTabbar" customModule="LimberTabbar">
<tabBar contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" itemPositioning="fill" translatesAutoresizingMaskIntoConstraints="NO" id="vLJ-1s-lDG" customClass="AHLimberTabbar" customModule="LimberTabbar">
<rect key="frame" x="0.0" y="519" width="320" height="49"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<viewLayoutGuide key="safeArea" id="6jr-aH-aSl"/>
<items>
<tabBarItem image="Face" id="vkY-82-Lpd" customClass="AHLimberTabbarItem" customModule="LimberTabbar"/>
<tabBarItem image="Alarm" id="NVT-af-e8g" customClass="AHLimberTabbarItem" customModule="LimberTabbar"/>
Expand All @@ -291,13 +292,16 @@
</items>
<color key="barTintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="selectedImageTintColor" red="0.18377019095816666" green="0.19598462580444592" blue="0.21545470664060917" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="observeSafeAreaInsets" value="NO"/>
</userDefinedRuntimeAttributes>
</tabBar>
</subviews>
<color key="backgroundColor" red="1" green="0.2274509804" blue="0.18823529410000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="yTG-ik-cWx" firstAttribute="trailing" secondItem="y0D-tL-cS3" secondAttribute="trailing" id="75y-rL-uAl"/>
<constraint firstItem="qQl-ZD-f51" firstAttribute="centerY" secondItem="q7m-cF-3xH" secondAttribute="centerY" id="7ns-22-bF9"/>
<constraint firstAttribute="bottom" secondItem="vLJ-1s-lDG" secondAttribute="bottom" id="Ffg-hD-ciJ"/>
<constraint firstAttribute="bottom" secondItem="vLJ-1s-lDG" secondAttribute="bottom" id="Eyc-Yh-Ez3"/>
<constraint firstItem="y0D-tL-cS3" firstAttribute="top" secondItem="XBZ-tq-kdW" secondAttribute="bottom" constant="16" id="Gcz-oB-bda"/>
<constraint firstItem="q7m-cF-3xH" firstAttribute="leading" secondItem="y0D-tL-cS3" secondAttribute="leading" id="Ndt-DM-dpP"/>
<constraint firstItem="y0D-tL-cS3" firstAttribute="width" secondItem="tpc-VL-EZd" secondAttribute="width" id="PQQ-H2-ibe"/>
Expand Down Expand Up @@ -339,10 +343,10 @@
</scene>
</scenes>
<resources>
<image name="Alarm" width="48" height="48"/>
<image name="Calendar" width="48" height="48"/>
<image name="Face" width="48" height="48"/>
<image name="Favorite" width="48" height="48"/>
<image name="FingerPrint" width="48" height="48"/>
<image name="Alarm" width="24" height="24"/>
<image name="Calendar" width="24" height="24"/>
<image name="Face" width="24" height="24"/>
<image name="Favorite" width="24" height="24"/>
<image name="FingerPrint" width="24" height="24"/>
</resources>
</document>
1 change: 1 addition & 0 deletions LimberTabbarExample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions LimberTabbarExample/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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`.
Expand Down

0 comments on commit 2620186

Please sign in to comment.