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/ns collection layout section theme section inter group spacing #167

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
163f3dd
add: theme_backgroundColorOrGradient to UIView
Nov 21, 2022
6286180
update: name for selector
Nov 22, 2022
2f1db8a
Merge pull request #1 from RedAirship/feature/background-gradient
ryantan Nov 22, 2022
ecad119
add: theme_widthConstant and theme_heightConstant to UIView
ryantan Nov 24, 2022
7bf4f2f
Merge pull request #2 from RedAirship/feat/width-height
ryantan Nov 24, 2022
670e376
add: theme_constraintConstant to NSLayoutConstraint
ryantan Nov 29, 2022
ef6b6c1
add: theme_figmaShadow to CALayer
ryantan Nov 29, 2022
07a1a27
Merge pull request #3 from RedAirship/feat/constraint-constant-and-sh…
huy-ras Nov 29, 2022
491f507
docs: clean up and some comments for NSLayoutConstraint+Theme.swift
ryantan Nov 29, 2022
aac41a4
add: theme_stackViewSpacing to UIStackView
ryantan Nov 29, 2022
4b3cf93
Merge pull request #4 from RedAirship/feat/stackview-spacing
huy-ras Nov 29, 2022
66f66e1
add: padding with theme for UIStackView
huy-ras Dec 7, 2022
734cd44
Merge pull request #5 from RedAirship/feature/padding-stack-view
ryantan Dec 7, 2022
f871c82
update: wrong directions of vertical and horizontal
huy-ras Dec 7, 2022
7674a5b
Merge pull request #6 from RedAirship/fix/padding-vertical-horizontal…
ryantan Dec 7, 2022
9eb2d2f
feat: create theme_titlePositionAdjustmentVerticalPositive, theme_tit…
hooiling513 Dec 14, 2022
93175f1
Merge pull request #7 from RedAirship/feature/create-new-theme-proper…
ryantan Dec 15, 2022
b63f239
feat(nsCollectionLayoutSection): add `theme_sectionInterGroupSpacing`…
PaulAddy Dec 16, 2022
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
21 changes: 21 additions & 0 deletions Sources/CALayer+Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// CALayer+Theme.swift
//
//
// Created by Hooi Ling on 14/12/22.
//

import Foundation
import QuartzCore

extension CALayer {
/// Sets corner radius on CALayer
///
/// Triggered by SwiftTheme when theme_cornerRadius is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
///
/// Not called setCornerRadius so as not to conflict with existing func with same name.
@objc func customSetCornerRadius(_ value: CGFloat) {
cornerRadius = value
}
}
21 changes: 21 additions & 0 deletions Sources/NSLayoutConstraint+Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// NSLayoutConstraint+Theme.swift
//
// Setters used by ThemePickers operating on NSLayoutConstraint.
//
// Created by Ryan Tan on 29/11/22.
//

import UIKit

#if os(iOS)
extension NSLayoutConstraint {

/// Sets constant for the constraint.
///
/// Triggered by SwiftTheme when theme_constraintConstant is used.
@objc func setConstraintConstant(_ value: CGFloat) {
constant = value
}
}
#endif
83 changes: 83 additions & 0 deletions Sources/UIKit+Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ import UIKit
get { return getThemePicker(self, "setTintColor:") as? ThemeColorPicker }
set { setThemePicker(self, "setTintColor:", newValue) }
}
var theme_backgroundColorOrGradient: ThemeAnyPicker? {
get { return getThemePicker(self, "setBackgroundColorOrGradient:") as? ThemeAnyPicker }
set { setThemePicker(self, "setBackgroundColorOrGradient:", newValue) }
}
var theme_widthConstant: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setWidthConstantConstraint:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setWidthConstantConstraint:", newValue) }
}
var theme_heightConstant: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setHeightConstantConstraint:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setHeightConstantConstraint:", newValue) }
}
}
@objc public extension UIApplication
{
Expand Down Expand Up @@ -152,6 +164,16 @@ import UIKit
get { return getThemePicker(self, "setSelectedImage:") as? ThemeImagePicker }
set { setThemePicker(self, "setSelectedImage:", newValue) }
}

var theme_titlePositionAdjustmentVertical: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setTitlePositionAdjustmentVertical:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setTitlePositionAdjustmentVertical:", newValue) }
}

var theme_titlePositionAdjustmentVerticalNegative: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setTitlePositionAdjustmentVerticalNegative:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setTitlePositionAdjustmentVerticalNegative:", newValue) }
}
}
@objc public extension UITableView
{
Expand Down Expand Up @@ -311,6 +333,14 @@ import UIKit
get { return getThemePicker(self, "setFillColor:") as? ThemeCGColorPicker }
set { setThemePicker(self, "setFillColor:", newValue) }
}
var theme_figmaShadow: ThemeAnyPicker? {
get { return getThemePicker(self, "setFigmaShadowTokens:") as? ThemeAnyPicker }
set { setThemePicker(self, "setFigmaShadowTokens:", newValue) }
}
var theme_cornerRadius: ThemeCGFloatPicker? {
get { return getThemePicker(self, "customSetCornerRadius:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "customSetCornerRadius:", newValue) }
}
}
@objc public extension CATextLayer
{
Expand Down Expand Up @@ -397,6 +427,59 @@ import UIKit
set { setThemePicker(self, "setEffect:", newValue) }
}
}
@objc public extension NSLayoutConstraint
{
var theme_constraintConstant: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setConstraintConstant:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setConstraintConstant:", newValue) }
}
}

@available(iOS 13.0, *)
@objc public extension NSCollectionLayoutSection
{
var theme_sectionInterGroupSpacing: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setSectionInterGroupSpacing:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setSectionInterGroupSpacing:", newValue) }
}
}


@objc public extension UIStackView
{
var theme_stackViewSpacing: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewSpacing:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewSpacing:", newValue) }
}
var theme_paddingLeft: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingLeft:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingLeft:", newValue) }
}
var theme_paddingTop: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingTop:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingTop:", newValue) }
}
var theme_paddingRight: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingRight:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingRight:", newValue) }
}
var theme_paddingBottom: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingBottom:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingBottom:", newValue) }
}
var theme_paddingVertical: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingVertical:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingVertical:", newValue) }
}
var theme_paddingHorizontal: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPaddingHorizontal:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPaddingHorizontal:", newValue) }
}
var theme_padding: ThemeCGFloatPicker? {
get { return getThemePicker(self, "setStackViewPadding:") as? ThemeCGFloatPicker }
set { setThemePicker(self, "setStackViewPadding:", newValue) }
}
}
@available(iOS 13.0, *)
@objc public extension UINavigationBarAppearance
{
Expand Down
86 changes: 86 additions & 0 deletions Sources/UIStackview+Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// UIStackview+Theme.swift
//
// Setters used by ThemePickers operating on UIStackView.
//
// Created by Ryan Tan on 29/11/22.
//

import UIKit

#if os(iOS)
extension UIStackView {

/// Sets spacing on stack views..
///
/// Triggered by SwiftTheme when theme_stackViewSpacing is used.
@objc func setStackViewSpacing(_ value: CGFloat) {
spacing = value
}

/// Sets padding left on stack views.
///
/// Triggered by SwiftTheme when theme_paddingLeft is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingLeft(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.left = value
}

/// Sets padding top on stack views.
///
/// Triggered by SwiftTheme when theme_paddingTop is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingTop(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.top = value
}

/// Sets padding right on stack views.
///
/// Triggered by SwiftTheme when theme_paddingRight is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingRight(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.right = value
}

/// Sets padding bottom on stack views.
///
/// Triggered by SwiftTheme when theme_paddingBottom is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingBottom(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.bottom = value
}

/// Sets padding for vertical (top, bottom) on stack views.
///
/// Triggered by SwiftTheme when theme_paddingVertical is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingVertical(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.top = value
layoutMargins.bottom = value
}

/// Sets padding for horizontal (leading, trailing) on stack views.
///
/// Triggered by SwiftTheme when theme_paddingHorizontal is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPaddingHorizontal(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins.left = value
layoutMargins.right = value
}

/// Sets padding all sides on stack views.
///
/// Triggered by SwiftTheme when theme_padding is used.
/// - Parameter value: a `ThemeCGFloatPicker` value
@objc func setStackViewPadding(_ value: CGFloat) {
isLayoutMarginsRelativeArrangement = true
layoutMargins = UIEdgeInsets(top: value, left: value, bottom: value, right: value)
}
}
#endif
28 changes: 28 additions & 0 deletions Sources/UITabBarItem+Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// File.swift
//
//
// Created by Hooi Ling on 13/12/22.
//


import UIKit

#if os(iOS)
extension UITabBarItem {

/// Sets vertical value for titlePositionAdjustment.
///
/// Triggered by SwiftTheme when `theme_titlePositionAdjustmentVertical` is used.
@objc func setTitlePositionAdjustmentVertical(_ value: CGFloat) {
titlePositionAdjustment = UIOffset(horizontal: 0, vertical: value)
}

/// Sets negative vertical value for titlePositionAdjustment.
///
/// Triggered by SwiftTheme when `theme_titlePositionAdjustmentVerticalNegative` is used.
@objc func setTitlePositionAdjustmentVerticalNegative(_ value: CGFloat) {
titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -value)
}
}
#endif