Skip to content

Commit

Permalink
Merge pull request #119 from vveltri/feature/hybrid-row-title-subtitl…
Browse files Browse the repository at this point in the history
…e-grayed

Added hybrid row title and subtitle grayed
  • Loading branch information
vveltri-meli authored Jul 13, 2021
2 parents dee150b + e089697 commit 9cc3b4e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Sin publicar
- Fix en `setAdditionalEdgeInsets(with:)` para el Cover Carousel
- Added closed status support to title and subtile on Hybrid Row

# v1.30.0
🚀 1.30.0 🚀
Expand Down
14 changes: 9 additions & 5 deletions Example/Example_BusinessComponents/MockData/RowData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class RowData: NSObject, MLBusinessRowData {
}

func getMainDescription() -> [MLBusinessRowMainDescriptionData]? {
return [RowMainDescriptionData(type: "image", content: "https://i.ibb.co/2KcdLdy/16-px.png", color: "#454545"),
RowMainDescriptionData(type: "text", content: "598m", color: "#454545"),
RowMainDescriptionData(type: "text", content: " · ", color: "#454545"),
RowMainDescriptionData(type: "image", content: "https://i.ibb.co/prSV6dY/estrella-android.png", color: "#454545"),
RowMainDescriptionData(type: "text", content: "4.3 (24)", color: "#454545"),]
return [RowMainDescriptionData(type: "image", content: "https://i.ibb.co/2KcdLdy/16-px.png", color: "#737373"),
RowMainDescriptionData(type: "text", content: "598m", color: "#737373"),
RowMainDescriptionData(type: "text", content: " · ", color: "#737373"),
RowMainDescriptionData(type: "image", content: "https://i.ibb.co/prSV6dY/estrella-android.png", color: "#737373"),
RowMainDescriptionData(type: "text", content: "4.3 (24)", color: "#737373"),]
}

func getMainSecondaryDescription() -> [MLBusinessMultipleDescriptionModel]? {
Expand Down Expand Up @@ -78,6 +78,10 @@ class RowData: NSObject, MLBusinessRowData {
func getLink() -> String? {
return "mercadopago://scanqr"
}

func getMainTitleStatus() -> String? {
return "CLOSED"
}
}

extension RowData {
Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://github.com/CocoaPods/Specs.git'
source 'https://cdn.cocoapods.org'

platform :ios, '10.0'
use_frameworks!
Expand Down
1 change: 1 addition & 0 deletions Source/Components/Row/MLBusinessRowData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Foundation
@objc func getRightLabelStatus() -> String?
@objc func getRightBottomInfo() -> MLBusinessRowRightBottomInfoData?
@objc func getLink() -> String?
@objc optional func getMainTitleStatus() -> String?
}

@objc public protocol MLBusinessRowMainDescriptionData: NSObjectProtocol {
Expand Down
22 changes: 17 additions & 5 deletions Source/Components/Row/MLBusinessRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public class MLBusinessRowView: UIView {
rightBottomInfo.translatesAutoresizingMaskIntoConstraints = false
return rightBottomInfo
}()

private let blockedColor = MLStyleSheetManager.styleSheet.blackColor.withAlphaComponent(0.4)
private let closedBlackColor = MLStyleSheetManager.styleSheet.blackColor.withAlphaComponent(0.4)
private let closedGreyColor = MLStyleSheetManager.styleSheet.greyColor.withAlphaComponent(0.4)
private let blackColor = MLStyleSheetManager.styleSheet.blackColor
private let greyColor = MLStyleSheetManager.styleSheet.greyColor

var imageProvider: MLBusinessImageProvider {
didSet {
Expand Down Expand Up @@ -299,6 +305,7 @@ public class MLBusinessRowView: UIView {
createMainDescription(with: content.getMainDescription())
createMainSecondaryDescription(with: content.getMainSecondaryDescription?())
createStatusDescription(with: content.getStatusDescription?())
setMainTitleStatus(with: content.getMainTitleStatus?())
}

private func createRightSection(with content: MLBusinessRowData) {
Expand Down Expand Up @@ -362,6 +369,16 @@ public class MLBusinessRowView: UIView {
mainStackView.addArrangedSubview(statusDescriptionContainerView)
}

private func setMainTitleStatus(with status: String?) {
guard let status = status, status.lowercased() == "closed" else {
mainTitleLabel.textColor = blackColor
mainSubtitleLabel.textColor = blackColor
return
}
mainTitleLabel.textColor = closedBlackColor
mainSubtitleLabel.textColor = closedBlackColor
}

private func createRightTopLabel(with text: String?) {
guard let rightTopLabelText = text else { return }
rightTopLabel.text = rightTopLabelText
Expand Down Expand Up @@ -419,21 +436,16 @@ public class MLBusinessRowView: UIView {

private func setRightLabelStatus(with rightLabelStatus: String?) {
if let rightLabelStatus = rightLabelStatus, rightLabelStatus.lowercased() == "blocked" {
let blockedColor = MLStyleSheetManager.styleSheet.blackColor.withAlphaComponent(0.4)
rightPrimaryLabel.textColor = blockedColor
rightSecondaryLabel.textColor = blockedColor
rightBottomInfoPill.alpha = 1
} else if let rightLabelStatus = rightLabelStatus, rightLabelStatus.lowercased() == "closed" {
let closedBlackColor = MLStyleSheetManager.styleSheet.blackColor.withAlphaComponent(0.4)
let closedGreyColor = MLStyleSheetManager.styleSheet.greyColor.withAlphaComponent(0.4)
rightTopLabel.textColor = closedBlackColor
rightPrimaryLabel.textColor = closedBlackColor
rightSecondaryLabel.textColor = closedBlackColor
rightMiddleLabel.textColor = closedGreyColor
rightBottomInfoPill.alpha = 0.4
} else {
let blackColor = MLStyleSheetManager.styleSheet.blackColor
let greyColor = MLStyleSheetManager.styleSheet.greyColor
rightTopLabel.textColor = blackColor
rightPrimaryLabel.textColor = blackColor
rightSecondaryLabel.textColor = blackColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MLBusinessCoverCarouselItemContentModelMapper: MLBusinessCoverCarouselItem
leftImageAccessory: model.leftImageAccessory,
leftImageStatus: model.leftImageStatus,
mainTitle: model.mainTitle,
mainTitleStatus: model.mainTitleStatus,
mainSubtitle: model.mainSubtitle,
mainDescription: model.mainDescription,
mainSecondaryDescription: model.mainSecondaryDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public struct MLBusinessCoverCarouselItemContentModel: Codable {
public let leftImageAccessory: String?
public let leftImageStatus: String?
public let mainTitle: String
public let mainTitleStatus: String?
public let mainSubtitle: String?
public let mainDescription: [MLBusinessRowMainDescription]?
public let mainSecondaryDescription: [MLBusinessMultipleDescriptionModel]?
Expand All @@ -61,6 +62,7 @@ public struct MLBusinessCoverCarouselItemContentModel: Codable {
leftImageAccessory: String?,
leftImageStatus: String? = nil,
mainTitle: String,
mainTitleStatus: String? = nil,
mainSubtitle: String?,
mainDescription: [MLBusinessRowMainDescription]?,
mainSecondaryDescription: [MLBusinessMultipleDescriptionModel]?,
Expand All @@ -76,6 +78,7 @@ public struct MLBusinessCoverCarouselItemContentModel: Codable {
self.leftImageAccessory = leftImageAccessory
self.leftImageStatus = leftImageStatus
self.mainTitle = mainTitle
self.mainTitleStatus = mainTitleStatus
self.mainSubtitle = mainSubtitle
self.mainDescription = mainDescription
self.mainSecondaryDescription = mainSecondaryDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class MLBusinessMultipleRowItemModel: NSObject, Codable {
private let leftImageAccessory: String?
private let leftImageStatus: String?
private let mainTitle: String
private let mainTitleStatus: String?
private let mainSubtitle: String?
private let mainDescription: [MLBusinessRowMainDescription]?
private let mainSecondaryDescription: [MLBusinessMultipleDescriptionModel]?
Expand All @@ -63,11 +64,12 @@ public class MLBusinessMultipleRowItemModel: NSObject, Codable {
private let link: String?
private let tracking: MLBusinessItemModelTracking?

public init(leftImage: String?, leftImageAccessory: String?, leftImageStatus: String? = nil, mainTitle: String, mainSubtitle: String?, mainDescription: [MLBusinessRowMainDescription]?, mainSecondaryDescription: [MLBusinessMultipleDescriptionModel]? = nil, statusDescription: [MLBusinessMultipleDescriptionModel]? = nil, rightPrimaryLabel: String?, rightSecondaryLabel: String?, rightMiddleLabel: String?, rightTopLabel: String?, rightLabelStatus: String?, rightBottomInfo: MLBusinessRowRightBottomInfo?, link: String?, tracking: MLBusinessItemModelTracking?) {
public init(leftImage: String?, leftImageAccessory: String?, leftImageStatus: String? = nil, mainTitle: String, mainTitleStatus: String? = nil, mainSubtitle: String?, mainDescription: [MLBusinessRowMainDescription]?, mainSecondaryDescription: [MLBusinessMultipleDescriptionModel]? = nil, statusDescription: [MLBusinessMultipleDescriptionModel]? = nil, rightPrimaryLabel: String?, rightSecondaryLabel: String?, rightMiddleLabel: String?, rightTopLabel: String?, rightLabelStatus: String?, rightBottomInfo: MLBusinessRowRightBottomInfo?, link: String?, tracking: MLBusinessItemModelTracking?) {
self.leftImage = leftImage
self.leftImageAccessory = leftImageAccessory
self.leftImageStatus = leftImageStatus
self.mainTitle = mainTitle
self.mainTitleStatus = mainTitleStatus
self.mainSubtitle = mainSubtitle
self.mainDescription = mainDescription
self.mainSecondaryDescription = mainSecondaryDescription
Expand Down Expand Up @@ -100,6 +102,10 @@ extension MLBusinessMultipleRowItemModel: MLBusinessRowData {
return mainTitle
}

public func getMainTitleStatus() -> String? {
return mainTitleStatus
}

public func getMainSubtitle() -> String? {
return mainSubtitle
}
Expand Down

0 comments on commit 9cc3b4e

Please sign in to comment.