File tree Expand file tree Collapse file tree 3 files changed +17
-16
lines changed
Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -82,16 +82,6 @@ extension CGPath {
8282
8383// MARK: - Helper Functions
8484
85- /// Limits the precision of a CGFloat to a specified number of decimal places.
86- /// - Parameters:
87- /// - value: The CGFloat value to limit.
88- /// - places: The number of decimal places to retain.
89- /// - Returns: A CGFloat rounded to the specified number of decimal places.
90- private func limitPrecision( _ value: CGFloat , toDecimalPlaces places: Int ) -> CGFloat {
91- let multiplier = pow ( 10.0 , CGFloat ( places) )
92- return ( value * multiplier) . rounded ( ) / multiplier
93- }
94-
9585/// Creates a CGVector from two CGPoints.
9686/// - Parameters:
9787/// - from: The starting CGPoint.
Original file line number Diff line number Diff line change @@ -37,15 +37,26 @@ private enum FrameListModifier<ID>: ViewModifier where ID: Hashable {
3737}
3838
3939extension View {
40- func frames< ID> ( _ value: Binding < [ ID : CGRect ] > ) -> some View where ID: Hashable {
40+
41+ /// A modifier which observes changes to view frames with corresponding IDs
42+ /// - Parameter value: a binding to a dictionary of IDs to frame rectangle
43+ /// - Returns: a View
44+ public func frames< ID> ( _ value: Binding < [ ID : CGRect ] > ) -> some View where ID: Hashable {
4145 readFrames { value. wrappedValue = $0 }
4246 }
4347
44- func writeFrame< ID> ( id: ID , coordinates: CoordinateSpace ) -> some View where ID: Hashable {
48+ /// A modifier which writes changes to the current view's frame with corresponding `id`
49+ /// - Parameter id: the current view's corresponding ID
50+ /// - Parameter coordinates: the coordinate space in which the frame is expressed
51+ /// - Returns: a View
52+ public func writeFrame< ID> ( id: ID , coordinates: CoordinateSpace ) -> some View where ID: Hashable {
4553 self . modifier ( FrameListModifier< ID> . writer( id: id, coordinates: coordinates) )
4654 }
4755
48- func readFrames< ID> ( onChange: @escaping ( [ ID : CGRect ] ) -> ( ) ) -> some View where ID: Hashable {
56+ /// A modifier which reads changes to view frames with corresponding IDs
57+ /// - Parameter value: a binding to a dictionary of IDs to frame rectangle
58+ /// - Returns: a View
59+ public func readFrames< ID> ( onChange: @escaping ( [ ID : CGRect ] ) -> ( ) ) -> some View where ID: Hashable {
4960 self . modifier ( FrameListModifier< ID> . reader( onChange: onChange) )
5061 }
5162}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ private struct FrameModifier: ViewModifier {
3636
3737extension View {
3838
39- /// An extension whose `value` tracks the enclosed view's bounding rectangle in `coordinates`
39+ /// A modifier whose `value` tracks the enclosed view's bounding rectangle in `coordinates`
4040 /// - Parameters:
4141 /// - value: a `CGRect` binding
4242 /// - coordinates: a coordinate space
@@ -47,7 +47,7 @@ extension View {
4747 } )
4848 }
4949
50- /// An extension whose `value` tracks the enclosed view's size in `coordinates`
50+ /// A modifier whose `value` tracks the enclosed view's size in `coordinates`
5151 /// - Parameters:
5252 /// - value: a `CGSize` binding
5353 /// - coordinates: a coordinate space
@@ -58,7 +58,7 @@ extension View {
5858 } )
5959 }
6060
61- /// An extension whose `value` tracks the enclosed view's origin in `coordinates`
61+ /// A modifier whose `value` tracks the enclosed view's origin in `coordinates`
6262 /// - Parameters:
6363 /// - value: a `CGPoint` binding
6464 /// - coordinates: a coordinate space
You can’t perform that action at this time.
0 commit comments