Skip to content

Commit

Permalink
pr-1114: adjustments to TabBarCenteringStyle values and preparation f…
Browse files Browse the repository at this point in the history
…or release 2.16.2
  • Loading branch information
Daniel Dahan committed Jul 9, 2018
1 parent dfa7b8a commit 926d4bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
## 2.16.2

* [pr-1113](https://github.com/CosmicMind/Material/pull/1113): Added update() to Grid.
* [pr-1112](https://github.com/CosmicMind/Material/pull/1112): Added tab bar centering.
* [issue-926](https://github.com/CosmicMind/Material/issues/926): TabsController - centering TabItem after selection.
* [pr-1114](https://github.com/CosmicMind/Material/pull/1114): Added option to adjust tabBar line width.
* [issue-1109](https://github.com/CosmicMind/Material/issues/1109): Want to change TabBar line width.

## 2.16.1

* [issue-1110](https://github.com/CosmicMind/Material/issues/1110): Fixed an issue where the depth of a view was being clipped from incorrectly.
* [issue-1110](https://github.com/CosmicMind/Material/issues/1110): Fixed an issue where the depth of a view was being clipped incorrectly.
* [pr-1111](https://github.com/CosmicMind/Material/pull/1111): Fixed TabItem - was not being changed on swipe.
* [pr-1106](https://github.com/CosmicMind/Material/pull/1106): Added ability to show visibility and clear button at the same time.
* [issue-992](https://github.com/CosmicMind/Material/issues/992): Visibility & Clear Button can't be shown in TextField at the same time.
* [pr-1104](https://github.com/CosmicMind/Material/pull/1104): Added missing devices.
* [pr-1101](https://github.com/CosmicMind/Material/pull/1101): Enum for support iPhoneX.

## 2.16.0

Expand Down Expand Up @@ -30,6 +43,8 @@
* [pr-1097](https://github.com/CosmicMind/Material/pull/1097):: Added new extensions: UIColor(argb:), UIColor(rgb:), UIButton.fontSize, UILabel.fontSize.
* [pr-1093](https://github.com/CosmicMind/Material/pull/1093):: Fix TextField placeholderLabel position.
* [issue-1092](https://github.com/CosmicMind/Material/issues/1092): TextField.placeholderLabel is positioned higher than before in version 2.x.x.
* [pr-1103](https://github.com/CosmicMind/Material/pull/1103): Added ability to change password visibility icons.
* [issue-1012](https://github.com/CosmicMind/Material/issues/1012): Can we set visibility icon custom for password textfield.


## 2.15.0
Expand Down
2 changes: 1 addition & 1 deletion Material.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '2.16.1'
s.version = '2.16.2'
s.swift_version = '4.0'
s.license = 'BSD-3-Clause'
s.summary = 'A UI/UX framework for creating beautiful applications.'
Expand Down
2 changes: 1 addition & 1 deletion Sources/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>2.16.1</string>
<string>2.16.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
14 changes: 11 additions & 3 deletions Sources/iOS/TabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public enum TabBarStyle: Int {

public enum TabBarCenteringStyle {
case never
case whenNeeded
case auto
case always
}

Expand Down Expand Up @@ -243,7 +243,7 @@ open class TabBar: Bar {
}

/// An enum that determines the tab bar centering style.
open var tabBarCenteringStyle = TabBarCenteringStyle.never {
open var tabBarCenteringStyle = TabBarCenteringStyle.always {
didSet {
layoutSubviews()
}
Expand Down Expand Up @@ -513,6 +513,7 @@ fileprivate extension TabBar {

func lineFrame(for tabItem: TabItem, forMotion: Bool = false) -> CGRect {
let y = .bottom == lineAlignment ? scrollView.bounds.height - (forMotion ? lineHeight / 2 : lineHeight) : (forMotion ? lineHeight / 2 : 0)

let w: CGFloat = {
switch tabBarLineStyle {
case .auto:
Expand All @@ -525,7 +526,9 @@ fileprivate extension TabBar {
return closure(tabItem)
}
}()

let x = forMotion ? tabItem.center.x : (tabItem.frame.origin.x + (tabItem.bounds.width - w) / 2)

return CGRect(x: x, y: y, width: w, height: lineHeight)
}
}
Expand Down Expand Up @@ -645,6 +648,7 @@ fileprivate extension TabBar {
selectedTabItem = tabItem

let f = lineFrame(for: tabItem, forMotion: true)

line.animate(.duration(0.25),
.size(f.size),
.position(f.origin),
Expand Down Expand Up @@ -675,17 +679,21 @@ fileprivate extension TabBar {
let shouldScroll = !scrollView.bounds.contains(v.frame)

switch tabBarCenteringStyle {
case .whenNeeded:
case .auto:
guard shouldScroll else {
return nil
}

fallthrough

case .always:
return v.center.x - bounds.width / 2

case .never:
guard shouldScroll else {
return nil
}

return v.frame.origin.x < scrollView.bounds.minX ? v.frame.origin.x : v.frame.maxX - scrollView.bounds.width
}
}()
Expand Down

0 comments on commit 926d4bb

Please sign in to comment.