From b59629d8ad2efb38c754d07598c9bfc7c2df7bef Mon Sep 17 00:00:00 2001 From: Daniel Huri Date: Wed, 6 Jun 2018 19:50:59 +0300 Subject: [PATCH 1/2] Bug Fix: EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41 --- CHANGELOG.md | 6 ++++++ Example/Podfile.lock | 4 ++-- Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json | 6 +++--- Example/Pods/Manifest.lock | 4 ++-- Example/Pods/Target Support Files/SwiftEntryKit/Info.plist | 2 +- README.md | 4 ++-- Source/MessageViews/MessagesUtils/EKButtonBarView.swift | 1 + SwiftEntryKit.podspec | 4 ++-- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 218b1f7c..c7586e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Change Log Any notable changes to this project will be documented in this file. +## 0.3.2 + +### Bug Fixes + +* [EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41](https://github.com/huri000/SwiftEntryKit/issues/41) + ## 0.3.1 ### Features diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 2c4ed73f..8b446c60 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.0.2) - Quick (1.2.0) - QuickLayout (2.0.2) - - SwiftEntryKit (0.3.1): + - SwiftEntryKit (0.3.2): - QuickLayout (= 2.0.2) DEPENDENCIES: @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: bfe1f814edabba69ff145cb1283e04ed636a67f2 Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08 QuickLayout: a730730b646b231fd4ef7cffaeb1e81fe0e1ca92 - SwiftEntryKit: 3ed2ea7496d22dfba4693f9029a0c217c1915d76 + SwiftEntryKit: e2e36ab4cb060d0ce190b4a399a5bca26dcc2bad PODFILE CHECKSUM: edd6c2af5cc390dbf823427759474ab6c303ec9e diff --git a/Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json b/Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json index f6d8e6e7..f3d56505 100644 --- a/Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json +++ b/Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json @@ -1,12 +1,12 @@ { "name": "SwiftEntryKit", - "version": "0.3.1", + "version": "0.3.2", "summary": "A simple banner and pop-up displayer for iOS. Written in Swift.", "platforms": { "ios": "9.0" }, "requires_arc": true, - "description": "SwiftEntryKit is a banner presenter library for iOS. It can be used to easily display pop-ups and notification-like views within your iOS apps. SwiftEntryKit is highly customizable but also offsers a bunch of beatiful presets that can be themed with your app fonts and colors.", + "description": "SwiftEntryKit is a banner presenter library for iOS. It can be used to easily display pop-ups and notification-like views within your iOS apps. SwiftEntryKit is highly customizable but also offers a bunch of beautiful presets that can be themed with your app fonts and colors.", "homepage": "https://github.com/huri000/SwiftEntryKit", "license": { "type": "MIT", @@ -17,7 +17,7 @@ }, "source": { "git": "https://github.com/huri000/SwiftEntryKit.git", - "tag": "0.3.1" + "tag": "0.3.2" }, "source_files": "Source/**/*", "frameworks": "UIKit", diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 2c4ed73f..8b446c60 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -2,7 +2,7 @@ PODS: - Nimble (7.0.2) - Quick (1.2.0) - QuickLayout (2.0.2) - - SwiftEntryKit (0.3.1): + - SwiftEntryKit (0.3.2): - QuickLayout (= 2.0.2) DEPENDENCIES: @@ -24,7 +24,7 @@ SPEC CHECKSUMS: Nimble: bfe1f814edabba69ff145cb1283e04ed636a67f2 Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08 QuickLayout: a730730b646b231fd4ef7cffaeb1e81fe0e1ca92 - SwiftEntryKit: 3ed2ea7496d22dfba4693f9029a0c217c1915d76 + SwiftEntryKit: e2e36ab4cb060d0ce190b4a399a5bca26dcc2bad PODFILE CHECKSUM: edd6c2af5cc390dbf823427759474ab6c303ec9e diff --git a/Example/Pods/Target Support Files/SwiftEntryKit/Info.plist b/Example/Pods/Target Support Files/SwiftEntryKit/Info.plist index 1caf1ff8..03a923c0 100644 --- a/Example/Pods/Target Support Files/SwiftEntryKit/Info.plist +++ b/Example/Pods/Target Support Files/SwiftEntryKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.3.1 + 0.3.2 CFBundleSignature ???? CFBundleVersion diff --git a/README.md b/README.md index 6493d379..db7f84d8 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ source 'https://github.com/cocoapods/specs.git' platform :ios, '9.0' use_frameworks! -pod 'SwiftEntryKit', '0.3.1' +pod 'SwiftEntryKit', '0.3.2' ``` Then, run the following command: @@ -150,7 +150,7 @@ $ brew install carthage To integrate SwiftEntryKit into your Xcode project using Carthage, specify the following in your `Cartfile`: ```ogdl -github "huri000/SwiftEntryKit" == 0.3.1 +github "huri000/SwiftEntryKit" == 0.3.2 ``` ## Usage diff --git a/Source/MessageViews/MessagesUtils/EKButtonBarView.swift b/Source/MessageViews/MessagesUtils/EKButtonBarView.swift index a4614c6a..6779d8c9 100644 --- a/Source/MessageViews/MessagesUtils/EKButtonBarView.swift +++ b/Source/MessageViews/MessagesUtils/EKButtonBarView.swift @@ -85,6 +85,7 @@ public class EKButtonBarView: UIView { guard !buttons.isEmpty else { return } + Array(buttons.dropFirst()).layout(.height, to: buttons.first!) buttons.layoutToSuperview(axis: oppositeAxis) buttons.spread(spreadAxis, stretchEdgesToSuperview: true) buttons.layout(relativeEdge, to: self, ratio: buttonEdgeRatio, priority: .must) diff --git a/SwiftEntryKit.podspec b/SwiftEntryKit.podspec index f86a4e4f..2f8b2fe0 100644 --- a/SwiftEntryKit.podspec +++ b/SwiftEntryKit.podspec @@ -8,14 +8,14 @@ Pod::Spec.new do |s| s.name = 'SwiftEntryKit' - s.version = '0.3.1' + s.version = '0.3.2' s.summary = 'A simple banner and pop-up displayer for iOS. Written in Swift.' s.platform = :ios s.ios.deployment_target = '9.0' s.requires_arc = true s.description = <<-DESC -SwiftEntryKit is a banner presenter library for iOS. It can be used to easily display pop-ups and notification-like views within your iOS apps. SwiftEntryKit is highly customizable but also offsers a bunch of beautiful presets that can be themed with your app fonts and colors. +SwiftEntryKit is a banner presenter library for iOS. It can be used to easily display pop-ups and notification-like views within your iOS apps. SwiftEntryKit is highly customizable but also offers a bunch of beautiful presets that can be themed with your app fonts and colors. DESC s.homepage = 'https://github.com/huri000/SwiftEntryKit' s.license = { :type => 'MIT', :file => 'LICENSE' } From 18cb849193676e4615a0df6797978ce12e911124 Mon Sep 17 00:00:00 2001 From: Daniel Huri Date: Wed, 6 Jun 2018 20:39:51 +0300 Subject: [PATCH 2/2] Support multiple button (EKButtonBarView) as an entry. --- CHANGELOG.md | 9 +++++ README.md | 4 +-- Source/MessageViews/EKAlertMessageView.swift | 21 ++---------- Source/MessageViews/EKRatingMessageView.swift | 6 +--- .../MessagesUtils/EKButtonBarView.swift | 33 ++++++++++++++++--- SwiftEntryKit.podspec | 2 +- 6 files changed, 43 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7586e64..3c173cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Change Log Any notable changes to this project will be documented in this file. +## 0.3.3 + +### Issues Handled: +* [Multiple button support? #19](https://github.com/huri000/SwiftEntryKit/issues/19) + +### Changes: + +EKButtonBarView exposes `func expand()`, it + ## 0.3.2 ### Bug Fixes diff --git a/README.md b/README.md index db7f84d8..fb4c83b5 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ source 'https://github.com/cocoapods/specs.git' platform :ios, '9.0' use_frameworks! -pod 'SwiftEntryKit', '0.3.2' +pod 'SwiftEntryKit', '0.3.3' ``` Then, run the following command: @@ -150,7 +150,7 @@ $ brew install carthage To integrate SwiftEntryKit into your Xcode project using Carthage, specify the following in your `Cartfile`: ```ogdl -github "huri000/SwiftEntryKit" == 0.3.2 +github "huri000/SwiftEntryKit" == 0.3.3 ``` ## Usage diff --git a/Source/MessageViews/EKAlertMessageView.swift b/Source/MessageViews/EKAlertMessageView.swift index cf527619..9d940dc6 100644 --- a/Source/MessageViews/EKAlertMessageView.swift +++ b/Source/MessageViews/EKAlertMessageView.swift @@ -72,34 +72,17 @@ public class EKAlertMessageView: EKSimpleMessageView { if !message.buttonBarContent.content.isEmpty { if message.buttonBarContent.expandAnimatedly { - let damping: CGFloat = message.buttonBarContent.content.count <= 2 ? 0.4 : 0.8 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - self.animateIn(damping: damping) + self.buttonBarView.expand() } } else { - buttonBarView.alpha = 1 buttonBarView.expand() - SwiftEntryKit.layoutIfNeeded() } } } // MARK: Internal Animation private func animateIn(damping: CGFloat) { - SwiftEntryKit.layoutIfNeeded() - buttonBarView.alpha = 1 - - UIView.animate(withDuration: 0.8, delay: 0, usingSpringWithDamping: damping, initialSpringVelocity: 0, options: [.beginFromCurrentState, .allowUserInteraction, .layoutSubviews, .allowAnimatedContent], animations: { - - // Expand - self.buttonBarView.expand() - - /* NOTE: Calling layoutIfNeeded for the whole view hierarchy. - Sometimes it's easier to just use frames instead of AutoLayout for - hierarch complexity considerations. Here the animation influences almost the - entire view hierarchy. */ - SwiftEntryKit.layoutIfNeeded() - - }, completion: nil) + } } diff --git a/Source/MessageViews/EKRatingMessageView.swift b/Source/MessageViews/EKRatingMessageView.swift index 340cbf92..c2b90791 100644 --- a/Source/MessageViews/EKRatingMessageView.swift +++ b/Source/MessageViews/EKRatingMessageView.swift @@ -78,10 +78,6 @@ public class EKRatingMessageView: UIView { // MARK: Internal Animation private func animateIn() { layoutIfNeeded() - buttonBarView.alpha = 1 - UIView.animate(withDuration: 0.8, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [.beginFromCurrentState, .allowUserInteraction, .layoutSubviews], animations: { - self.buttonBarView.expand() - SwiftEntryKit.layoutIfNeeded() - }, completion: nil) + buttonBarView.expand() } } diff --git a/Source/MessageViews/MessagesUtils/EKButtonBarView.swift b/Source/MessageViews/MessagesUtils/EKButtonBarView.swift index 6779d8c9..f63cbdac 100644 --- a/Source/MessageViews/MessagesUtils/EKButtonBarView.swift +++ b/Source/MessageViews/MessagesUtils/EKButtonBarView.swift @@ -85,7 +85,10 @@ public class EKButtonBarView: UIView { guard !buttons.isEmpty else { return } - Array(buttons.dropFirst()).layout(.height, to: buttons.first!) + let suffix = Array(buttons.dropFirst()) + if !suffix.isEmpty { + suffix.layout(.height, to: buttons.first!) + } buttons.layoutToSuperview(axis: oppositeAxis) buttons.spread(spreadAxis, stretchEdgesToSuperview: true) buttons.layout(relativeEdge, to: self, ratio: buttonEdgeRatio, priority: .must) @@ -159,12 +162,32 @@ public class EKButtonBarView: UIView { } // Amination - func expand() { - compressedConstraint.priority = .defaultLow - expandedConstraint.priority = .must + public func expand() { + + let expansion = { + self.compressedConstraint.priority = .defaultLow + self.expandedConstraint.priority = .must + + /* NOTE: Calling layoutIfNeeded for the whole view hierarchy. + Sometimes it's easier to just use frames instead of AutoLayout for + hierarch complexity considerations. Here the animation influences almost the + entire view hierarchy. */ + SwiftEntryKit.layoutIfNeeded() + } + + alpha = 1 + if buttonBarContent.expandAnimatedly { + let damping: CGFloat = buttonBarContent.content.count <= 2 ? 0.4 : 0.8 + SwiftEntryKit.layoutIfNeeded() + UIView.animate(withDuration: 0.8, delay: 0, usingSpringWithDamping: damping, initialSpringVelocity: 0, options: [.beginFromCurrentState, .allowUserInteraction, .layoutSubviews, .allowAnimatedContent], animations: { + expansion() + }, completion: nil) + } else { + expansion() + } } - func compress() { + public func compress() { compressedConstraint.priority = .must expandedConstraint.priority = .defaultLow } diff --git a/SwiftEntryKit.podspec b/SwiftEntryKit.podspec index 2f8b2fe0..5029bbd9 100644 --- a/SwiftEntryKit.podspec +++ b/SwiftEntryKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'SwiftEntryKit' - s.version = '0.3.2' + s.version = '0.3.3' s.summary = 'A simple banner and pop-up displayer for iOS. Written in Swift.' s.platform = :ios s.ios.deployment_target = '9.0'