Files
letro-ios/compound-ios/Inspector/Sources/Tokens/GradientsScreen.swift
renovate[bot] aafb467e85 Update dependency element-hq/compound-design-tokens to v6.10.1 (#5123)
* Update dependency element-hq/compound-design-tokens to v6.10.0

* Further Compound updates.

The gradients have been simplified and are now opaque.

* Missed snapshots.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Doug <douglase@element.io>
2026-02-25 21:45:10 +00:00

65 lines
1.7 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Compound
import SwiftUI
struct GradientsScreen: View {
var body: some View {
ScreenContent(navigationTitle: "Gradients") {
// allValues isn't currently working as gradients use computed properties
// in order for them to work with colour overrides.
ForEach(Gradient.compound.allValues, id: \.name) { gradient in
GradientItem(gradient: gradient.value, name: gradient.name)
}
}
}
}
struct GradientItem: View {
let gradient: Gradient
let name: String
var body: some View {
HStack {
swatch
VStack(alignment: .leading) {
Text(name)
.font(.compound.bodyLG)
.foregroundColor(.compound.textPrimary)
}
}
}
var swatch: some View {
swatchShape
.foregroundStyle(gradient)
.frame(height: 40)
.aspectRatio(1, contentMode: .fit)
.overlay {
swatchShape
.strokeBorder(Color.compound.iconPrimary, lineWidth: 1.5)
.opacity(0.2)
}
}
var swatchShape: some InsettableShape {
RoundedRectangle(cornerRadius: 12, style: .continuous)
}
}
struct GradientsScreen_Previews: PreviewProvider {
static var previews: some View {
NavigationStack {
ColorsScreen()
}
.previewLayout(.fixed(width: 375, height: 700))
}
}