diff --git a/Sources/Spatial/align/AlignType/AlignType.swift b/Sources/Spatial/align/AlignType/AlignType.swift index 418ec58..27b2920 100644 --- a/Sources/Spatial/align/AlignType/AlignType.swift +++ b/Sources/Spatial/align/AlignType/AlignType.swift @@ -1,9 +1,14 @@ import Foundation /** - * Single align type - * - Remark: Use `.rawValue` if you want to get the string "topLeft" - * - Remark: Could also just do: no type enum and: `Swift.print("\(String(describing: TestEnum.three))") // three + * Enum defining single alignment types. + * Use `.rawValue` to get the string representation of the enum case. + * Alternatively, you can use a no-type enum and print the case name directly. */ public enum AlignType: String { - case left, right, top, bottom, centerHor, centerVer -} + case left // Aligns to the left + case right // Aligns to the right + case top // Aligns to the top + case bottom // Aligns to the bottom + case centerHor // Aligns to the horizontal center + case centerVer // Aligns to the vertical center +} \ No newline at end of file diff --git a/Sources/Spatial/align/alignment/Alignment+Extension.swift b/Sources/Spatial/align/alignment/Alignment+Extension.swift index 42f0942..78b5c97 100644 --- a/Sources/Spatial/align/alignment/Alignment+Extension.swift +++ b/Sources/Spatial/align/alignment/Alignment+Extension.swift @@ -1,25 +1,31 @@ import Foundation /** - * Extension + * Extension to `Alignment` enum to provide computed properties for horizontal and vertical alignment types. */ extension Alignment { /** - * - Returns the horizontal type from the dual-axis type `Alignment` + * Returns the horizontal alignment type from the dual-axis alignment type `Alignment`. */ public var horAlign: HorizontalAlign { switch self { + // If the alignment is top left, center left, or bottom left, return left alignment case .topLeft, .centerLeft, .bottomLeft: return .left + // If the alignment is top right, center right, or bottom right, return right alignment case .topRight, .bottomRight, .centerRight: return .right - case .bottomCenter, .topCenter, .centerCenter: return .centerX + // If the alignment is top center, bottom center, or center center, return center X alignment + case .topCenter, .bottomCenter, .centerCenter: return .centerX } } /** - * - Returns the vertical type from the dual-axis type `Alignment` + * Returns the vertical alignment type from the dual-axis alignment type `Alignment`. */ public var verAlign: VerticalAlign { switch self { - case .topRight, .topCenter, .topLeft: return .top - case .bottomCenter, .bottomRight, .bottomLeft: return .bottom + // If the alignment is top left, top center, or top right, return top alignment + case .topLeft, .topCenter, .topRight: return .top + // If the alignment is bottom left, bottom center, or bottom right, return bottom alignment + case .bottomLeft, .bottomCenter, .bottomRight: return .bottom + // If the alignment is center left, center right, or center center, return center Y alignment case .centerRight, .centerLeft, .centerCenter: return .centerY } } diff --git a/Sources/Spatial/align/alignment/Alignment.swift b/Sources/Spatial/align/alignment/Alignment.swift index d1402b6..b98831f 100755 --- a/Sources/Spatial/align/alignment/Alignment.swift +++ b/Sources/Spatial/align/alignment/Alignment.swift @@ -1,8 +1,7 @@ import Foundation - /** - * Alignment types (Both axises) - * - Remark: Use `Alignment.topLeft.rawValue if you want to get the string "topLeft" + * Enum defining alignment types for both horizontal and vertical axises. + * Use `Alignment.topLeft.rawValue` to get the string "topLeft". */ public enum Alignment: String { case topLeft // Aligns to the top left corner diff --git a/Tests/SpatialTests/SpatialTests.swift b/Tests/SpatialTests/SpatialTests.swift index a1df444..362040b 100644 --- a/Tests/SpatialTests/SpatialTests.swift +++ b/Tests/SpatialTests/SpatialTests.swift @@ -22,4 +22,5 @@ extension SpatialTests { XCTAssertTrue(equalsB) } } -#endif \ No newline at end of file +#endif +