Skip to content

Commit

Permalink
chore(ios): rename UIImage getter on Image to uiImage (#137)
Browse files Browse the repository at this point in the history
This is mainly for consisentency with the `uiFont` getter on `Typograph`.

BREAKING CHANGE: The `image` property getter that returns a `UIImage` on the `Image` extension has been renamed `uiImage`.
  • Loading branch information
Westin Newell committed Nov 14, 2019
1 parent 2612e91 commit b524ae5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/existing-project-integration/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension {

```swift
extension Image {
var image: UIImage
var uiImage: UIImage
}
```

Expand Down
30 changes: 15 additions & 15 deletions examples/lorem-ipsum/examples/ios/LoremIpsum/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

diez.attach { [weak self] result in
switch result {
case .success(let designSystem):
Expand All @@ -24,20 +24,20 @@ class ViewController: UIViewController {
}
}
}

private func apply(_ designSystem: DesignSystem) {
guard let view = self.view as? View else {
fatalError("Unexpected view type: \(String(describing: self.view))")
}

view.backgroundColor = designSystem.colors.darkBackground.color
if let mastheadImage = designSystem.images.masthead.image {

if let mastheadImage = designSystem.images.masthead.uiImage {
view.headerView.backgroundColor = UIColor(patternImage: mastheadImage)
}
view.iconView.image = designSystem.images.logo.image

view.iconView.image = designSystem.images.logo.uiImage

view.contentBackgroundView.backgroundColor = designSystem.colors.lightBackground.color
let margin = designSystem.layoutValues.contentMargin
view.contentStackView.layoutMargins = UIEdgeInsets(
Expand All @@ -47,28 +47,28 @@ class ViewController: UIViewController {
right: margin.right
)
view.contentStackView.spacing = designSystem.layoutValues.spacingSmall

view.titleLabel.apply(designSystem.typographs.heading1)
view.titleLabel.text = designSystem.strings.title

view.captionLabel.apply(designSystem.typographs.caption)
view.captionLabel.text = designSystem.strings.caption

view.animationView.load(designSystem.loadingAnimation)
}

init() {
super.init(nibName: nil, bundle: nil)
}

override func loadView() {
view = View()
}

override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) { fatalError("\(#function) not implemented.") }
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension ReportViewController {
private func apply(_ design: HeaderDesign, to view: ReportHeaderView) {
view.regionLabel.apply(design.regionLabel)
view.placeLabel.apply(design.placeLabel)
view.pinIconImageView.image = design.mapPinIcon.image
view.pinIconImageView.image = design.mapPinIcon.uiImage
view.locationImageView.strokeWidth = design.locationImage.strokeWidth
view.locationImageView.strokeGradient = Gradient(design.locationImage.strokeGradient)
view.locationImageWidthAndHeight = design.locationImage.widthAndHeight
Expand All @@ -46,7 +46,7 @@ extension ReportViewController {

private func apply(_ design: TemperatureDesign, to view: HorizontalImageLabelView) {
view.label.apply(design.typograph)
view.imageView.image = design.icon.image
view.imageView.image = design.icon.uiImage
view.spacing = design.iconSpacing
}

Expand All @@ -56,7 +56,7 @@ extension ReportViewController {
view.bottomLabel.apply(design.valueTypograph)
view.verticalSpacing = design.labelSpacing
view.horizontalSpacing = design.iconSpacing
view.imageView.image = design.icon.image
view.imageView.image = design.icon.uiImage
}

private func apply(_ design: ForecastCardDesign, to view: ForecastCardView) {
Expand Down Expand Up @@ -99,7 +99,7 @@ extension ReportViewController {
navigationBar.barTintColor = design.barTintColor.color
view.label.text = design.title
view.label.apply(design.typograph)
view.imageView.image = design.icon.image
view.imageView.image = design.icon.uiImage
view.spacing = design.iconToTitleSpacing
}
}
4 changes: 2 additions & 2 deletions packages/targets/sources/ios/bindings/Image.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
extension Image {
/**
An image of the appropriate scale if it exits.
An `UIImage` of the appropriate scale if it exits.
When in [hot mode](x-source-tag://Diez), calls [image(withScale:)](x-source-tag://Image.imageWithScale)
with `UIScreen.main.scale`.
When not in [hot mode](x-source-tag://Diez), uses `UIImage(named:bundle:compatibleWith:)`.
*/
@objc public var image: UIImage? {
@objc public var uiImage: UIImage? {
if environment.isHot {
guard let hotImage = image(withScale: UIScreen.main.scale) else {
return image(withScale: 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ extension Image: ReflectedCustomStringConvertible {

extension Image {
/**
An image of the appropriate scale if it exits.
An `UIImage` of the appropriate scale if it exits.
When in [hot mode](x-source-tag://Diez), calls [image(withScale:)](x-source-tag://Image.imageWithScale)
with `UIScreen.main.scale`.
When not in [hot mode](x-source-tag://Diez), uses `UIImage(named:bundle:compatibleWith:)`.
*/
@objc public var image: UIImage? {
@objc public var uiImage: UIImage? {
if environment.isHot {
guard let hotImage = image(withScale: UIScreen.main.scale) else {
return image(withScale: 3)
Expand Down

0 comments on commit b524ae5

Please sign in to comment.