Skip to content

Commit

Permalink
Use less extensions. Their symbols are less efficient to process
Browse files Browse the repository at this point in the history
  • Loading branch information
aabewhite committed Sep 21, 2023
1 parent 9ab111b commit 3e07c72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
32 changes: 14 additions & 18 deletions Sources/SkipUI/SkipUI/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public struct Color: View, Hashable, Sendable {
fatalError()
}
#endif
}

extension Color {
// MARK: -

public enum RGBColorSpace : Hashable, Sendable {
case sRGB
case sRGBLinear
Expand Down Expand Up @@ -91,9 +91,9 @@ extension Color {
colorImpl = { androidx.compose.ui.graphics.Color.hsl(hue: Float(hue), saturation: Float(saturation), lightness: Float(brightness), alpha: Float(opacity)) }
#endif
}
}

extension Color {
// MARK: -

public struct Resolved : Hashable {
public var red: Float
public var green: Float
Expand Down Expand Up @@ -121,20 +121,18 @@ extension Color {
public init(_ resolved: Color.Resolved) {
self.init(red: Double(resolved.red), green: Double(resolved.green), blue: Double(resolved.blue), opacity: Double(resolved.opacity))
}
}

extension Color {
// MARK: -

public static var accentColor: Color {
#if SKIP
return Color(colorImpl: { MaterialTheme.colorScheme.primary })
#else
fatalError()
#endif
}
}

#if SKIP
extension Color {
#if SKIP
public static let clear = Color(colorImpl: {
androidx.compose.ui.graphics.Color.Transparent
})
Expand Down Expand Up @@ -200,28 +198,26 @@ extension Color {
public static let brown = Color(colorImpl: {
color(light: 0xFFA2845E, dark: 0xFFAC8E68)
})
}
#endif
#endif

// MARK: -

extension Color {
@available(*, unavailable)
public init(_ name: String, bundle: Any? = nil /* Bundle? = nil */) {
#if SKIP
colorImpl = { androidx.compose.ui.graphics.Color.White }
#endif
}
}

extension Color {
@available(*, unavailable)
public init(uiColor: Any /* UIColor */) {
#if SKIP
colorImpl = { androidx.compose.ui.graphics.Color.White }
#endif
}
}

extension Color {
// MARK: -

public func opacity(_ opacity: Double) -> Color {
#if SKIP
return Color(colorImpl: {
Expand All @@ -232,9 +228,9 @@ extension Color {
return self
#endif
}
}

extension Color {
// MARK: -

@available(*, unavailable)
public var gradient: Any /* AnyGradient */ {
fatalError()
Expand Down
12 changes: 6 additions & 6 deletions Sources/SkipUI/SkipUI/Containers/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ public struct List<SelectionValue, Content> : View where SelectionValue: Hashabl
stubView()
}
#endif

// MARK: -

public init(_ data: Range<Int>, @ViewBuilder rowContent: @escaping (Int) -> Content) {
self.init(indexRange: data, indexedContent: rowContent)
}
}

/// Adopted by views that adapt when used as a list item.
Expand All @@ -173,12 +179,6 @@ protocol ListItemAdapting {
#endif
}

extension List {
public init(_ data: Range<Int>, @ViewBuilder rowContent: @escaping (Int) -> Content) {
self.init(indexRange: data, indexedContent: rowContent)
}
}

// Kotlin does not support generic constructor parameters, so we have to model many List constructors as functions

#if SKIP
Expand Down

0 comments on commit 3e07c72

Please sign in to comment.