From 0d00510ac44726f9ff596d1d9da9952fcc10dd88 Mon Sep 17 00:00:00 2001 From: Abe White Date: Mon, 2 Oct 2023 21:50:01 -0500 Subject: [PATCH] Use material3 components that more closely align with SwiftUI. Fixes in applying foreground and tint color --- Sources/SkipUI/SkipUI/Color/Color.swift | 5 +++-- .../SkipUI/Compose/ComposeContext.swift | 9 ++++++++ Sources/SkipUI/SkipUI/Containers/List.swift | 2 +- Sources/SkipUI/SkipUI/Controls/Button.swift | 19 +++++++++++----- .../SkipUI/SkipUI/Controls/TextField.swift | 22 ++++++++++++++----- Sources/SkipUI/SkipUI/Controls/Toggle.swift | 3 ++- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Sources/SkipUI/SkipUI/Color/Color.swift b/Sources/SkipUI/SkipUI/Color/Color.swift index d3105c8b..e7b8c924 100644 --- a/Sources/SkipUI/SkipUI/Color/Color.swift +++ b/Sources/SkipUI/SkipUI/Color/Color.swift @@ -6,6 +6,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box +import androidx.compose.material.ContentAlpha import androidx.compose.material3.MaterialTheme import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable @@ -148,11 +149,11 @@ public struct Color: View, Hashable, Sendable { }) public static let primary = Color(colorImpl: { - MaterialTheme.colorScheme.onPrimary + MaterialTheme.colorScheme.onBackground }) public static let secondary = Color(colorImpl: { - MaterialTheme.colorScheme.onSecondary + MaterialTheme.colorScheme.onBackground.copy(alpha: ContentAlpha.medium) }) static let systemBackground = Color(colorImpl: { diff --git a/Sources/SkipUI/SkipUI/Compose/ComposeContext.swift b/Sources/SkipUI/SkipUI/Compose/ComposeContext.swift index a505fae9..550f5057 100644 --- a/Sources/SkipUI/SkipUI/Compose/ComposeContext.swift +++ b/Sources/SkipUI/SkipUI/Compose/ComposeContext.swift @@ -29,4 +29,13 @@ public struct ComposeContext { return context } } + +/// Mechanism for a parent view to change how a child view is composed. +//public protocol Composer { +// @Composable public func compose(view: inout View, context: ComposeContext) +//} +// +//extension Composer { +// +//} #endif diff --git a/Sources/SkipUI/SkipUI/Containers/List.swift b/Sources/SkipUI/SkipUI/Containers/List.swift index 75296995..56ca1bad 100644 --- a/Sources/SkipUI/SkipUI/Containers/List.swift +++ b/Sources/SkipUI/SkipUI/Containers/List.swift @@ -112,7 +112,7 @@ public struct List : View where SelectionValue: Hashabl private static let verticalInset = 32.0 private static let minimumItemHeight = 44.0 private static let horizontalItemInset = 16.0 - private static let verticalItemInset = 8.0 + private static let verticalItemInset = 4.0 @Composable private func ComposeItem(view: inout View, context: ComposeContext, style: ListStyle) { let contentModifier = Modifier.padding(horizontal: Self.horizontalItemInset.dp, vertical: Self.verticalItemInset.dp).fillWidth().requiredHeightIn(min: Self.minimumItemHeight.dp) diff --git a/Sources/SkipUI/SkipUI/Controls/Button.swift b/Sources/SkipUI/SkipUI/Controls/Button.swift index 9f72fd7d..3b0e9c48 100644 --- a/Sources/SkipUI/SkipUI/Controls/Button.swift +++ b/Sources/SkipUI/SkipUI/Controls/Button.swift @@ -5,13 +5,10 @@ #if SKIP import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.material.ContentAlpha import androidx.compose.material3.ButtonColors import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.FilledTonalButton -import androidx.compose.material3.LocalTextStyle -import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp @@ -58,12 +55,24 @@ public struct Button