2021-09-14 21:38:12 -07:00
|
|
|
/*
|
|
|
|
|
Abstract:
|
2021-09-18 15:33:35 -07:00
|
|
|
A view draws a circle in the background of the shortName text
|
2021-09-14 21:38:12 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
struct CircleText: View {
|
|
|
|
|
var text: String
|
2021-09-18 15:33:35 -07:00
|
|
|
var color: Color
|
2022-06-13 14:39:21 -07:00
|
|
|
var circleSize: CGFloat? = 60
|
2022-06-13 18:54:16 -07:00
|
|
|
var fontSize: CGFloat? = 20
|
2022-11-20 16:37:37 -08:00
|
|
|
var brightness: Double? = 0
|
2023-03-31 12:08:42 -07:00
|
|
|
var textColor: Color? = .white
|
2021-09-14 21:38:12 -07:00
|
|
|
|
|
|
|
|
var body: some View {
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2022-01-02 10:05:13 -08:00
|
|
|
let font = Font.system(size: fontSize!)
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2021-09-24 00:39:36 -07:00
|
|
|
ZStack {
|
|
|
|
|
Circle()
|
|
|
|
|
.fill(color)
|
2022-11-20 16:37:37 -08:00
|
|
|
.brightness(brightness ?? 0)
|
2022-01-02 10:05:13 -08:00
|
|
|
.frame(width: circleSize, height: circleSize)
|
2023-03-31 12:08:42 -07:00
|
|
|
Text(text).textCase(.uppercase).font(font).foregroundColor(textColor).fixedSize()
|
2022-01-02 10:05:13 -08:00
|
|
|
.frame(width: circleSize, height: circleSize, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/).offset(x: 0, y: 0)
|
2021-09-24 00:39:36 -07:00
|
|
|
}
|
2021-09-14 21:38:12 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CircleText_Previews: PreviewProvider {
|
|
|
|
|
static var previews: some View {
|
2022-06-15 16:49:51 -07:00
|
|
|
CircleText(text: "RDDN", color: Color.accentColor)
|
2021-09-18 17:10:22 -07:00
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
2021-09-14 21:38:12 -07:00
|
|
|
}
|
|
|
|
|
}
|