Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
fail-fast: false
matrix:
include:
- swift: "5"
xcode: "26.2"
runs-on: macos-15
- swift: "5"
xcode: "16.4"
runs-on: macos-15
Expand All @@ -37,8 +40,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: "26.0.1"
xcode: "26.0.1"
- os: "26.2"
xcode: "26.2"
sim: "iPhone 16 Pro"
parallel: NO # Stop random test job failures
runs-on: macos-15
Expand Down Expand Up @@ -66,7 +69,7 @@ jobs:
example:
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer
strategy:
fail-fast: false
matrix:
Expand All @@ -93,21 +96,21 @@ jobs:
strategy:
fail-fast: false
matrix:
xcode: ["26.0.1", "16.4", "15.4"]
xcode: ["26.2", "16.4", "15.4"]
platform: [iphoneos, iphonesimulator]
arch: [x86_64, arm64]
exclude:
- platform: iphoneos
arch: x86_64
include:
# 26.0.1
# 26.x
- platform: iphoneos
xcode: "26.0.1"
sys: "ios26.0"
xcode: "26.2"
sys: "ios26.2"
runs-on: macos-15
- platform: iphonesimulator
xcode: "26.0.1"
sys: "ios26.0-simulator"
xcode: "26.2"
sys: "ios26.2-simulator"
runs-on: macos-15
# 18.5
- platform: iphoneos
Expand Down Expand Up @@ -138,7 +141,7 @@ jobs:
cocoapods:
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_26.0.1.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- name: "CocoaPods: pod lib lint"
Expand Down
24 changes: 22 additions & 2 deletions Examples/SamplesSwiftUI/SamplesSwiftUI/UseCases/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct MainView: View {
@State private var panelLayout: FloatingPanelLayout? = MyFloatingPanelLayout()
@State private var panelState: FloatingPanelState?
@State private var selectedContent: CardContent = .list
@State private var lastEvent: MyPanelCoordinator.Event?

var body: some View {
ZStack {
Expand All @@ -28,6 +29,9 @@ struct MainView: View {
}
}
.pickerStyle(.segmented)

Text("Last event: \(lastEvent?.rawValue ?? "None")")

Button("Move to full") {
withAnimation(.interactiveSpring) {
panelState = .full
Expand All @@ -52,7 +56,8 @@ struct MainView: View {
}
}
.floatingPanel(
coordinator: MyPanelCoordinator.self
coordinator: MyPanelCoordinator.self,
onEvent: onEvent
) { proxy in
switch selectedContent {
case .list:
Expand Down Expand Up @@ -80,11 +85,18 @@ struct MainView: View {
Logger().debug("Panel state changed: \(newValue ?? .hidden)")
}
}

func onEvent(_ event: MyPanelCoordinator.Event) {
lastEvent = event
}
}

// A custom coordinator object which handles panel context updates and setting up `FloatingPanelControllerDelegate` methods
class MyPanelCoordinator: FloatingPanelCoordinator {
enum Event {}
enum Event: String {
case willBeginDragging
case didEndAttracting
}

let action: (Event) -> Void
let proxy: FloatingPanelProxy
Expand Down Expand Up @@ -115,6 +127,14 @@ class MyPanelCoordinator: FloatingPanelCoordinator {
}

extension MyPanelCoordinator: FloatingPanelControllerDelegate {
func floatingPanelWillBeginDragging(_ fpc: FloatingPanelController) {
action(.willBeginDragging)
}

func floatingPanelDidEndAttracting(_ fpc: FloatingPanelController) {
action(.didEndAttracting)
}

func floatingPanelDidChangeState(_ fpc: FloatingPanelController) {
// NOTE: This timing is difference from one of the change of the binding value
// to `floatingPanelState(_:)` modifier
Expand Down
12 changes: 12 additions & 0 deletions FloatingPanel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
5404FC6D2F3D900E00BCC99B /* CoordinatorProxyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5404FC6B2F3D900E00BCC99B /* CoordinatorProxyTests.swift */; };
542753C622C49A6E00D17955 /* LayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 542753C522C49A6E00D17955 /* LayoutTests.swift */; };
5431025B2DB8AAB800A927EF /* View+floatingPanelSurface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 543102592DB8AAB800A927EF /* View+floatingPanelSurface.swift */; };
5431025E2DB8AAB800A927EF /* View+floatingPanelConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 543102572DB8AAB800A927EF /* View+floatingPanelConfiguration.swift */; };
Expand Down Expand Up @@ -58,6 +59,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
5404FC6B2F3D900E00BCC99B /* CoordinatorProxyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinatorProxyTests.swift; sourceTree = "<group>"; };
542753C522C49A6E00D17955 /* LayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutTests.swift; sourceTree = "<group>"; };
542753C722C49A8F00D17955 /* TestSupports.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSupports.swift; sourceTree = "<group>"; };
543102572DB8AAB800A927EF /* View+floatingPanelConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+floatingPanelConfiguration.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -121,6 +123,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5404FC6C2F3D900E00BCC99B /* SwiftUI */ = {
isa = PBXGroup;
children = (
5404FC6B2F3D900E00BCC99B /* CoordinatorProxyTests.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
};
545DB9B72151169500CA77B8 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -169,6 +179,7 @@
545DB9CE2151169500CA77B8 /* Tests */ = {
isa = PBXGroup;
children = (
5404FC6C2F3D900E00BCC99B /* SwiftUI */,
54A6B6B022968B530077F348 /* CoreTests.swift */,
545DB9CF2151169500CA77B8 /* ControllerTests.swift */,
547F7A9B2A6E946000303905 /* GestureTests.swift */,
Expand Down Expand Up @@ -363,6 +374,7 @@
542753C622C49A6E00D17955 /* LayoutTests.swift in Sources */,
54A6B6B82296A8520077F348 /* SurfaceViewTests.swift in Sources */,
546055BF2333C4740069F400 /* TestSupports.swift in Sources */,
5404FC6D2F3D900E00BCC99B /* CoordinatorProxyTests.swift in Sources */,
547F7A9C2A6E946000303905 /* GestureTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 9 additions & 1 deletion Sources/SwiftUI/FloatingPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ extension FloatingPanelView {
class FloatingPanelCoordinatorProxy {
private let origin: any FloatingPanelCoordinator
private var stateBinding: Binding<FloatingPanelState?>
/// Tracks the last binding value seen by `update(state:)` to detect actual changes
/// vs. stale values from unrelated SwiftUI re-renders.
private var lastKnownBindingState: FloatingPanelState?

private var subscriptions: Set<AnyCancellable> = Set()

Expand Down Expand Up @@ -249,7 +252,12 @@ extension FloatingPanelCoordinatorProxy {

// Update the state of FloatingPanelController
func update(state: FloatingPanelState?) {
guard let state = state else { return }
defer { lastKnownBindingState = state }
guard
let state = state,
state != lastKnownBindingState,
controller.state != state
else { return }
controller.move(to: state, animated: false)
}

Expand Down
Loading