Skip to content

Commit

Permalink
Finish issue alexisakers#128
Browse files Browse the repository at this point in the history
  • Loading branch information
caocmai committed Mar 5, 2021
1 parent 7b35bb9 commit c561e1b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Example/Swift/Bulletin/BulletinDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ enum BulletinDataSource {
static func makeIntroPage() -> FeedbackPageBLTNItem {

let page = FeedbackPageBLTNItem(title: "Welcome to\nPetBoard")

page.titleAlignment = .right
page.descriptionAlignment = .right
page.imageContentMode = .right

page.image = #imageLiteral(resourceName: "RoundedIcon")
page.imageAccessibilityLabel = "😻"
page.appearance = makeLightAppearance()
Expand Down
10 changes: 5 additions & 5 deletions Sources/InterfaceBuilder/BLTNInterfaceBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import UIKit
* Creates a standard title label.
*/

@objc(makeTitleLabelNextToCloseButton:)
open func makeTitleLabel(isNextToCloseButton: Bool) -> BLTNTitleLabelContainer {
@objc(makeTitleLabelNextToCloseButton:titleAlginment:)
open func makeTitleLabel(isNextToCloseButton: Bool, titleAlginment: NSTextAlignment) -> BLTNTitleLabelContainer {

let titleLabel = UILabel()
titleLabel.textAlignment = .center
titleLabel.textAlignment = titleAlginment
titleLabel.textColor = appearance.titleTextColor
titleLabel.accessibilityTraits.insert(.header)
titleLabel.numberOfLines = 2
Expand All @@ -45,10 +45,10 @@ import UIKit
* Creates a standard description label.
*/

@objc open func makeDescriptionLabel() -> UILabel {
@objc open func makeDescriptionLabel(descriptionAlginment: NSTextAlignment) -> UILabel {

let descriptionLabel = UILabel()
descriptionLabel.textAlignment = .center
descriptionLabel.textAlignment = descriptionAlginment
descriptionLabel.textColor = appearance.descriptionTextColor
descriptionLabel.numberOfLines = 0
descriptionLabel.font = appearance.makeDescriptionFont()
Expand Down
14 changes: 10 additions & 4 deletions Sources/Models/BLTNPageItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import UIKit

/// The title of the page.
@objc public let title: String

/// The alignments of the title and description
public var titleAlignment: NSTextAlignment = .center
public var descriptionAlignment: NSTextAlignment = .center
public var imageContentMode: UIView.ContentMode = .scaleAspectFit

/**
* An image to display below the title.
Expand Down Expand Up @@ -179,7 +184,7 @@ import UIKit

// Title
let isNextToCloseButton = isDismissable && requiresCloseButton
let titleView = interfaceBuilder.makeTitleLabel(isNextToCloseButton: isNextToCloseButton)
let titleView = interfaceBuilder.makeTitleLabel(isNextToCloseButton: isNextToCloseButton, titleAlginment: titleAlignment)
titleView.label.text = title

self.titleLabel = titleView
Expand All @@ -189,7 +194,8 @@ import UIKit
// Image View
if let image = self.image {
let imageView = UIImageView(image: image)
imageView.contentMode = .scaleAspectFit
imageView.contentMode = imageContentMode
// imageView.contentMode = .scaleAspectFit
imageView.tintColor = appearance.imageViewTintColor

if let accessibilityLabel = imageAccessibilityLabel {
Expand All @@ -206,13 +212,13 @@ import UIKit

// Description Label
if let attributedDescription = attributedDescriptionText {
let label = interfaceBuilder.makeDescriptionLabel()
let label = interfaceBuilder.makeDescriptionLabel(descriptionAlginment: descriptionAlignment)
label.attributedText = attributedDescription
contentViews.append(label)
self.descriptionLabel = label
insertComplementaryViews(makeViewsUnderDescription)
} else if let description = descriptionText {
let label = interfaceBuilder.makeDescriptionLabel()
let label = interfaceBuilder.makeDescriptionLabel(descriptionAlginment: descriptionAlignment)
label.text = description
contentViews.append(label)
self.descriptionLabel = label
Expand Down

0 comments on commit c561e1b

Please sign in to comment.