Unify card background styles
This commit is contained in:
@@ -56,3 +56,42 @@ public extension View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public extension View {
|
||||||
|
@ViewBuilder
|
||||||
|
func cardStyle() -> some View {
|
||||||
|
modifier(CardStyleModifier())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct CardStyleModifier: ViewModifier {
|
||||||
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
|
|
||||||
|
func body(content: Content) -> some View {
|
||||||
|
if #available(iOS 26.0, macOS 26.0, tvOS 26.0, *) {
|
||||||
|
content
|
||||||
|
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
|
||||||
|
} else {
|
||||||
|
content
|
||||||
|
.background(backgroundColor)
|
||||||
|
.cornerRadius(16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var backgroundColor: Color {
|
||||||
|
#if os(iOS)
|
||||||
|
return Color(uiColor: .secondarySystemGroupedBackground)
|
||||||
|
#elseif os(macOS)
|
||||||
|
return Color(nsColor: .textBackgroundColor)
|
||||||
|
#elseif os(tvOS)
|
||||||
|
switch colorScheme {
|
||||||
|
case .dark:
|
||||||
|
return Color(uiColor: .black)
|
||||||
|
default:
|
||||||
|
return Color(uiColor: .white)
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return Color.clear
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,9 +76,8 @@ public struct ConnectionView: View {
|
|||||||
}
|
}
|
||||||
.foregroundColor(.textColor)
|
.foregroundColor(.textColor)
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
.padding(EdgeInsets(top: 10, leading: 13, bottom: 10, trailing: 13))
|
.padding(16)
|
||||||
.background(backgroundColor)
|
.cardStyle()
|
||||||
.cornerRadius(10)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
.background(.clear)
|
.background(.clear)
|
||||||
@@ -99,16 +98,6 @@ public struct ConnectionView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var backgroundColor: Color {
|
|
||||||
#if os(iOS)
|
|
||||||
return Color(uiColor: .secondarySystemGroupedBackground)
|
|
||||||
#elseif os(macOS)
|
|
||||||
return Color(nsColor: .textBackgroundColor)
|
|
||||||
#elseif os(tvOS)
|
|
||||||
return Color.black
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private nonisolated func closeConnection() async {
|
private nonisolated func closeConnection() async {
|
||||||
do {
|
do {
|
||||||
try await LibboxNewStandaloneCommandClient()!.closeConnection(connection.id)
|
try await LibboxNewStandaloneCommandClient()!.closeConnection(connection.id)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public struct DashboardCardView<Content: View>: View {
|
public struct DashboardCardView<Content: View>: View {
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
|
||||||
|
|
||||||
private let title: String
|
private let title: String
|
||||||
private let isHalfWidth: Bool
|
private let isHalfWidth: Bool
|
||||||
@ViewBuilder private let content: () -> Content
|
@ViewBuilder private let content: () -> Content
|
||||||
@@ -26,40 +24,8 @@ public struct DashboardCardView<Content: View>: View {
|
|||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.padding(EdgeInsets(top: 20, leading: 26, bottom: 20, trailing: 26))
|
.padding(EdgeInsets(top: 20, leading: 26, bottom: 20, trailing: 26))
|
||||||
#else
|
#else
|
||||||
.padding(EdgeInsets(top: 16, leading: 16, bottom: 16, trailing: 16))
|
.padding(16)
|
||||||
#endif
|
|
||||||
.modifier(CardStyleModifier(colorScheme: colorScheme))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct CardStyleModifier: ViewModifier {
|
|
||||||
let colorScheme: ColorScheme
|
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
|
||||||
if #available(iOS 26.0, macOS 26.0, tvOS 26.0, *) {
|
|
||||||
content
|
|
||||||
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
|
|
||||||
} else {
|
|
||||||
content
|
|
||||||
.background(backgroundColor)
|
|
||||||
.cornerRadius(16)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var backgroundColor: Color {
|
|
||||||
#if os(iOS)
|
|
||||||
return Color(uiColor: .secondarySystemGroupedBackground)
|
|
||||||
#elseif os(macOS)
|
|
||||||
return Color(nsColor: .textBackgroundColor)
|
|
||||||
#elseif os(tvOS)
|
|
||||||
switch colorScheme {
|
|
||||||
case .dark:
|
|
||||||
return Color(uiColor: .black)
|
|
||||||
default:
|
|
||||||
return Color(uiColor: .white)
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return Color.clear
|
|
||||||
#endif
|
#endif
|
||||||
|
.cardStyle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,8 +183,12 @@ struct ProfilePickerSheet: View {
|
|||||||
List {
|
List {
|
||||||
ForEach(profileList, id: \.id) { profile in
|
ForEach(profileList, id: \.id) { profile in
|
||||||
macOSProfileRow(profile)
|
macOSProfileRow(profile)
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
|
.listRowInsets(EdgeInsets(top: 6, leading: 16, bottom: 6, trailing: 16))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.listStyle(.plain)
|
||||||
#else
|
#else
|
||||||
List {
|
List {
|
||||||
ForEach(profileList, id: \.id) { profile in
|
ForEach(profileList, id: \.id) { profile in
|
||||||
@@ -204,10 +208,14 @@ struct ProfilePickerSheet: View {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.environmentObject(environments)
|
.environmentObject(environments)
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
|
.listRowInsets(EdgeInsets(top: 6, leading: 16, bottom: 6, trailing: 16))
|
||||||
}
|
}
|
||||||
.onMove(perform: moveProfile)
|
.onMove(perform: moveProfile)
|
||||||
.onDelete(perform: deleteProfile)
|
.onDelete(perform: deleteProfile)
|
||||||
}
|
}
|
||||||
|
.listStyle(.plain)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,6 +631,8 @@ private struct ProfilePickerRow: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
|
.padding(16)
|
||||||
|
.cardStyle()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -57,23 +57,8 @@ public struct GroupItemView: View {
|
|||||||
}
|
}
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
.buttonStyle(.borderless)
|
.buttonStyle(.borderless)
|
||||||
.padding(EdgeInsets(top: 10, leading: 13, bottom: 10, trailing: 13))
|
.padding(16)
|
||||||
.background(backgroundColor)
|
.cardStyle()
|
||||||
.cornerRadius(10)
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: 10)
|
|
||||||
.stroke(Color.gray.opacity(0.3), lineWidth: 1)
|
|
||||||
)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private var backgroundColor: Color {
|
|
||||||
#if os(iOS)
|
|
||||||
return Color(uiColor: .secondarySystemGroupedBackground)
|
|
||||||
#elseif os(macOS)
|
|
||||||
return Color(nsColor: .textBackgroundColor)
|
|
||||||
#elseif os(tvOS)
|
|
||||||
return Color.black
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user