Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some UI customization options #384

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ DerivedData
# Pods/
.idea
/Tests/FailureDiffs
xcshareddata
.build
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

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

16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}
46 changes: 46 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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:[

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

.product(name: "DynamicBlurView", package: "DynamicBlurView")
],
path: "PopupDialog/Classes")
]
)
1 change: 1 addition & 0 deletions PopupDialog/Classes/InteractiveTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//

import Foundation
import UIKit

// Handles interactive transition triggered via pan gesture recognizer on dialog
final internal class InteractiveTransition: UIPercentDrivenInteractiveTransition {
Expand Down
1 change: 1 addition & 0 deletions PopupDialog/Classes/PopupDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
60 changes: 59 additions & 1 deletion PopupDialog/Classes/PopupDialogContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

/// The spacing between buttons
@objc public dynamic var buttonsInterSpacing: CGFloat {
get { return buttonStackView.spacing }
set {
buttonStackView.spacing = newValue
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

/// 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 }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 121 characters (line_length)

set {
buttonStackContainerView.constraints.filter { $0.firstAttribute == .leading }.first?.constant = newValue
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

/// The separator color between buttons and popup content view
@objc public dynamic var separatorColor: UIColor? {
get { return separator.backgroundColor }
set {
separator.backgroundColor = newValue
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

// MARK: Shadow related

/// Enable / disable shadow rendering of the container
Expand Down Expand Up @@ -126,10 +160,34 @@ final public class PopupDialogContainerView: UIView {
buttonStackView.spacing = 0
return buttonStackView
}()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

// 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
}()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

// 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
Expand Down
1 change: 1 addition & 0 deletions PopupDialog/Classes/PopupDialogOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import Foundation
import DynamicBlurView
import UIKit

/// The (blurred) overlay view below the popup dialog
final public class PopupDialogOverlayView: UIView {
Expand Down