mirror of
https://github.com/samsonjs/ControlCenter_iOS.git
synced 2026-03-25 09:15:48 +00:00
49 lines
1.1 KiB
Swift
49 lines
1.1 KiB
Swift
//
|
|
// ControlBackground.swift
|
|
// ControlCenter_iOS
|
|
//
|
|
// Created by Sami Samhuri on 2020-06-25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ControlBackground<Content: View>: View {
|
|
let bgColor: Color
|
|
let radius: CGFloat
|
|
let opacity: Double
|
|
let content: Content
|
|
|
|
init(
|
|
bgColor: Color = Color(.secondarySystemGroupedBackground),
|
|
radius: CGFloat = 12,
|
|
opacity: Double = 0.8,
|
|
@ViewBuilder build: () -> Content
|
|
) {
|
|
self.bgColor = bgColor
|
|
self.radius = radius
|
|
self.opacity = opacity
|
|
self.content = build()
|
|
}
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
content.hidden().overlay(
|
|
RoundedRectangle(cornerRadius: radius, style: .continuous)
|
|
.foregroundColor(bgColor)
|
|
.opacity(opacity)
|
|
)
|
|
content
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ControlBackground_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
LightAndDarkPreviews {
|
|
ControlBackground {
|
|
Text("Hello")
|
|
.padding()
|
|
}
|
|
}
|
|
}
|
|
}
|