Skip to content

Commit

Permalink
Merge branch 'master' into feature/view-controller-entry
Browse files Browse the repository at this point in the history
* master:
  Support multiple button (EKButtonBarView) as an entry.
  Bug Fix: EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41

# Conflicts:
#	README.md
#	SwiftEntryKit.podspec
  • Loading branch information
huri000 committed Jun 8, 2018
2 parents 763c7ce + 2c7bbf3 commit 1e99efd
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 37 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# 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

* [EKAlertMessageView fail to layout all of the ButtonContents inside EKAlertMessage #41](https://github.com/huri000/SwiftEntryKit/issues/41)

## 0.3.1

### Features
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -24,7 +24,7 @@ SPEC CHECKSUMS:
Nimble: bfe1f814edabba69ff145cb1283e04ed636a67f2
Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08
QuickLayout: a730730b646b231fd4ef7cffaeb1e81fe0e1ca92
SwiftEntryKit: 3ed2ea7496d22dfba4693f9029a0c217c1915d76
SwiftEntryKit: e2e36ab4cb060d0ce190b4a399a5bca26dcc2bad

PODFILE CHECKSUM: edd6c2af5cc390dbf823427759474ab6c303ec9e

Expand Down
6 changes: 3 additions & 3 deletions Example/Pods/Local Podspecs/SwiftEntryKit.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/SwiftEntryKit/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions Source/MessageViews/EKAlertMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
}
6 changes: 1 addition & 5 deletions Source/MessageViews/EKRatingMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
32 changes: 28 additions & 4 deletions Source/MessageViews/MessagesUtils/EKButtonBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public class EKButtonBarView: UIView {
guard !buttons.isEmpty else {
return
}
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)
Expand Down Expand Up @@ -158,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
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftEntryKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
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' }
Expand Down

0 comments on commit 1e99efd

Please sign in to comment.