Skip to content

Add additional bridging. Remove Sendable conformances #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Sources/SkipUI/SkipUI/Animation/Animation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final class AnimationHolder {
}
#endif

public struct Animation : Hashable, Sendable {
public struct Animation : Hashable {
#if SKIP
/// The current active animation, whether from the environment via `animation` or from `withAnimation`.
@Composable static func current(isAnimating: Bool) -> Animation? {
Expand Down Expand Up @@ -392,7 +392,7 @@ public struct Animation : Hashable, Sendable {
}
}

public enum AnimationCompletionCriteria : Hashable, Sendable {
public enum AnimationCompletionCriteria : Hashable {
case logicallyComplete
case removed
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SkipUI/SkipUI/Animation/Spring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.compose.animation.core.SpringSpec
import androidx.compose.animation.core.TweenSpec
#endif

public struct Spring : Hashable, Sendable {
public struct Spring : Hashable {
#if SKIP
private let animationSpec: AnimationSpec<Any>

Expand Down Expand Up @@ -109,7 +109,7 @@ public struct Spring : Hashable, Sendable {
}
}

public enum SpringLoadingBehavior : Hashable, Sendable {
public enum SpringLoadingBehavior : Hashable {
case automatic
case enabled
case disabled
Expand Down
6 changes: 3 additions & 3 deletions Sources/SkipUI/SkipUI/Animation/Transition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extension Transition {
#endif
}

public struct ContentTransition : RawRepresentable, Equatable, Sendable {
public struct ContentTransition : RawRepresentable, Equatable {
public let rawValue: Int
public init(rawValue: Int) {
self.rawValue = rawValue
Expand Down Expand Up @@ -156,7 +156,7 @@ public struct AnyTransition {
}
}

public enum TransitionPhase: Hashable, Sendable {
public enum TransitionPhase: Hashable {
case willAppear
case identity
case didDisappear
Expand All @@ -177,7 +177,7 @@ public enum TransitionPhase: Hashable, Sendable {
}
}

public struct TransitionProperties : Sendable {
public struct TransitionProperties {
public let hasMotion: Bool

public init(hasMotion: Bool = true) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/SkipUI/SkipUI/App/Scene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public protocol Scene {

extension Scene {
@available(*, unavailable)
public func backgroundTask<D, R>(_ task: BackgroundTask<D, R>, action: @escaping @Sendable (D) async -> R) -> some Scene /* where D : Sendable, R : Sendable */ {
public func backgroundTask<D, R>(_ task: BackgroundTask<D, R>, action: @escaping (D) async -> R) -> some Scene /* where D : Sendable, R : Sendable */ {
return self
}

Expand Down Expand Up @@ -70,7 +70,7 @@ extension Scene {
}
}

public struct ScenePadding : Equatable, Sendable {
public struct ScenePadding : Equatable {
public static let minimum = ScenePadding()
}

Expand All @@ -86,7 +86,7 @@ extension View {
}
}

public enum ScenePhase : Int, Comparable, Hashable, Sendable {
public enum ScenePhase : Int, Comparable, Hashable {
case background
case inactive
case active
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/App/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public struct WindowGroup : Scene {
// }
}

public enum WindowResizability : Sendable {
public enum WindowResizability {
case automatic
case contentSize
case contentMinSize
Expand Down
7 changes: 6 additions & 1 deletion Sources/SkipUI/SkipUI/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct Color: ShapeStyle, Hashable {

// MARK: -

public enum RGBColorSpace : Hashable, Sendable {
public enum RGBColorSpace : Hashable {
case sRGB
case sRGBLinear
case displayP3
Expand Down Expand Up @@ -607,6 +607,11 @@ private struct ColorSet : Decodable {
let alpha: String?

var color: Color {
// Note that colors might be in the form of "0xAB" hex or non-decimal "255" numbers,
// corresponding to the "Input Method" menu in the Xcode colorset asset.
// These seem to be no metadata indicating the input method, other than looking at
// the value and seeing whether it starts with "0x" (hex) or contains a dot (float)
// See: https://github.com/skiptools/skip-ui/issues/146
let redValue = Double(red ?? "") ?? 0.0
let greenValue = Double(green ?? "") ?? 0.0
let blueValue = Double(blue ?? "") ?? 0.0
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Color/ColorRenderingMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
#if !SKIP_BRIDGE

public enum ColorRenderingMode : Hashable, Sendable {
public enum ColorRenderingMode : Hashable {
case nonLinear
case linear
case extendedLinear
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Color/ColorScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.platform.LocalContext
#endif

public enum ColorScheme : Int, CaseIterable, Hashable, Sendable {
public enum ColorScheme : Int, CaseIterable, Hashable {
case light = 0 // For bridging
case dark = 1 // For bridging

Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/DismissBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
#if !SKIP_BRIDGE

public enum DismissBehavior : Sendable {
public enum DismissBehavior {
case interactive
case destructive
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/EditActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if !SKIP_BRIDGE
import Foundation

public struct EditActions /* <Data> */ : OptionSet, Sendable {
public struct EditActions /* <Data> */ : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/EditMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
#if !SKIP_BRIDGE

public enum EditMode : Hashable, Sendable {
public enum EditMode : Hashable {
case inactive
case transient
case active
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public struct MenuActionDismissBehavior: RawRepresentable, Equatable {
public static let disabled = MenuActionDismissBehavior(rawValue: 1)
}

public struct MenuOrder: RawRepresentable, Equatable, Hashable, Sendable {
public struct MenuOrder: RawRepresentable, Equatable, Hashable {
public let rawValue: Int

public init(rawValue: Int) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SkipUI/SkipUI/Commands/Search.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension View {
}
}

public struct SearchFieldPlacement : RawRepresentable, Sendable {
public struct SearchFieldPlacement : RawRepresentable {
public let rawValue: Int

public init(rawValue: Int) {
Expand All @@ -92,7 +92,7 @@ public struct SearchFieldPlacement : RawRepresentable, Sendable {
return SearchFieldPlacement(rawValue: 4)
}

public enum NavigationBarDrawerDisplayMode : Sendable {
public enum NavigationBarDrawerDisplayMode {
case automatic
case always
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/SubmitLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import androidx.compose.ui.text.input.ImeAction
#endif

public enum SubmitLabel : Sendable {
public enum SubmitLabel {
case done
case go
case send
Expand Down
2 changes: 1 addition & 1 deletion Sources/SkipUI/SkipUI/Commands/SubmitTriggers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
#if !SKIP_BRIDGE

public struct SubmitTriggers : OptionSet, Sendable {
public struct SubmitTriggers : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/SkipUI/SkipUI/Commands/Toolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public struct ToolbarTitleMenu : CustomizableToolbarContent, View {
#endif
}

public enum ToolbarCustomizationBehavior : Sendable {
public enum ToolbarCustomizationBehavior {
case `default`
case reorderable
case disabled
Expand Down Expand Up @@ -137,7 +137,7 @@ public enum ToolbarPlacement: Equatable {
case tabBar
}

public enum ToolbarRole : Sendable {
public enum ToolbarRole {
case automatic
case navigationStack
case browser
Expand All @@ -151,7 +151,7 @@ public enum ToolbarTitleDisplayMode {
case inline
}

public struct ToolbarCustomizationOptions : OptionSet, Sendable {
public struct ToolbarCustomizationOptions : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
Expand Down
10 changes: 5 additions & 5 deletions Sources/SkipUI/SkipUI/Components/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public struct Image : View, Equatable {
fatalError()
}

public enum Interpolation : Hashable, Sendable {
public enum Interpolation : Hashable {
case none
case low
case medium
Expand All @@ -782,13 +782,13 @@ public struct Image : View, Equatable {
return self
}

public enum DynamicRange : Hashable, Sendable {
public enum DynamicRange : Hashable {
case standard
case constrainedHigh
case high
}

public enum TemplateRenderingMode : Hashable, Sendable {
public enum TemplateRenderingMode : Hashable {
case template
case original
}
Expand All @@ -798,7 +798,7 @@ public struct Image : View, Equatable {
return self
}

public enum Orientation : UInt8, CaseIterable, Hashable, Sendable {
public enum Orientation : UInt8, CaseIterable, Hashable {
case up
case upMirrored
case down
Expand All @@ -809,7 +809,7 @@ public struct Image : View, Equatable {
case rightMirrored
}

public enum Scale : Hashable, Sendable {
public enum Scale : Hashable {
case small
case medium
case large
Expand Down
10 changes: 8 additions & 2 deletions Sources/SkipUI/SkipUI/Containers/Form.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
import androidx.compose.runtime.Composable
#endif

// SKIP @bridge
public struct Form : View {
#if SKIP
// It appears that on iOS, List and Form render the same
let list: List

public init(@ViewBuilder content: () -> any View) {
list = List(content: content)
self.list = List(content: content)
}

// SKIP @bridge
public init(bridgedContent: any View) {
self.list = List(bridgedContent: bridgedContent)
}

#if SKIP
@Composable public override func ComposeContent(context: ComposeContext) {
let _ = list.Compose(context: context)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SkipUI/SkipUI/Containers/Grid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.ui.unit.dp
import struct CoreGraphics.CGFloat
#endif

public struct GridItem : Sendable {
public enum Size : Sendable {
public struct GridItem {
public enum Size {
case fixed(CGFloat)
case flexible(minimum: CGFloat = 10.0, maximum: CGFloat = .infinity)
case adaptive(minimum: CGFloat, maximum: CGFloat = .infinity)
Expand Down
34 changes: 23 additions & 11 deletions Sources/SkipUI/SkipUI/Containers/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -732,39 +732,40 @@ public struct ListStyle: RawRepresentable, Equatable {
self.rawValue = rawValue
}

public static let automatic = ListStyle(rawValue: 0)
public static let automatic = ListStyle(rawValue: 0) // For bridging

@available(*, unavailable)
public static let sidebar = ListStyle(rawValue: 1)
public static let sidebar = ListStyle(rawValue: 1) // For bridging

@available(*, unavailable)
public static let insetGrouped = ListStyle(rawValue: 2)
public static let insetGrouped = ListStyle(rawValue: 2) // For bridging

@available(*, unavailable)
public static let grouped = ListStyle(rawValue: 3)
public static let grouped = ListStyle(rawValue: 3) // For bridging

@available(*, unavailable)
public static let inset = ListStyle(rawValue: 4)
public static let inset = ListStyle(rawValue: 4) // For bridging

public static let plain = ListStyle(rawValue: 5)
public static let plain = ListStyle(rawValue: 5) // For bridging
}

public enum ListItemTint : Sendable {
public enum ListItemTint {
case fixed(Color)
case preferred(Color)
case monochrome
}

public enum ListSectionSpacing : Sendable {
public enum ListSectionSpacing {
case `default`
case compact
case custom(CGFloat)
}

extension View {
public func listRowBackground(_ view: Any?) -> some View {
// SKIP @bridge
public func listRowBackground(_ view: (any View)?) -> any View {
#if SKIP
return ListItemModifierView(view: self, background: view as! View?)
return ListItemModifierView(view: self, background: view)
#else
return self
#endif
Expand All @@ -778,6 +779,11 @@ extension View {
#endif
}

// SKIP @bridge
public func listRowSeparator(bridgedVisibility: Int, bridgedEdges: Int) -> any View {
return listRowSeparator(Visibility(rawValue: bridgedVisibility) ?? .automatic, edges: VerticalEdge.Set(rawValue: bridgedEdges))
}

@available(*, unavailable)
public func listRowSeparatorTint(_ color: Color?, edges: VerticalEdge.Set = .all) -> some View {
return self
Expand All @@ -801,7 +807,13 @@ extension View {
#endif
}

public func listItemTint(_ tint: Color?) -> some View {
// SKIP @bridge
public func listStyle(bridgedStyle: Int) -> any View {
return listStyle(ListStyle(rawValue: bridgedStyle))
}

// SKIP @bridge
public func listItemTint(_ tint: Color?) -> any View {
#if SKIP
return environment(\._listItemTint, tint)
#else
Expand Down
Loading
Loading