Skip to content

Commit

Permalink
[2.0.0] Improved Sizing API permitting for intrinsic sizing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkluz committed Aug 7, 2022
1 parent 2c0f5aa commit f052667
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 94 deletions.
31 changes: 26 additions & 5 deletions Example/Sources/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class MainViewController: UIViewController {
button(title: "Emoji + Right Aligned", target: self, action: #selector(presentIndicatorWithRightAlignmentAndEmoji(_:))),
button(title: "No Image + Center Aligned", target: self, action: #selector(presentIndicatorWithCenterAlignment(_:))),
button(title: "No Image + Left Aligned", target: self, action: #selector(presentIndicatorWithLeftAlignment(_:))),
button(title: "No Image + Right Aligned", target: self, action: #selector(presentIndicatorWithRightAlignment(_:)))
button(title: "No Image + Right Aligned", target: self, action: #selector(presentIndicatorWithRightAlignment(_:))),
button(title: "Extended Size", target: self, action: #selector(presentIndicatorWithExtendedSize(_:)))
]
}()

Expand Down Expand Up @@ -89,6 +90,16 @@ public class MainViewController: UIViewController {
present(alignment: .right, attachment: nil)
}

@objc
public func presentIndicatorWithExtendedSize(_ sender: Any) {
present(
alignment: .natural,
maybeTitle: "This is a Long Title",
maybeSubtitle: "And an extended subtitle string",
attachment: .emoji(.init(value: "🌼", alignment: .left))
)
}

@objc
public func presentIndicatorWithLeftAlignment(_ sender: Any) {
present(alignment: .left, attachment: nil)
Expand Down Expand Up @@ -116,8 +127,13 @@ public class MainViewController: UIViewController {
print("appeared: \(controller)")
}

private func present(alignment: NSTextAlignment, attachment: Indicate.Content.Attachment?) {
let title: String = {
private func present(
alignment: NSTextAlignment,
maybeTitle: String? = nil,
maybeSubtitle: String? = nil,
attachment: Indicate.Content.Attachment?
) {
let title: String = maybeTitle ?? {
switch alignment {
case .left:
return "Left"
Expand All @@ -132,7 +148,7 @@ public class MainViewController: UIViewController {
}
}() + " Aligned"

let subtitle: String = {
let subtitle: String = maybeSubtitle ?? {
switch attachment {
case .none:
return "Without Attachment"
Expand All @@ -155,7 +171,12 @@ public class MainViewController: UIViewController {
subtitle: .init(value: subtitle, alignment: alignment),
attachment: attachment)

let configuration = Indicate.Configuration(tap: indicatorTapped, appeared: indicatorAppeared, dismissed: indicatorDismissed)
let configuration = Indicate.Configuration(
tap: indicatorTapped,
appeared: indicatorAppeared,
dismissed: indicatorDismissed,
contentSizingMode: .intrinsic
)

indicatePresentationController = Indicate.PresentationController(content: content, configuration: configuration)
indicatePresentationController?.present(in: view)
Expand Down
Loading

0 comments on commit f052667

Please sign in to comment.