Skip to content

Commit c561e1b

Browse files
committed
Finish issue alexaubry#128
1 parent 7b35bb9 commit c561e1b

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Example/Swift/Bulletin/BulletinDataSource.swift

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ enum BulletinDataSource {
3030
static func makeIntroPage() -> FeedbackPageBLTNItem {
3131

3232
let page = FeedbackPageBLTNItem(title: "Welcome to\nPetBoard")
33+
34+
page.titleAlignment = .right
35+
page.descriptionAlignment = .right
36+
page.imageContentMode = .right
37+
3338
page.image = #imageLiteral(resourceName: "RoundedIcon")
3439
page.imageAccessibilityLabel = "😻"
3540
page.appearance = makeLightAppearance()

Sources/InterfaceBuilder/BLTNInterfaceBuilder.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import UIKit
2424
* Creates a standard title label.
2525
*/
2626

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

3030
let titleLabel = UILabel()
31-
titleLabel.textAlignment = .center
31+
titleLabel.textAlignment = titleAlginment
3232
titleLabel.textColor = appearance.titleTextColor
3333
titleLabel.accessibilityTraits.insert(.header)
3434
titleLabel.numberOfLines = 2
@@ -45,10 +45,10 @@ import UIKit
4545
* Creates a standard description label.
4646
*/
4747

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

5050
let descriptionLabel = UILabel()
51-
descriptionLabel.textAlignment = .center
51+
descriptionLabel.textAlignment = descriptionAlginment
5252
descriptionLabel.textColor = appearance.descriptionTextColor
5353
descriptionLabel.numberOfLines = 0
5454
descriptionLabel.font = appearance.makeDescriptionFont()

Sources/Models/BLTNPageItem.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ import UIKit
2626

2727
/// The title of the page.
2828
@objc public let title: String
29+
30+
/// The alignments of the title and description
31+
public var titleAlignment: NSTextAlignment = .center
32+
public var descriptionAlignment: NSTextAlignment = .center
33+
public var imageContentMode: UIView.ContentMode = .scaleAspectFit
2934

3035
/**
3136
* An image to display below the title.
@@ -179,7 +184,7 @@ import UIKit
179184

180185
// Title
181186
let isNextToCloseButton = isDismissable && requiresCloseButton
182-
let titleView = interfaceBuilder.makeTitleLabel(isNextToCloseButton: isNextToCloseButton)
187+
let titleView = interfaceBuilder.makeTitleLabel(isNextToCloseButton: isNextToCloseButton, titleAlginment: titleAlignment)
183188
titleView.label.text = title
184189

185190
self.titleLabel = titleView
@@ -189,7 +194,8 @@ import UIKit
189194
// Image View
190195
if let image = self.image {
191196
let imageView = UIImageView(image: image)
192-
imageView.contentMode = .scaleAspectFit
197+
imageView.contentMode = imageContentMode
198+
// imageView.contentMode = .scaleAspectFit
193199
imageView.tintColor = appearance.imageViewTintColor
194200

195201
if let accessibilityLabel = imageAccessibilityLabel {
@@ -206,13 +212,13 @@ import UIKit
206212

207213
// Description Label
208214
if let attributedDescription = attributedDescriptionText {
209-
let label = interfaceBuilder.makeDescriptionLabel()
215+
let label = interfaceBuilder.makeDescriptionLabel(descriptionAlginment: descriptionAlignment)
210216
label.attributedText = attributedDescription
211217
contentViews.append(label)
212218
self.descriptionLabel = label
213219
insertComplementaryViews(makeViewsUnderDescription)
214220
} else if let description = descriptionText {
215-
let label = interfaceBuilder.makeDescriptionLabel()
221+
let label = interfaceBuilder.makeDescriptionLabel(descriptionAlginment: descriptionAlignment)
216222
label.text = description
217223
contentViews.append(label)
218224
self.descriptionLabel = label

0 commit comments

Comments
 (0)