diff --git a/Example/Sources/RootViewController.swift b/Example/Sources/RootViewController.swift index 6a7978f..102dd23 100644 --- a/Example/Sources/RootViewController.swift +++ b/Example/Sources/RootViewController.swift @@ -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(_:))) ] }() @@ -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) @@ -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" @@ -132,7 +148,7 @@ public class MainViewController: UIViewController { } }() + " Aligned" - let subtitle: String = { + let subtitle: String = maybeSubtitle ?? { switch attachment { case .none: return "Without Attachment" @@ -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) diff --git a/Indicate/Sources/Configuration.swift b/Indicate/Sources/Configuration.swift index 9644fa8..bc15e6b 100644 --- a/Indicate/Sources/Configuration.swift +++ b/Indicate/Sources/Configuration.swift @@ -15,6 +15,11 @@ extension Indicate { /// Configuration structure controlling various aspects of the `Indicate` indicator. public struct Configuration { + public enum ContentSizingMode { + case intrinsic + case custom(CGSize) + } + public typealias Action = (PresentationController) -> Void // MARK: Configuration (Public Properties) @@ -32,26 +37,26 @@ extension Indicate { public let duration: TimeInterval /// Size of the indicator (excluding shadows). - public let size: CGSize + public let contentSizingMode: ContentSizingMode /// Padding to apply around the content area inside the indicator. public let contentPadding: UIEdgeInsets /// Spacing between various items inside the content area of the indicator (e.g. image view and text area). public let horizontalItemSpacing: CGFloat - + /// Indicator's title color public let titleColor: UIColor - + /// Indicator's subtitle color public let subtitleColor: UIColor - + /// Indicator's background color public let backgroundColor: UIColor - + /// Indicator's title font public let titleFont: UIFont - + /// Indicator's subtitle font public let subtitleFont: UIFont @@ -67,15 +72,15 @@ extension Indicate { private static let defaultContentPadding: UIEdgeInsets = UIEdgeInsets(top: 8.0, left: 16.0, bottom: 8.0, right: 16.0) private static let defaultHorizontalItemSpacing: CGFloat = 8.0 - + private static let defaultTitleColor: UIColor = UIColor(named: "TitleColor", in: .indicate, compatibleWith: nil) ?? UIColor.black - + private static let defaultSubtitleColor: UIColor = UIColor(named: "SubtitleColor", in: .indicate, compatibleWith: nil) ?? UIColor.darkGray - + private static let defaultBackgroundColor: UIColor = UIColor(named: "BackgroundColor", in: .indicate, compatibleWith: nil) ?? UIColor.white - + private static let defaultTitleFont: UIFont = UIFont.boldSystemFont(ofSize: 13.0) - + private static let defaultSubtitleFont: UIFont = UIFont.boldSystemFont(ofSize: 13.0) // MARK: Configuration (Public Methods) @@ -87,7 +92,7 @@ extension Indicate { /// - appeared: Handler invoked whenever the indicator appears on-screen. /// - dismissed: Handler invoked whenever the indicator disappears off-screen. /// - duration: Duration to show the indicator for before automatically dismissing it. *NOTE:* Interaction with the indicator resets the timer. - /// - size: Size of the indicator (excluding shadows). + /// - contentSizingMode: Size of the indicator (excluding shadows). /// - contentPadding: Padding to apply around the content area inside the indicator. /// - horizontalItemSpacing: Spacing between various items inside the content area of the indicator (e.g. image view and text area). /// - titleColor: Indicator's title color @@ -95,13 +100,26 @@ extension Indicate { /// - backgroundColor: Indicator's background color /// - titleFont: Indicator's title font /// - subtitleFont: Indicator's subtitle font - public init(tap: Action? = nil, appeared: Action? = nil, dismissed: Action? = nil, duration: TimeInterval? = nil, size: CGSize? = nil, contentPadding: UIEdgeInsets? = nil, horizontalItemSpacing: CGFloat? = nil, titleColor: UIColor? = nil, subtitleColor: UIColor? = nil, backgroundColor: UIColor? = nil, titleFont: UIFont? = nil, subtitleFont: UIFont? = nil) { + public init( + tap: Action? = nil, + appeared: Action? = nil, + dismissed: Action? = nil, + duration: TimeInterval? = nil, + contentSizingMode: ContentSizingMode? = nil, + contentPadding: UIEdgeInsets? = nil, + horizontalItemSpacing: CGFloat? = nil, + titleColor: UIColor? = nil, + subtitleColor: UIColor? = nil, + backgroundColor: UIColor? = nil, + titleFont: UIFont? = nil, + subtitleFont: UIFont? = nil + ) { self.tap = tap self.appeared = appeared self.dismissed = dismissed self.duration = duration ?? Self.defaultDuration self.contentPadding = contentPadding ?? Self.defaultContentPadding - self.size = size ?? Self.defaultSize + self.contentSizingMode = contentSizingMode ?? .custom(Self.defaultSize) self.horizontalItemSpacing = horizontalItemSpacing ?? Self.defaultHorizontalItemSpacing self.titleColor = titleColor ?? Self.defaultTitleColor self.subtitleColor = subtitleColor ?? Self.defaultSubtitleColor @@ -118,61 +136,221 @@ extension Indicate.Configuration { /// Create a copy of the current configuration structure with a new `tap` handler. public func with(tap: Action?) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `appeared` handler. + /// Create a copy of the current configuration structure with a new `appeared` handler public func with(appeared: Action?) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `dismissed` handler. + + /// Create a copy of the current configuration structure with a new `dismissed` handler public func with(dismissed: Action?) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `duration` value. + + /// Create a copy of the current configuration structure with a new `duration` value public func with(duration: TimeInterval) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `size` value. - public func with(size: CGSize) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + + /// Create a copy of the current configuration structure with a new `contentSizingMode` value + public func with(contentSizingMode: ContentSizingMode) -> Self { + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `contentPadding` value. + + /// Create a copy of the current configuration structure with a new `contentPadding` value public func with(contentPadding: UIEdgeInsets) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - /// Create a copy of the current configuration structure with a new `horizontalItemSpacing` value. + /// Create a copy of the current configuration structure with a new `horizontalItemSpacing` value public func with(horizontalItemSpacing: CGFloat) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - - /// Create a copy of the current configuration structure with a new `titleColor` value. + + /// Create a copy of the current configuration structure with a new `titleColor` value public func with(titleColor: UIColor) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - - /// Create a copy of the current configuration structure with a new `subtitleColor` value. + + /// Create a copy of the current configuration structure with a new `subtitleColor` value public func with(subtitleColor: UIColor) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - - /// Create a copy of the current configuration structure with a new `backgroundColor` value. + + /// Create a copy of the current configuration structure with a new `backgroundColor` value public func with(backgroundColor: UIColor) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - - /// Create a copy of the current configuration structure with a new `titleFont` value. + + /// Create a copy of the current configuration structure with a new `titleFont` value public func with(titleFont: UIFont) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } - - /// Create a copy of the current configuration structure with a new `subtitleFont` value. + + /// Create a copy of the current configuration structure with a new `subtitleFont` value public func with(subtitleFont: UIFont) -> Self { - return Indicate.Configuration(tap: tap, appeared: appeared, dismissed: dismissed, duration: duration, size: size, contentPadding: contentPadding, horizontalItemSpacing: horizontalItemSpacing, titleColor: titleColor, subtitleColor: subtitleColor, backgroundColor: backgroundColor, titleFont: titleFont, subtitleFont: subtitleFont) + return Indicate.Configuration( + tap: tap, + appeared: appeared, + dismissed: dismissed, + duration: duration, + contentSizingMode: contentSizingMode, + contentPadding: contentPadding, + horizontalItemSpacing: horizontalItemSpacing, + titleColor: titleColor, + subtitleColor: subtitleColor, + backgroundColor: backgroundColor, + titleFont: titleFont, + subtitleFont: subtitleFont + ) } } diff --git a/Indicate/Sources/PresentationController.swift b/Indicate/Sources/PresentationController.swift index bb65488..1d015e0 100644 --- a/Indicate/Sources/PresentationController.swift +++ b/Indicate/Sources/PresentationController.swift @@ -63,15 +63,19 @@ extension Indicate { public init(content inContent: Content, configuration inConfiguration: Configuration = .default) { content = inContent configuration = inConfiguration - indicator = View(viewModel: ViewModel(content: content, - size: configuration.size, - contentPadding: configuration.contentPadding, - horizontalItemSpacing: configuration.horizontalItemSpacing, - titleColor: configuration.titleColor, - subtitileColor: configuration.subtitleColor, - backgroundColor: configuration.backgroundColor, - titleFont: configuration.titleFont, - subtitleFont: configuration.subtitleFont)) + indicator = View( + viewModel: ViewModel( + content: content, + contentSizingMode: configuration.contentSizingMode, + contentPadding: configuration.contentPadding, + horizontalItemSpacing: configuration.horizontalItemSpacing, + titleColor: configuration.titleColor, + subtitileColor: configuration.subtitleColor, + backgroundColor: configuration.backgroundColor, + titleFont: configuration.titleFont, + subtitleFont: configuration.subtitleFont + ) + ) super.init() diff --git a/Indicate/Sources/View.swift b/Indicate/Sources/View.swift index 7436644..ce4333f 100644 --- a/Indicate/Sources/View.swift +++ b/Indicate/Sources/View.swift @@ -25,10 +25,12 @@ extension Indicate { internal override func layoutSubviews() { super.layoutSubviews() - contentView.frame = CGRect(x: viewModel.contentPadding.left, - y: viewModel.contentPadding.top, - width: bounds.width - viewModel.contentPadding.left - viewModel.contentPadding.right, - height: bounds.height - viewModel.contentPadding.top - viewModel.contentPadding.bottom) + contentView.frame = CGRect( + x: viewModel.contentPadding.left, + y: viewModel.contentPadding.top, + width: bounds.width - viewModel.contentPadding.left - viewModel.contentPadding.right, + height: bounds.height - viewModel.contentPadding.top - viewModel.contentPadding.bottom + ) imageView.frame = { if viewModel.isImageViewHidden { @@ -36,16 +38,20 @@ extension Indicate { } if viewModel.isImageViewLeftAligned { - return CGRect(x: 0.0, - y: 0.0, - width: contentView.bounds.height, - height: contentView.bounds.height) + return CGRect( + x: 0.0, + y: 0.0, + width: contentView.bounds.height, + height: contentView.bounds.height + ) } - return CGRect(x: contentView.bounds.width - contentView.bounds.height, - y: 0.0, - width: contentView.bounds.height, - height: contentView.bounds.height) + return CGRect( + x: contentView.bounds.width - contentView.bounds.height, + y: 0.0, + width: contentView.bounds.height, + height: contentView.bounds.height + ) }() emojiLabel.frame = { @@ -54,16 +60,20 @@ extension Indicate { } if viewModel.isEmojiLabelLeftAligned { - return CGRect(x: 0.0, - y: 0.0, - width: contentView.bounds.height, - height: contentView.bounds.height) + return CGRect( + x: 0.0, + y: 0.0, + width: contentView.bounds.height, + height: contentView.bounds.height + ) } - return CGRect(x: contentView.bounds.width - contentView.bounds.height, - y: 0.0, - width: contentView.bounds.height, - height: contentView.bounds.height) + return CGRect( + x: contentView.bounds.width - contentView.bounds.height, + y: 0.0, + width: contentView.bounds.height, + height: contentView.bounds.height + ) }() titleLabel.frame = { @@ -73,28 +83,47 @@ extension Indicate { if viewModel.isImageViewLeftAligned || viewModel.isEmojiLabelLeftAligned { let x = max(imageView.bounds.maxX, emojiLabel.bounds.maxX) + viewModel.horizontalItemSpacing - return CGRect(x: x, - y: 0.0, - width: contentView.bounds.width - x, - height: contentView.bounds.height) + return CGRect( + x: x, + y: 0.0, + width: contentView.bounds.width - x, + height: contentView.bounds.height + ) } - return CGRect(x: 0.0, - y: 0.0, - width: contentView.bounds.width - viewModel.horizontalItemSpacing - max(imageView.bounds.width, emojiLabel.bounds.width), - height: contentView.bounds.height) + return CGRect( + x: 0.0, + y: 0.0, + width: contentView.bounds.width - viewModel.horizontalItemSpacing - max(imageView.bounds.width, emojiLabel.bounds.width), + height: contentView.bounds.height + ) }() refreshAppearance() } internal override func sizeThatFits(_ size: CGSize) -> CGSize { - let titleSize = titleLabel.sizeThatFits(size) - let attachmentWidth = viewModel.hasAttachment ? viewModel.size.height - (viewModel.contentPadding.top + viewModel.contentPadding.bottom) : 0.0 - let size = CGSize(width: min(viewModel.size.width, viewModel.contentPadding.left + attachmentWidth + viewModel.horizontalItemSpacing + titleSize.width + viewModel.contentPadding.right), - height: viewModel.size.height) + switch viewModel.contentSizingMode { + case .custom(let size): + let titleSize = titleLabel.sizeThatFits(size) + let attachmentWidth = viewModel.hasAttachment ? size.height - (viewModel.contentPadding.top + viewModel.contentPadding.bottom) : 0.0 + let size = CGSize( + width: ceil(min(size.width, viewModel.contentPadding.left + attachmentWidth + viewModel.horizontalItemSpacing + titleSize.width + viewModel.contentPadding.right)), + height: ceil(size.height) + ) + + return size + case .intrinsic: + let titleSize = titleLabel.sizeThatFits(size) + let attachmentWidth = viewModel.hasAttachment ? titleSize.height : 0.0 + let size = CGSize( + width: ceil(viewModel.contentPadding.left + attachmentWidth + viewModel.horizontalItemSpacing + titleSize.width + viewModel.contentPadding.right) + 1.0, // NOTE: It is necessary to add one point in width as attributed string sometimes produce an insufficiently large `sizeThatFits(_:)` result which leads to undesired linebreaks. + height: ceil(titleSize.height + viewModel.contentPadding.top + viewModel.contentPadding.bottom) + ) + + return size + } - return size } internal override func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize { diff --git a/Indicate/Sources/ViewModel.swift b/Indicate/Sources/ViewModel.swift index ec86ddb..cc97dad 100644 --- a/Indicate/Sources/ViewModel.swift +++ b/Indicate/Sources/ViewModel.swift @@ -104,7 +104,7 @@ extension Indicate { return attachment.alignment == .left || (attachment.alignment == .natural && UIApplication.shared.userInterfaceLayoutDirection == .leftToRight) } - internal let size: CGSize + internal let contentSizingMode: Configuration.ContentSizingMode internal let contentPadding: UIEdgeInsets @@ -126,9 +126,19 @@ extension Indicate { // MARK: ViewModel (internal Methods) - internal init(content: Content, size: CGSize, contentPadding: UIEdgeInsets, horizontalItemSpacing: CGFloat, titleColor: UIColor, subtitileColor: UIColor, backgroundColor: UIColor, titleFont: UIFont, subtitleFont: UIFont) { + internal init( + content: Content, + contentSizingMode: Configuration.ContentSizingMode, + contentPadding: UIEdgeInsets, + horizontalItemSpacing: CGFloat, + titleColor: UIColor, + subtitileColor: UIColor, + backgroundColor: UIColor, + titleFont: UIFont, + subtitleFont: UIFont + ) { self.content = content - self.size = size + self.contentSizingMode = contentSizingMode self.contentPadding = contentPadding self.horizontalItemSpacing = horizontalItemSpacing self.titleColor = titleColor diff --git a/IndicateKit.podspec b/IndicateKit.podspec index 5c8121f..73a1e9e 100644 --- a/IndicateKit.podspec +++ b/IndicateKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "IndicateKit" spec.module_name = "Indicate" - spec.version = "1.0.6" + spec.version = "2.0.0" spec.license = { type: "MIT" } spec.homepage = "https://github.com/pkluz/indicate" spec.authors = { "Philip Kluz": "philip.kluz@gmail.com" }