stevengharris / SplitView

A flexible way to split SwiftUI views with a draggable splitter
MIT License
146 stars 17 forks source link

Fix the onChange(of:perform:) deprecation warnings #41

Open serge-ivamov opened 3 weeks ago

serge-ivamov commented 3 weeks ago

Split.swift:

*** Split.swift-old 2024-10-09 14:50:59.622048883 +0400
--- Split.swift-new 2024-10-09 16:00:36.372341071 +0400
***************
*** 99,105 ****
              }
              .clipped()  // Can cause problems in some List styles if not clipped
              .environmentObject(layout)
!             .onChange(of: fraction.value) { new in constrainedFraction = new }
          }
      }

--- 99,105 ----
              }
              .clipped()  // Can cause problems in some List styles if not clipped
              .environmentObject(layout)
!             .onChange(of: fraction.value) { constrainedFraction = fraction.value }
          }
      }

Splitter.swift:

*** Splitter.swift-old  2024-10-09 14:50:59.624959091 +0400
--- Splitter.swift-new  2024-10-09 16:00:42.523829954 +0400
***************
*** 68,75 ****
          // hidden when the side is hidden (styling.hideSplitter is true), then set the
          // splitter color to clear. When the splitter is actually hidden, it doesn't even
          // exist, but when previewing it does, so we have to make it invisible this way.
!         .onChange(of: styling.previewHide) { hide in
!             if hide {
                  dividerColor = styling.hideSplitter ? .clear : privateColor ?? color
              } else {
                  dividerColor = privateColor ?? color
--- 68,75 ----
          // hidden when the side is hidden (styling.hideSplitter is true), then set the
          // splitter color to clear. When the splitter is actually hidden, it doesn't even
          // exist, but when previewing it does, so we have to make it invisible this way.
!         .onChange(of: styling.previewHide) {
!             if styling.previewHide {
                  dividerColor = styling.hideSplitter ? .clear : privateColor ?? color
              } else {
                  dividerColor = privateColor ?? color