Skip to content

Commit 5e0312e

Browse files
committed
Crash fix on <5 items rend, delegation updates
1 parent 7abd077 commit 5e0312e

File tree

7 files changed

+33
-22
lines changed

7 files changed

+33
-22
lines changed

ExpandedTabBar.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'ExpandedTabBar'
3-
s.version = '3.0.0'
3+
s.version = '3.0.1'
44
s.summary = 'ExpandedTabBar is a very creative designed solution for "more" items in UITabBarController'
55

66
s.homepage = 'https://github.com/yervandsar/ExpandedTabBar'

ExpandedTabBar.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,12 @@
508508
buildSettings = {
509509
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
510510
CODE_SIGN_STYLE = Automatic;
511+
CURRENT_PROJECT_VERSION = 4;
511512
DEVELOPMENT_TEAM = 94ST773MP3;
512513
INFOPLIST_FILE = ExpandedTabBar/Info.plist;
513514
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
514515
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
515-
MARKETING_VERSION = 2.0.2;
516+
MARKETING_VERSION = 3.0.1;
516517
PRODUCT_BUNDLE_IDENTIFIER = com.yervandsar.ExpandedTabBar;
517518
PRODUCT_NAME = "$(TARGET_NAME)";
518519
SWIFT_VERSION = 5.0;
@@ -525,11 +526,12 @@
525526
buildSettings = {
526527
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
527528
CODE_SIGN_STYLE = Automatic;
529+
CURRENT_PROJECT_VERSION = 4;
528530
DEVELOPMENT_TEAM = 94ST773MP3;
529531
INFOPLIST_FILE = ExpandedTabBar/Info.plist;
530532
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
531533
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
532-
MARKETING_VERSION = 2.0.2;
534+
MARKETING_VERSION = 3.0.1;
533535
PRODUCT_BUNDLE_IDENTIFIER = com.yervandsar.ExpandedTabBar;
534536
PRODUCT_NAME = "$(TARGET_NAME)";
535537
SWIFT_VERSION = 5.0;

ExpandedTabBar/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>$(MARKETING_VERSION)</string>
1919
<key>CFBundleVersion</key>
20-
<string>3</string>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UILaunchStoryboardName</key>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ExpandedTabBar v3.0.0
1+
# ExpandedTabBar v3.0.1
22
![Platform](https://img.shields.io/badge/platform-iOS-black.svg) ![Badge w/ Version](https://img.shields.io/cocoapods/v/ExpandedTabBar.svg) ![Platform](https://img.shields.io/badge/Swift_Package_Manager-compatible-green.svg)
33

44

Sources/ExpandedTabBar/ExpandedTabBarConstraints.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ internal extension ExpandedTabBarController {
8585
/// Adding container view to background
8686
func addContainerView(with items: [UIStackView]) {
8787

88-
parentContainerView = ContainerView.create(for: tabBar)
88+
let parentContainerView = ContainerView.create(for: tabBar)
8989
parentContainerView.roundCorners(corners: options.container.roundedCorners,
9090
radius: options.container.cornerRadius)
9191
parentContainerView.setOptions(options.container)
@@ -114,6 +114,8 @@ internal extension ExpandedTabBarController {
114114

115115
parentViewWidthConstraint = widthConstraint
116116
parentViewHeightConstraint = heightConstraint
117+
118+
self.parentContainerView = parentContainerView
117119
}
118120

119121
/// Content indicator right margin.

Sources/ExpandedTabBar/ExpandedTabBarController.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ open class ExpandedTabBarController: UITabBarController {
5050
internal var innerContainer = UIView()
5151
internal var indicatorView = UIView()
5252

53-
internal var parentContainerView: ContainerView!
53+
internal var parentContainerView: ContainerView?
5454

5555
// MARK: Constraints
5656
internal var indicatorRightConstraint: NSLayoutConstraint?
@@ -90,8 +90,8 @@ open class ExpandedTabBarController: UITabBarController {
9090
bgViewBottomConstraint?.constant = -1 * offset
9191

9292
let maxSize = ExpandedTabBarViews.containerMaxSize
93-
let containerWidth = min(maxSize.width - 40, parentContainerView.stackView.frame.size.width)
94-
let containerHeight = min(maxSize.height - 40, parentContainerView.stackView.frame.size.height)
93+
let containerWidth = min(maxSize.width - 40, parentContainerView?.stackView.frame.size.width ?? 0)
94+
let containerHeight = min(maxSize.height - 40, parentContainerView?.stackView.frame.size.height ?? 0)
9595

9696
parentViewWidthConstraint?.constant = max(200, containerWidth)
9797
parentViewHeightConstraint?.constant = containerHeight
@@ -135,36 +135,38 @@ open class ExpandedTabBarController: UITabBarController {
135135
// MARK: - Animartion Handling
136136
internal extension ExpandedTabBarController {
137137
func showMoreContainer() {
138+
guard let parent = self.parentContainerView else { return }
138139

139-
self.options.animationType.animation
140-
.willShow(container: self.parentContainerView, background: self.backgroundView)
140+
self.options.animationType.animation.willShow(container: parent, background: self.backgroundView)
141141

142142
let showAnimation = {
143143
self.backgroundView.alpha = 1
144-
self.options.animationType.animation.show(container: self.parentContainerView, on: self.backgroundView)
144+
self.options.animationType.animation.show(container: parent, on: self.backgroundView)
145145
self.backgroundView.layoutIfNeeded()
146146
}
147147

148-
UIView.animate(withDuration: options.animationType.animation.duration, animations: showAnimation) { _ in
149-
self.options.animationType.animation
150-
.didShow(container: self.parentContainerView, background: self.backgroundView)
148+
UIView.animate(withDuration: options.animationType.animation.duration, animations: showAnimation) {
149+
[weak self] _ in
150+
guard let self = self else { return }
151+
self.options.animationType.animation.didShow(container: parent, background: self.backgroundView)
151152
}
152153
}
153154

154155
func hideMoreContainer() {
156+
guard let parent = self.parentContainerView else { return }
155157

156-
self.options.animationType.animation
157-
.willHide(container: self.parentContainerView, background: self.backgroundView)
158+
self.options.animationType.animation.willHide(container: parent, background: self.backgroundView)
158159

159160
let hideAnimation = {
160-
self.options.animationType.animation.hide(container: self.parentContainerView, from: self.backgroundView)
161+
self.options.animationType.animation.hide(container: parent, from: self.backgroundView)
161162
self.backgroundView.alpha = 0
162163
self.backgroundView.layoutIfNeeded()
163164
}
164165

165-
UIView.animate(withDuration: options.animationType.animation.duration, animations: hideAnimation) { _ in
166-
self.options.animationType.animation
167-
.didHide(container: self.parentContainerView, background: self.backgroundView)
166+
UIView.animate(withDuration: options.animationType.animation.duration, animations: hideAnimation) {
167+
[weak self] _ in
168+
guard let self = self else { return }
169+
self.options.animationType.animation.didHide(container: parent, background: self.backgroundView)
168170
}
169171
}
170172
}

Sources/ExpandedTabBar/ExpandedTabBarControllerDelegate.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ extension ExpandedTabBarController: UITabBarControllerDelegate {
2525
public func tabBarController(_ tabBarController: UITabBarController,
2626
didSelect viewController: UIViewController) {
2727
deselectMore()
28+
expandedDelegate?.expandedTabBarController(self,
29+
didSelect: viewController,
30+
withItem: viewController.tabBarItem)
2831
}
2932
}
3033

@@ -43,7 +46,9 @@ internal extension ExpandedTabBarController {
4346
viewControllers?[index] = selectedViewController
4447
self.selectedIndex = index
4548

46-
expandedDelegate?.expandedTabBarController(self, didSelect: selectedViewController, withItem: tabBarItem)
49+
expandedDelegate?.expandedTabBarController(self,
50+
didSelect: selectedViewController,
51+
withItem: tabBarItem)
4752
}
4853

4954
private func deselectMore() {

0 commit comments

Comments
 (0)