Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1.3.4 #28

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/Core/Utilities/OptionalSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public struct OptionalSize {
self.width = width
self.height = height
}

public init(size: Float?) {
self.init(width: size, height: size)
}

public init(_ size: Float?) {
self.init(size: size)
}
}

// MARK: - Logic
Expand Down
18 changes: 18 additions & 0 deletions Sources/Epoxy/CollectionView/Tools/EpoxyModeled+Padding.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// EpoxyModeled+Padding.swift
// RakuyoKit
//
// Created by Rakuyo on 2024/5/22.
// Copyright © 2024 RakuyoKit. All rights reserved.
//

import UIKit

import EpoxyCore
import EpoxyLayoutGroups

extension EpoxyModeled where Self: PaddingProviding {
public func padding(_ value: SectionEdgeInsets) -> Self {
padding(value.edgeInsets)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import CoreGraphics.CGFunction
public struct ListSpacing {
/// Default Spacing: 0
public static let `default`: Self = 0

/// Normal Spacing: 10
public static let normal: Self = 10

/// Spacing
public let spacing: CGFloat

/// Set Custom Spacing
///
/// - Parameter spacing: Custom Spacing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,31 @@ import UIKit
/// Spacing around the section.
public enum SectionEdgeInsets {
// swiftlint:disable sorted_enum_cases

/// Only at the top.
case top(CGFloat)

/// Only at the bottom.
case bottom(CGFloat)

/// Both top and bottom with the same size.
case topBottom(CGFloat)
case vertical(CGFloat)

/// Both sides with the same size.
case bothSides(CGFloat)
case horizontal(CGFloat)

/// Custom spacing for all four sides.
case allInOne(CGFloat)

/// Custom spacing, equal spacing on coaxes
case allWithCoaxes(vertical: CGFloat, horizontal: CGFloat)

/// Custom spacing for all four sides.
case all(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat)

/// Fully customized using `NSDirectionalEdgeInsets`.
case custom(NSDirectionalEdgeInsets)

// swiftlint:enable sorted_enum_cases
}

Expand All @@ -43,22 +46,25 @@ extension SectionEdgeInsets {
switch self {
case .top(let value):
.init(top: value, leading: 0, bottom: 0, trailing: 0)

case .bottom(let value):
.init(top: 0, leading: 0, bottom: value, trailing: 0)
case .topBottom(let value):

case .vertical(let value):
.init(top: value, leading: 0, bottom: value, trailing: 0)
case .bothSides(let value):

case .horizontal(let value):
.init(top: 0, leading: value, bottom: 0, trailing: value)

case .allInOne(let value):
.init(top: value, leading: value, bottom: value, trailing: value)

case .allWithCoaxes(let vertical, let horizontal):
.init(top: vertical, leading: horizontal, bottom: vertical, trailing: horizontal)

case .all(let top, let leading, let bottom, let trailing):
.init(top: top, leading: leading, bottom: bottom, trailing: trailing)

case .custom(let edge):
edge
}
Expand Down
32 changes: 29 additions & 3 deletions Sources/Epoxy/Row/ButtonRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import RAKCore
public final class ButtonRow: UIButton {
private lazy var size: OptionalSize? = nil

/// Closure for touch down event.
/// Closure for `.touchDown` event.
private lazy var didTouchDown: ButtonClosure? = nil

/// Closure for tap event.
/// Closure for `.touchUpInside` event.
private lazy var didTap: ButtonClosure? = nil

/// Closure for `.menuActionTriggered` event. Only available on iOS 14.
private lazy var didTriggerMenuAction: ButtonClosure? = nil
}

// MARK: - Life cycle
Expand Down Expand Up @@ -53,6 +56,11 @@ extension ButtonRow {
private func buttonDidClick(_ button: UIButton) {
didTap?(button)
}

@objc
private func buttonDidTriggerMenuAction(_ button: UIButton) {
didTriggerMenuAction?(button)
}
}

// MARK: StyledView
Expand Down Expand Up @@ -117,6 +125,10 @@ extension ButtonRow: StyledView {

addTarget(self, action: #selector(buttonDidTouchDown(_:)), for: .touchDown)
addTarget(self, action: #selector(buttonDidClick(_:)), for: .touchUpInside)

if #available(iOS 14.0, *) {
addTarget(self, action: #selector(buttonDidTriggerMenuAction(_:)), for: .menuActionTriggered)
}
}
}

Expand Down Expand Up @@ -225,14 +237,19 @@ extension ButtonRow: BehaviorsConfigurableView {
/// Closure for tap event.
public let didTap: ButtonClosure?

/// Closure for `.menuActionTriggered` event. Only available on iOS 14.
public let didTriggerMenuAction: ButtonClosure?

public init(
updateImage: ImageRow.Behaviors<T>? = nil,
didTouchDown: ButtonClosure? = nil,
didTap: ButtonClosure? = nil
didTap: ButtonClosure? = nil,
didTriggerMenuAction: ButtonClosure? = nil
) {
self.updateImage = updateImage
self.didTouchDown = didTouchDown
self.didTap = didTap
self.didTriggerMenuAction = didTriggerMenuAction
}
}

Expand All @@ -257,5 +274,14 @@ extension ButtonRow: BehaviorsConfigurableView {

didTouchDown = behaviors?.didTouchDown
didTap = behaviors?.didTap

if
#available(iOS 14.0, *),
let _didTriggerMenuAction = behaviors?.didTriggerMenuAction
{
didTriggerMenuAction = _didTriggerMenuAction
} else {
didTriggerMenuAction = nil
}
}
}
6 changes: 3 additions & 3 deletions Sources/Epoxy/Row/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension ImageRow: ContentConfigurableView {
case asset(String, bundle: Bundle = .main)
case data(Data)
case file(String)
case sfSymbols(String)
case sfSymbols(String, configuration: UIImage.SymbolConfiguration? = nil)

public var image: UIImage? {
switch self {
Expand All @@ -111,8 +111,8 @@ extension ImageRow: ContentConfigurableView {
case .file(let path):
.init(contentsOfFile: path)

case .sfSymbols(let name):
.init(systemName: name)
case .sfSymbols(let name, let configuration):
.init(systemName: name, withConfiguration: configuration)
}
}
}
Expand Down