From 926d4bbd88f1262e0f4090ef886c578473a7e227 Mon Sep 17 00:00:00 2001 From: Daniel Dahan Date: Mon, 9 Jul 2018 12:43:30 -0400 Subject: [PATCH] pr-1114: adjustments to TabBarCenteringStyle values and preparation for release 2.16.2 --- CHANGELOG.md | 17 ++++++++++++++++- Material.podspec | 2 +- Sources/Info.plist | 2 +- Sources/iOS/TabBar.swift | 14 +++++++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e06839ee3..02815def1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/Material.podspec b/Material.podspec index 5d458e535..d3ec0cb4c 100755 --- a/Material.podspec +++ b/Material.podspec @@ -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.' diff --git a/Sources/Info.plist b/Sources/Info.plist index 54afc39cf..fdd61da42 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.16.1 + 2.16.2 CFBundleSignature ???? CFBundleVersion diff --git a/Sources/iOS/TabBar.swift b/Sources/iOS/TabBar.swift index 4cb24c4e8..5f11a1314 100644 --- a/Sources/iOS/TabBar.swift +++ b/Sources/iOS/TabBar.swift @@ -201,7 +201,7 @@ public enum TabBarStyle: Int { public enum TabBarCenteringStyle { case never - case whenNeeded + case auto case always } @@ -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() } @@ -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: @@ -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) } } @@ -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), @@ -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 } }()