Skip to content

Commit

Permalink
Tint icon Imageview
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanegon committed Sep 16, 2021
1 parent 7310824 commit b4a69af
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
10 changes: 10 additions & 0 deletions Mistica/Source/Components/EmptyState/EmptyState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ public extension EmptyState {
}
}

var iconTintColor: UIColor {

get {
emptyStateContentBase.iconTintColor
}
set {
emptyStateContentBase.iconTintColor = newValue
}
}

var primaryButton: Button {
emptyStateContentBase.emptyStateButtons.primaryButton
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import UIKit

public struct EmptyStateConfiguration {
static let empty = EmptyStateConfiguration(type: .default(.icon(UIImage(color: .success))), title: "Basic configuration", description: "This is a basic configuration for the empty state", actions: nil)
static let empty = EmptyStateConfiguration(type: .default(.icon(UIImage())), title: "Basic configuration", description: "This is a basic configuration for the empty state", actions: nil)

public enum EmptyStateActions {
case primary(EmptyStateButton)
Expand Down Expand Up @@ -43,7 +43,7 @@ public struct EmptyStateConfiguration {
let description: String?
let actions: EmptyStateActions?

public init(type: EmptyStateType = .default(.icon(UIImage())), title: String, description: String?, actions: EmptyStateActions? = nil) {
public init(type: EmptyStateType, title: String, description: String?, actions: EmptyStateActions? = nil) {
self.type = type
self.title = title
self.description = description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ extension EmptyStateContentBase {
}
}

var iconTintColor: UIColor {

get {
iconImage.tintColor
}
set {
iconImage.tintColor = newValue
}
}

func configure(withConfiguration configuration: EmptyStateConfiguration) {
configureMessagesContent(withConfiguration: configuration)
// Asset is mandatory
Expand Down
8 changes: 4 additions & 4 deletions Mistica/Tests/MisticaTests/UI/EmptyStatesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class EmptyStatesTests: XCTestCase {
func testSecondaryAndLinkButtonsOnlyAsACard() {
MisticaConfig.brandStyle = .movistar

let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.smallImage)), actions: .secondaryAndLink(secondary: AnyValues.secondary, link: AnyValues.link))
let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.iconImage)), actions: .secondaryAndLink(secondary: AnyValues.secondary, link: AnyValues.link))

assertSnapshot(matching: view, as: .image)
}
Expand All @@ -136,15 +136,15 @@ final class EmptyStatesTests: XCTestCase {
func testEmptyButtonOnlyAsACard() {
MisticaConfig.brandStyle = .movistar

let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.smallImage)), actions: .empty)

let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.iconImage)), actions: .empty)
assertSnapshot(matching: view, as: .image)
}

func testLinkButtonOnlyAsACard() {
MisticaConfig.brandStyle = .movistar

let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.smallImage)), actions: .link(AnyValues.link))
let view = makeEmptyStateWithContentAndButtons(type: .card(.icon(AnyValues.iconImage)), actions: .link(AnyValues.link))

assertSnapshot(matching: view, as: .image)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ extension UICatalogEmptyStateViewController: UITableViewDataSource, UITableViewD
let asset = EmptyStateConfiguration.EmptyStateCardAsset.icon(image)
configuration = EmptyStateConfiguration(type: .card(asset), title: emptyStateTitle, description: emptyStateMessage, actions: actions)
} else {
let imageDefault = UIImage(color: .success)
let imageDefault = UIImage(color: .success)
let asset: EmptyStateConfiguration.EmptyStateDefaultAsset
switch assetCell.segmentedControl.selectedSegmentIndex {
case 0:
Expand All @@ -249,6 +249,7 @@ extension UICatalogEmptyStateViewController: UITableViewDataSource, UITableViewD
}
let vc = EmptyStateViewSampleViewController()
vc.emptyState.contentConfiguration = configuration
vc.emptyState.iconTintColor = .systemPink

show(vc, sender: self)
}
Expand Down

0 comments on commit b4a69af

Please sign in to comment.