Skip to content

Commit 2b606c2

Browse files
committed
updated
1 parent 7537725 commit 2b606c2

File tree

12 files changed

+383
-29
lines changed

12 files changed

+383
-29
lines changed

Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"location" : "https://github.com/flocked/FZSwiftUtils.git",
1717
"state" : {
1818
"branch" : "main",
19-
"revision" : "21b4a9aa0cef7bce4b6b1f0a63e8e52511cd1eb7"
19+
"revision" : "d062df0a7350c11d4f610a979f060612dc2966f5"
2020
}
2121
},
2222
{
@@ -25,7 +25,7 @@
2525
"location" : "https://github.com/flocked/FZUIKit.git",
2626
"state" : {
2727
"branch" : "main",
28-
"revision" : "c50355f75a62cbc2b3715de61d4575964050b04a"
28+
"revision" : "2d9103d4c655594313d77b220191afe9ca6de036"
2929
}
3030
}
3131
],

Example/Example/Base.lproj/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ Quicklook collection items via spacebar and favorite them by right-clicking them
909909
<subviews>
910910
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="5" horizontalPageScroll="10" verticalLineScroll="5" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="Imv-nG-c4J">
911911
<rect key="frame" x="0.0" y="253" width="220" height="245"/>
912-
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
912+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
913913
<clipView key="contentView" drawsBackground="NO" id="Bv4-Kx-Cwg">
914914
<rect key="frame" x="0.0" y="0.0" width="220" height="245"/>
915915
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// TextAccessory.swift
3+
//
4+
//
5+
// Created by Florian Zand on 16.03.25.
6+
//
7+
8+
import Foundation
9+
10+
struct TextAccessory {
11+
/**
12+
The text.
13+
14+
This value supersedes the ``attributedText`` property.
15+
*/
16+
public var text: String? {
17+
didSet {
18+
guard text != nil else { return }
19+
attributedText = nil
20+
}
21+
}
22+
23+
/**
24+
An attributed variant of the text.
25+
26+
This value supersedes the ``text`` property.
27+
*/
28+
public var attributedText: AttributedString? {
29+
didSet {
30+
guard attributedText != nil else { return }
31+
text = nil
32+
}
33+
}
34+
35+
/**
36+
The placeholder text.
37+
38+
This value supersedes the ``attributedPlaceholderText`` property.
39+
*/
40+
public var placeholderText: String? {
41+
didSet {
42+
guard placeholderText != nil else { return }
43+
attributedPlaceholderText = nil
44+
}
45+
}
46+
47+
/**
48+
An attributed variant of the placeholder text.
49+
50+
This value supersedes the ``placeholderText`` property.
51+
*/
52+
public var attributedPlaceholderText: AttributedString? {
53+
didSet {
54+
guard attributedPlaceholderText != nil else { return }
55+
placeholderText = nil
56+
}
57+
}
58+
59+
/// Properties for configuring the primary text.
60+
public var textProperties: TextProperties = .primary
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
//
2+
// TextStackAccessory.swift
3+
//
4+
//
5+
// Created by Florian Zand on 16.03.25.
6+
//
7+
8+
import Foundation
9+
10+
struct TextStackAccessory {
11+
/**
12+
The leading text.
13+
14+
This value supersedes the ``attributedLeadingText`` property.
15+
*/
16+
public var leadingText: String? {
17+
didSet {
18+
guard leadingText != nil else { return }
19+
attributedLeadingText = nil
20+
}
21+
}
22+
23+
/**
24+
An attributed variant of the leading text.
25+
26+
This value supersedes the ``leadingText`` property.
27+
*/
28+
public var attributedLeadingText: AttributedString? {
29+
didSet {
30+
guard attributedLeadingText != nil else { return }
31+
leadingText = nil
32+
}
33+
}
34+
35+
/**
36+
The leading placeholder text.
37+
38+
This value supersedes the ``attributedPlaceholderLeadingText`` property.
39+
*/
40+
public var placeholderLeadingText: String? {
41+
didSet {
42+
guard placeholderLeadingText != nil else { return }
43+
attributedPlaceholderLeadingText = nil
44+
}
45+
}
46+
47+
/**
48+
An attributed variant of the leading placeholder text.
49+
50+
This value supersedes the ``placeholderLeadingText`` property.
51+
*/
52+
public var attributedPlaceholderLeadingText: AttributedString? {
53+
didSet {
54+
guard attributedPlaceholderLeadingText != nil else { return }
55+
placeholderLeadingText = nil
56+
}
57+
}
58+
59+
/**
60+
The trailing text.
61+
62+
This value supersedes the ``attributedTrailingText`` property.
63+
*/
64+
public var trailingText: String? {
65+
didSet {
66+
guard trailingText != nil else { return }
67+
attributedTrailingText = nil
68+
}
69+
}
70+
71+
/**
72+
An attributed variant of the trailing text.
73+
74+
This value supersedes the ``trailingText`` property.
75+
*/
76+
public var attributedTrailingText: AttributedString? {
77+
didSet {
78+
guard attributedLeadingText != nil else { return }
79+
trailingText = nil
80+
}
81+
}
82+
83+
/**
84+
The trailing placeholder text.
85+
86+
This value supersedes the ``attributedPlaceholderTrailingText`` property.
87+
*/
88+
public var placeholderTrailingText: String? {
89+
didSet {
90+
guard placeholderLeadingText != nil else { return }
91+
attributedPlaceholderTrailingText = nil
92+
}
93+
}
94+
95+
/**
96+
An attributed variant of the trailing placeholder text.
97+
98+
This value supersedes the ``placeholderTrailingText`` property.
99+
*/
100+
public var attributedPlaceholderTrailingText: AttributedString? {
101+
didSet {
102+
guard attributedPlaceholderTrailingText != nil else { return }
103+
placeholderTrailingText = nil
104+
}
105+
}
106+
107+
108+
/// Properties for configuring the primary text.
109+
public var leadingTextProperties: TextProperties = .primary
110+
111+
/// Properties for configuring the primary text.
112+
public var trailingTextProperties: TextProperties = .primary
113+
114+
/// The spacing between the leading and trailing text.
115+
public var leadingToTrailingTextSpacing: CGFloat = 4.0
116+
117+
var trailingText: String?
118+
}

Sources/AdvancedCollectionTableView/Configuration/Configurations/NSListContentConfiguration/NSListContentConfiguration+Image.swift

Lines changed: 127 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,27 @@ public extension NSListContentConfiguration {
3535
}
3636

3737
/// The scaling of the image.
38-
public enum Scaling: Hashable {
38+
public enum Scaling: Int, Hashable {
3939
/// The image is resized to fit the bounds rectangle, preserving the aspect of the image. If the image does not completely fill the bounds rectangle, the image is centered in the partial axis.
40-
case fit
40+
case scaleToFit
41+
/// The image is resized to completely fill the bounds rectangle, while still preserving the aspect of the image.
42+
case scaleToFill
4143
/// The image is resized to fit the entire bounds rectangle.
4244
case resize
4345
/// The image isn't resized.
4446
case none
45-
// case fill
4647

47-
var imageScaling: NSImageScaling {
48+
var scaling: NSImageScaling {
4849
switch self {
49-
case .fit: return .scaleProportionallyUpOrDown
50-
// case .fill: return .scaleProportionallyUpOrDown
50+
case .scaleToFit: return .scaleProportionallyUpOrDown
51+
case .scaleToFill: return .scaleProportionallyUpOrDown
5152
case .resize: return .scaleAxesIndependently
5253
case .none: return .scaleNone
5354
}
5455
}
55-
56-
var contentsGravity: CALayerContentsGravity {
57-
switch self {
58-
case .fit: return .resizeAspect
59-
// case .fill: return .resizeAspectFill
60-
case .resize: return .resize
61-
case .none: return .center
62-
}
56+
57+
var imageScaling: ImageView.ImageScaling {
58+
ImageView.ImageScaling(rawValue: rawValue)!
6359
}
6460
}
6561

@@ -142,8 +138,27 @@ public extension NSListContentConfiguration {
142138
}
143139
}
144140

145-
// var reservedLayoutSize: CGSize = CGSize(0, 0)
146-
// static let standardDimension: CGFloat = -CGFloat.greatestFiniteMagnitude
141+
/**
142+
The layout size that the system reserves for the image, and then centers the image within.
143+
144+
Use this property to ensure:
145+
- Consistent horizontal alignment for images across adjacent content views, even when the images vary in width.
146+
- Consistent height for content views, even when the images vary in height.
147+
148+
The reserved layout size only affects the amount of space for the image, and its positioning within that space. It doesn’t affect the size of the image.
149+
150+
The default value is `zero`. A width or height of zero means that the system uses the default behavior for that dimension:
151+
- The system centers symbol images inside a predefined reserved layout size that scales with the content size category.
152+
- Nonsymbol images use a reserved layout size equal to the actual size of the displayed image.
153+
*/
154+
public var reservedLayoutSize: CGSize = CGSize(0, 0)
155+
156+
/**
157+
The system standard layout dimension for reserved layout size.
158+
159+
Setting the ``reservedLayoutSize`` width or height to this constant results in using the system standard value for a symbol image for that dimension, even when the image is not a symbol image.
160+
*/
161+
public static let standardDimension: CGFloat = -CGFloat.greatestFiniteMagnitude
147162

148163
/// The tint color for an image that is a template or symbol image.
149164
public var tintColor: NSColor?
@@ -202,7 +217,7 @@ public extension NSListContentConfiguration {
202217
public var symbolConfiguration: ImageSymbolConfiguration? = .font(.body)
203218

204219
/// The image scaling.
205-
public var scaling: Scaling = .fit
220+
public var scaling: Scaling = .scaleToFit
206221

207222
/// The sizing option for the image.
208223
public var sizing: Sizing = .totalTextHeight
@@ -216,3 +231,98 @@ public extension NSListContentConfiguration {
216231
init() {}
217232
}
218233
}
234+
235+
/*
236+
struct Layout: Hashable {
237+
enum VerticalSizing: Hashable {
238+
/// The image isn't resized.
239+
case imageSize
240+
/// The image is resized to the list item's height.
241+
case totalHeight
242+
/// The image is resized to the text height.
243+
case textHeight
244+
/// The image is resized to the secondary text height.
245+
case secondaryTextHeight
246+
/// The image is resized to fit the specified width.
247+
case width(CGFloat)
248+
/// The image is resized to fit the specified height.
249+
case height(CGFloat)
250+
/// The image is resized to the specified size.
251+
case size(CGSize)
252+
/// The image is resized to fit the maximum size.
253+
case maxSize(CGSize)
254+
}
255+
256+
enum HorizontalSizing: Hashable {
257+
/// The image isn't resized.
258+
case imageSize
259+
/// The image is resized to the list item's width.
260+
case totalWidth
261+
/// The image is resized to fit the specified width.
262+
case width(CGFloat)
263+
/// The image is resized to fit the specified height.
264+
case height(CGFloat)
265+
/// The image is resized to the specified size.
266+
case size(CGSize)
267+
/// The image is resized to fit the maximum size.
268+
case maxSize(CGSize)
269+
}
270+
271+
enum VerticalPosition: Hashable {
272+
/// The image is positioned at the first baseline.
273+
case firstBaseline
274+
/// The image is positioned at the center the text.
275+
case text
276+
/// The image is positioned at the center the secondary text.
277+
case secondaryText
278+
/// The image is positioned at the top edge.
279+
case top
280+
/// The image is positioned at the vertical center.
281+
case center
282+
/// The image is positioned at the bottom edge.
283+
case bottom
284+
}
285+
286+
enum HorizontalPosition: Hashable {
287+
/// The image is positioned at the leading edge.
288+
case leading
289+
/// The image is positioned at the horizontal center.
290+
case center
291+
/// The image is positioned at the trailing edge.
292+
case traiing
293+
}
294+
295+
enum _Position: Hashable {
296+
case leading(VerticalPosition, VerticalSizing)
297+
case trailing(VerticalPosition, VerticalSizing)
298+
case bottom(HorizontalPosition, HorizontalSizing)
299+
case top(HorizontalPosition, HorizontalSizing)
300+
}
301+
302+
func sdsd() {
303+
// Layout.
304+
}
305+
306+
let positon: _Position
307+
308+
init(_ positon: _Position) {
309+
self.positon = positon
310+
}
311+
312+
public static func leading(at positon: VerticalPosition = .firstBaseline, size: VerticalSizing = .imageSize) -> Layout {
313+
Layout(.leading(positon, size))
314+
}
315+
316+
public static func trailing(at positon: VerticalPosition = .firstBaseline, size: VerticalSizing = .imageSize) -> Layout {
317+
Layout(.trailing(positon, size))
318+
}
319+
320+
public static func bottom(at positon: HorizontalPosition = .leading, size: HorizontalSizing = .totalWidth) -> Layout {
321+
Layout(.bottom(positon, size))
322+
}
323+
324+
public static func top(at positon: HorizontalPosition = .leading, size: HorizontalSizing = .totalWidth) -> Layout {
325+
Layout(.top(positon, size))
326+
}
327+
}
328+
*/

0 commit comments

Comments
 (0)