Skip to content

Commit fda0c23

Browse files
author
coderchan
committed
Update
1 parent 29c0ac6 commit fda0c23

36 files changed

+1045
-36
lines changed

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ let package = Package(
55
name: "SwifterUI",
66
platforms: [.iOS(.v13)],
77
products: [
8-
// 主库
98
.library(
109
name: "SwiftlyUI",
1110
targets: ["SwiftlyUI"]
1211
),
1312
],
1413
dependencies: [],
1514
targets: [
16-
// 核心模块(不依赖 SnapKit)
1715
.target(
1816
name: "SwiftlyUI",
1917
path: "SwiftlyUI",

SwiftlyUI/Source/Core/UIActivityIndicatorView+SwiftlyUI.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ import UIKit
1010

1111

1212
public extension UIActivityIndicatorView {
13+
14+
/// SwiftlyUI extension for `UIActivityIndicatorView`.
1315
@discardableResult
1416
func style(_ style: UIActivityIndicatorView.Style) -> Self {
1517
self.style = style
1618
return self
1719
}
1820

21+
/// SwiftlyUI extension for `UIActivityIndicatorView`.
1922
@discardableResult
2023
func color(_ color: UIColor?) -> Self {
2124
self.color = color
2225
return self
2326
}
2427

28+
/// SwiftlyUI extension for `UIActivityIndicatorView`.
2529
@discardableResult
2630
func animating(_ animating: Bool) -> Self {
2731
if animating {
@@ -32,6 +36,7 @@ public extension UIActivityIndicatorView {
3236
return self
3337
}
3438

39+
/// SwiftlyUI extension for `UIActivityIndicatorView`.
3540
@discardableResult
3641
func hidesWhenStopped(_ hides: Bool) -> Self {
3742
self.hidesWhenStopped = hides

SwiftlyUI/Source/Core/UIBackgroundConfiguration+SwiftlyUI.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,67 +13,74 @@ import UIKit
1313
@available(iOS 14.0, watchOS 7.0, *)
1414
public extension UIBackgroundConfiguration {
1515

16+
17+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
18+
/// - Parameter content: A closure that builds an array of `UIView` elements to be used as the custom view.
19+
/// - Returns: A new `UIBackgroundConfiguration` instance with the custom view set.
1620
@discardableResult
1721
func customView(@SwiftlyUIBuilder content: () -> [UIView]) -> UIBackgroundConfiguration {
1822
var newConfig = self
1923
newConfig.customView = content().last
2024
return newConfig
2125
}
2226

27+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
2328
@discardableResult
2429
func customView(_ view: UIView?) -> UIBackgroundConfiguration {
2530
var newConfig = self
2631
newConfig.customView = view
2732
return newConfig
2833
}
2934

35+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
3036
@discardableResult
3137
func cornerRadius(_ radius: CGFloat) -> UIBackgroundConfiguration {
3238
var newConfig = self
3339
newConfig.cornerRadius = radius
3440
return newConfig
3541
}
3642

43+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
3744
@discardableResult
3845
func backgroundInsets(_ insets: NSDirectionalEdgeInsets) -> UIBackgroundConfiguration {
3946
var newConfig = self
4047
newConfig.backgroundInsets = insets
4148
return newConfig
4249
}
4350

51+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
4452
@discardableResult
4553
func edgesAddingLayoutMargins(_ edges: NSDirectionalRectEdge) -> UIBackgroundConfiguration {
4654
var newConfig = self
4755
newConfig.edgesAddingLayoutMarginsToBackgroundInsets = edges
4856
return newConfig
4957
}
5058

51-
// MARK: - 背景颜色相关
52-
59+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
5360
@discardableResult
5461
func backgroundColor(_ color: UIColor?) -> UIBackgroundConfiguration {
5562
var newConfig = self
5663
newConfig.backgroundColor = color
5764
return newConfig
5865
}
5966

67+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
6068
@discardableResult
6169
func backgroundColorTransformer(_ transformer: UIConfigurationColorTransformer?) -> UIBackgroundConfiguration {
6270
var newConfig = self
6371
newConfig.backgroundColorTransformer = transformer
6472
return newConfig
6573
}
6674

67-
// MARK: - 视觉效果
68-
75+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
6976
@discardableResult
7077
func visualEffect(_ effect: UIVisualEffect?) -> UIBackgroundConfiguration {
7178
var newConfig = self
7279
newConfig.visualEffect = effect
7380
return newConfig
7481
}
7582

76-
// MARK: - 图片配置 (iOS 15+/watchOS 8+)
83+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
7784
@available(iOS 15.0, watchOS 8.0, tvOS 15.0, *)
7885
@discardableResult
7986
func image(_ image: UIImage?) -> UIBackgroundConfiguration {
@@ -82,6 +89,7 @@ public extension UIBackgroundConfiguration {
8289
return newConfig
8390
}
8491

92+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
8593
@available(iOS 15.0, watchOS 8.0, tvOS 15.0, *)
8694
@discardableResult
8795
func imageContentMode(_ mode: UIView.ContentMode) -> UIBackgroundConfiguration {
@@ -90,29 +98,31 @@ public extension UIBackgroundConfiguration {
9098
return newConfig
9199
}
92100

93-
// MARK: - 边框样式
94-
101+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
95102
@discardableResult
96103
func strokeColor(_ color: UIColor?) -> UIBackgroundConfiguration {
97104
var newConfig = self
98105
newConfig.strokeColor = color
99106
return newConfig
100107
}
101108

109+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
102110
@discardableResult
103111
func strokeColorTransformer(_ transformer: UIConfigurationColorTransformer?) -> UIBackgroundConfiguration {
104112
var newConfig = self
105113
newConfig.strokeColorTransformer = transformer
106114
return newConfig
107115
}
108116

117+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
109118
@discardableResult
110119
func strokeWidth(_ width: CGFloat) -> UIBackgroundConfiguration {
111120
var newConfig = self
112121
newConfig.strokeWidth = width
113122
return newConfig
114123
}
115124

125+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
116126
@discardableResult
117127
func strokeOutset(_ outset: CGFloat) -> UIBackgroundConfiguration {
118128
var newConfig = self
@@ -122,6 +132,7 @@ public extension UIBackgroundConfiguration {
122132

123133
// MARK: - 阴影属性 (iOS 18+/watchOS 11+)
124134
#if compiler(>=6.0)
135+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
125136
@available(iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
126137
@discardableResult
127138
func shadowProperties(_ properties: UIShadowProperties) -> UIBackgroundConfiguration {
@@ -130,15 +141,14 @@ public extension UIBackgroundConfiguration {
130141
return newConfig
131142
}
132143
#endif
133-
// MARK: - 便捷方法
134144

135-
/// 链式更新状态配置
145+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
136146
@discardableResult
137147
func update(for state: UIConfigurationState) -> UIBackgroundConfiguration {
138148
self.updated(for: state)
139149
}
140150

141-
/// 便捷设置背景边距(简化版)
151+
/// SwiftlyUI extension for `UIBackgroundConfiguration`.
142152
@discardableResult
143153
func backgroundInsets(top: CGFloat = 0, leading: CGFloat = 0, bottom: CGFloat = 0, trailing: CGFloat = 0) -> UIBackgroundConfiguration {
144154
var newConfig = self

SwiftlyUI/Source/Core/UIBarButtonItem+SwiftlyUI.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,63 @@ import UIKit
1111

1212
public extension UIBarItem {
1313

14+
/// SwiftlyUI extension for `UIBarItem`.
1415
@discardableResult
1516
func title(_ title: String?) -> Self {
1617
self.title = title
1718
return self
1819
}
1920

21+
/// SwiftlyUI extension for `UIBarItem`.
2022
@discardableResult
2123
func enabled(_ enabled: Bool) -> Self {
2224
self.isEnabled = enabled
2325
return self
2426
}
2527

28+
/// SwiftlyUI extension for `UIBarItem`.
2629
@discardableResult
2730
func image(_ image: UIImage?) -> Self {
2831
self.image = image
2932
return self
3033
}
3134

35+
/// SwiftlyUI extension for `UIBarItem`.
3236
@discardableResult
3337
func landscapeImagePhone(_ image: UIImage?) -> Self {
3438
self.landscapeImagePhone = image
3539
return self
3640
}
3741

42+
/// SwiftlyUI extension for `UIBarItem`.
3843
@discardableResult
3944
func largeContentSizeImage(_ image: UIImage?) -> Self {
4045
self.largeContentSizeImage = image
4146
return self
4247
}
4348

49+
/// SwiftlyUI extension for `UIBarItem`.
4450
@discardableResult
4551
func imageInsets(_ insets: UIEdgeInsets) -> Self {
4652
self.imageInsets = insets
4753
return self
4854
}
4955

56+
/// SwiftlyUI extension for `UIBarItem`.
5057
@discardableResult
5158
func landscapeImagePhoneInsets(_ insets: UIEdgeInsets) -> Self {
5259
self.landscapeImagePhoneInsets = insets
5360
return self
5461
}
5562

63+
/// SwiftlyUI extension for `UIBarItem`.
5664
@discardableResult
5765
func largeContentSizeImageInsets(_ insets: UIEdgeInsets) -> Self {
5866
self.largeContentSizeImageInsets = insets
5967
return self
6068
}
6169

70+
/// SwiftlyUI extension for `UIBarItem`.
6271
@discardableResult
6372
func tag(_ tag: Int) -> Self {
6473
self.tag = tag
@@ -68,7 +77,7 @@ public extension UIBarItem {
6877

6978
public extension UIBarButtonItem {
7079

71-
/// Creates a UIBarButtonItem with a custom view.
80+
/// /// SwiftlyUI - Creates a UIBarButtonItem with a custom view.
7281
@discardableResult
7382
convenience init(@SwiftlyUIBuilder customContentView: () -> [UIView]) {
7483
if customContentView().count != 1 {
@@ -78,45 +87,52 @@ public extension UIBarButtonItem {
7887
self.init(customView: content)
7988
}
8089

90+
/// SwiftlyUI extension for `UIBarButtonItem`.
8191
@discardableResult
8292
func possibleTitles(_ titles: Set<String>?) -> Self {
8393
self.possibleTitles = titles
8494
return self
8595
}
8696

97+
/// SwiftlyUI extension for `UIBarButtonItem`.
8798
@discardableResult
8899
func customView(_ view: UIView?) -> Self {
89100
self.customView = view
90101
return self
91102
}
92103

104+
/// SwiftlyUI extension for `UIBarButtonItem`.
93105
@discardableResult
94106
func style(_ style: UIBarButtonItem.Style) -> Self {
95107
self.style = style
96108
return self
97109
}
98110

111+
/// SwiftlyUI extension for `UIBarButtonItem`.
99112
@discardableResult
100113
func target(_ target: AnyObject?, action: Selector?) -> Self {
101114
self.target = target
102115
self.action = action
103116
return self
104117
}
105118

119+
/// SwiftlyUI extension for `UIBarButtonItem`.
106120
@discardableResult
107121
func tintColor(_ color: UIColor?) -> Self {
108122
self.tintColor = color
109123
return self
110124
}
111125

112126
#if compiler(>=5.3)
127+
/// SwiftlyUI extension for `UIBarButtonItem`.
113128
@available(iOS 14, *)
114129
@discardableResult
115130
func menu(_ menu: UIMenu?) -> Self {
116131
self.menu = menu
117132
return self
118133
}
119134

135+
/// SwiftlyUI extension for `UIBarButtonItem`.
120136
@available(iOS 14, *)
121137
@discardableResult
122138
func primaryAction(_ action: UIAction?) -> Self {
@@ -126,13 +142,15 @@ public extension UIBarButtonItem {
126142

127143
#endif
128144
#if compiler(>=5.5)
145+
/// SwiftlyUI extension for `UIBarButtonItem`.
129146
@available(iOS 15.0, *)
130147
@discardableResult
131148
func changesSelectionAsPrimaryAction(_ changes: Bool) -> Self {
132149
self.changesSelectionAsPrimaryAction = changes
133150
return self
134151
}
135152

153+
/// SwiftlyUI extension for `UIBarButtonItem`.
136154
@available(iOS 15.0, *)
137155
@discardableResult
138156
func selected(_ selected: Bool) -> Self {
@@ -143,20 +161,23 @@ public extension UIBarButtonItem {
143161
#endif
144162

145163
#if compiler(>=5.7)
164+
/// SwiftlyUI extension for `UIBarButtonItem`.
146165
@available(iOS 16.0, *)
147166
@discardableResult
148167
func hidden(_ hidden: Bool = true) -> Self {
149168
self.isHidden = hidden
150169
return self
151170
}
152171

172+
/// SwiftlyUI extension for `UIBarButtonItem`.
153173
@available(iOS 16.0, *)
154174
@discardableResult
155175
func preferredMenuElementOrder(_ order: UIContextMenuConfiguration.ElementOrder) -> Self {
156176
self.preferredMenuElementOrder = order
157177
return self
158178
}
159179

180+
/// SwiftlyUI extension for `UIBarButtonItem`.
160181
@available(iOS 16.0, *)
161182
@discardableResult
162183
func menuRepresentation(_ representation: UIMenuElement?) -> Self {

0 commit comments

Comments
 (0)