diff --git a/.gitignore b/.gitignore index dfbbf7ad..c0e835b1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ DerivedData # Pods/ .idea /Tests/FailureDiffs +xcshareddata +.build diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..c0f5b27e --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "DynamicBlurView", + "repositoryURL": "https://github.com/KyoheiG3/DynamicBlurView.git", + "state": { + "branch": null, + "revision": "fbf91352ff3defee8e1fc7525696404bc3740a86", + "version": "5.0.4" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..9d9d774d --- /dev/null +++ b/Package.swift @@ -0,0 +1,46 @@ +// swift-tools-version:5.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. +// This comment is necessary, and every Package.swift file +// must start with it. +// It tells SPM which version to use. +// It doesn't have to be the same version as your code, +// but it should be compatible. + +import PackageDescription + +let package = Package( + name: "PopupDialog", + // Which platforms and minimum deployment targets are supported + // See: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html#supportedplatform + platforms: [ + .iOS(.v12) + ], + // The externaly visible build artifacts + // See: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html#product + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + // The library that you can actually import + .library( + name: "PopupDialog", + targets: ["PopupDialog"]) + ], + // Your package might need other packages. + // Due to being decentralized you have to tell SPM where to look. + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + .package(url: "https://github.com/KyoheiG3/DynamicBlurView.git", from: "5.0.0") + ], + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + // See: https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html#target + targets: [ + + .target( + name: "PopupDialog", + dependencies:[ + .product(name: "DynamicBlurView", package: "DynamicBlurView") + ], + path: "PopupDialog/Classes") + ] +) diff --git a/PopupDialog/Classes/InteractiveTransition.swift b/PopupDialog/Classes/InteractiveTransition.swift index 0f9f2f43..28182aa2 100644 --- a/PopupDialog/Classes/InteractiveTransition.swift +++ b/PopupDialog/Classes/InteractiveTransition.swift @@ -24,6 +24,7 @@ // import Foundation +import UIKit // Handles interactive transition triggered via pan gesture recognizer on dialog final internal class InteractiveTransition: UIPercentDrivenInteractiveTransition { diff --git a/PopupDialog/Classes/PopupDialog.swift b/PopupDialog/Classes/PopupDialog.swift index 69e7a006..38f4457b 100644 --- a/PopupDialog/Classes/PopupDialog.swift +++ b/PopupDialog/Classes/PopupDialog.swift @@ -254,6 +254,7 @@ final public class PopupDialog: UIViewController { let buttonStackView = popupContainerView.buttonStackView if buttons.isEmpty { stackView.removeArrangedSubview(popupContainerView.buttonStackView) + stackView.removeArrangedSubview(popupContainerView.separator) } for (index, button) in buttons.enumerated() { diff --git a/PopupDialog/Classes/PopupDialogContainerView.swift b/PopupDialog/Classes/PopupDialogContainerView.swift index 4f36e6c0..8058d95f 100644 --- a/PopupDialog/Classes/PopupDialogContainerView.swift +++ b/PopupDialog/Classes/PopupDialogContainerView.swift @@ -48,6 +48,40 @@ final public class PopupDialogContainerView: UIView { } } + /// The corner curve of the popup view + @available(iOS 13.0, *) + @objc public dynamic var cornerCurve: CALayerCornerCurve { + get { return shadowContainer.layer.cornerCurve } + set { + shadowContainer.layer.cornerCurve = newValue + container.layer.cornerCurve = newValue + } + } + + /// The spacing between buttons + @objc public dynamic var buttonsInterSpacing: CGFloat { + get { return buttonStackView.spacing } + set { + buttonStackView.spacing = newValue + } + } + + /// The spacing between buttons and the container view + @objc public dynamic var buttonsContainerSpacing: CGFloat { + get { return buttonStackContainerView.constraints.filter { $0.firstAttribute == .leading }.first?.constant ?? 0 } + set { + buttonStackContainerView.constraints.filter { $0.firstAttribute == .leading }.first?.constant = newValue + } + } + + /// The separator color between buttons and popup content view + @objc public dynamic var separatorColor: UIColor? { + get { return separator.backgroundColor } + set { + separator.backgroundColor = newValue + } + } + // MARK: Shadow related /// Enable / disable shadow rendering of the container @@ -126,10 +160,34 @@ final public class PopupDialogContainerView: UIView { buttonStackView.spacing = 0 return buttonStackView }() + + // The container view for the buttons stack view + internal lazy var buttonStackContainerView: UIView = { + let containerView = UIView() + containerView.translatesAutoresizingMaskIntoConstraints = false + containerView.addSubview(buttonStackView) + NSLayoutConstraint.activate([ + buttonStackView.topAnchor.constraint(equalTo: containerView.topAnchor), + buttonStackView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor), + buttonStackView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: 5), + buttonStackView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor) + ]) + return containerView + }() + + // The separator between the popup content and the buttonsStackContainerView + internal lazy var separator: UIView = { + let line = UIView(frame: .zero) + line.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + line.heightAnchor.constraint(equalToConstant: 1) + ]) + return line + }() // The main stack view, containing all relevant views internal lazy var stackView: UIStackView = { - let stackView = UIStackView(arrangedSubviews: [self.buttonStackView]) + let stackView = UIStackView(arrangedSubviews: [self.separator, self.buttonStackContainerView]) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical stackView.spacing = 0 diff --git a/PopupDialog/Classes/PopupDialogOverlayView.swift b/PopupDialog/Classes/PopupDialogOverlayView.swift index a1326c08..fb8fcff1 100644 --- a/PopupDialog/Classes/PopupDialogOverlayView.swift +++ b/PopupDialog/Classes/PopupDialogOverlayView.swift @@ -25,6 +25,7 @@ import Foundation import DynamicBlurView +import UIKit /// The (blurred) overlay view below the popup dialog final public class PopupDialogOverlayView: UIView {