Skip to content

Commit

Permalink
Merge pull request #47 from RakuyoKit/feature/epoxy
Browse files Browse the repository at this point in the history
Feature/epoxy
  • Loading branch information
rakuyoMo authored Jun 18, 2024
2 parents ab2931d + 495a371 commit 1b1d2f5
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 15 deletions.
22 changes: 13 additions & 9 deletions Sources/Epoxy/CollectionView/Spacer/SpacerRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ import RAKConfig
// MARK: - SpacerRow

/// View used for filling spacing in CollectionView
public final class SpacerRow: BaseStyledEpoxyView<SpacerRow.Style> {
public final class SpacerRow: BaseStyledEpoxyView<SpacerRow.Style> { }

// MARK: Life cycle

extension SpacerRow {
override public var intrinsicContentSize: CGSize {
.init(width: UIView.noIntrinsicMetric, height: style.height)
}
}

// MARK: Config

extension SpacerRow {
override public func config() {
super.config()

Expand Down Expand Up @@ -54,14 +66,6 @@ extension SpacerRow: ContentConfigurableView { }

extension SpacerRow: BehaviorsConfigurableView { }

// MARK: - Life cycle

extension SpacerRow {
override public var intrinsicContentSize: CGSize {
.init(width: UIView.noIntrinsicMetric, height: style.height)
}
}

// MARK: - SpacerRow.Style + ExpressibleByFloatLiteral

extension SpacerRow.Style: ExpressibleByFloatLiteral {
Expand Down
8 changes: 8 additions & 0 deletions Sources/Epoxy/Row/BaseStyledEpoxyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@ open class BaseStyledEpoxyView<Style: Hashable>: RAKBase.BaseView, StyledView {
public required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Config

override open func config() {
super.config()

translatesAutoresizingMaskIntoConstraints = false
}
}
#endif
4 changes: 2 additions & 2 deletions Sources/Epoxy/Row/ButtonRow/ButtonRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public final class ButtonRow: UIButton {
private lazy var didTriggerMenuAction: ButtonClosure? = nil
}

// MARK: - Life cycle
// MARK: Life cycle

extension ButtonRow {
override public var intrinsicContentSize: CGSize {
let superSize = super.intrinsicContentSize
lazy var superSize = super.intrinsicContentSize
guard let size else { return superSize }

return .init(
Expand Down
74 changes: 74 additions & 0 deletions Sources/Epoxy/Row/EmptyRow.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// EmptyRow.swift
// RakuyoKit
//
// Created by Rakuyo on 2024/6/18.
// Copyright © 2024 RakuyoKit. All rights reserved.
//

#if !os(watchOS) && !os(tvOS) && !os(visionOS)
import UIKit

import EpoxyCore
import RAKBase
import RAKCore

// MARK: - EmptyRow

/// Blank View
///
/// It is not recommended that you inherit from this class
public final class EmptyRow: BaseStyledEpoxyView<EmptyRow.Style> { }

// MARK: Life cycle

extension EmptyRow {
override public var intrinsicContentSize: CGSize {
lazy var superSize = super.intrinsicContentSize
guard let size = style.size else { return superSize }

return .init(
width: size.width ?? superSize.width,
height: size.height ?? superSize.height
)
}
}

// MARK: Config

extension EmptyRow {
override public func config() {
super.config()

backgroundColor = style.backgroundColor

layer.cornerRadius = style.cornerRadius
layer.masksToBounds = style.masksToBounds
layer.borderWidth = style.borderWidth
layer.borderColor = style.borderColor?.cgColor
}
}

// MARK: StyledView

extension EmptyRow {
public struct Style: Hashable {
public let size: OptionalCGSize?
public let backgroundColor: UIColor?

public let cornerRadius: CGFloat
public let masksToBounds: Bool

public let borderWidth: CGFloat
public let borderColor: UIColor?
}
}

// MARK: ContentConfigurableView

extension EmptyRow: ContentConfigurableView { }

// MARK: BehaviorsConfigurableView

extension EmptyRow: BehaviorsConfigurableView { }
#endif
4 changes: 2 additions & 2 deletions Sources/Epoxy/Row/ImageRow/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public final class ImageRow: UIImageView {
private lazy var size: OptionalCGSize? = nil
}

// MARK: - Life cycle
// MARK: Life cycle

extension ImageRow {
override public var intrinsicContentSize: CGSize {
let superSize = super.intrinsicContentSize
lazy var superSize = super.intrinsicContentSize
guard let size else { return superSize }

return .init(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Epoxy/Row/TextRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public final class TextRow: UILabel {
private lazy var size: OptionalCGSize? = nil
}

// MARK: - Life cycle
// MARK: Life cycle

extension TextRow {
override public var intrinsicContentSize: CGSize {
let superSize = super.intrinsicContentSize
lazy var superSize = super.intrinsicContentSize
guard let size else { return superSize }

return .init(
Expand Down

0 comments on commit 1b1d2f5

Please sign in to comment.