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
|
2023-09-02 09:23:20 -07:00
|
|
|
var circleSize: CGFloat = 45
|
2023-09-01 00:22:30 -07:00
|
|
|
|
2021-09-14 21:38:12 -07:00
|
|
|
var body: some View {
|
2023-03-06 10:33:18 -08:00
|
|
|
|
2021-09-24 00:39:36 -07:00
|
|
|
ZStack {
|
|
|
|
|
Circle()
|
|
|
|
|
.fill(color)
|
2022-01-02 10:05:13 -08:00
|
|
|
.frame(width: circleSize, height: circleSize)
|
2023-09-01 00:22:30 -07:00
|
|
|
Text(text)
|
|
|
|
|
.textCase(.uppercase)
|
2023-09-02 18:02:51 -07:00
|
|
|
.foregroundColor(color.isLight() ? .black : .white)
|
2023-10-21 15:33:00 -07:00
|
|
|
.font(.system(size: 8000))
|
2023-09-02 09:23:20 -07:00
|
|
|
.minimumScaleFactor(0.001)
|
2023-10-17 19:21:45 -07:00
|
|
|
.frame(width: circleSize * 0.95, height: circleSize * 0.95, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
2021-09-24 00:39:36 -07:00
|
|
|
}
|
2023-09-03 09:04:07 -07:00
|
|
|
.aspectRatio(1, contentMode: .fit)
|
2021-09-14 21:38:12 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CircleText_Previews: PreviewProvider {
|
|
|
|
|
static var previews: some View {
|
2023-10-21 15:33:00 -07:00
|
|
|
|
|
|
|
|
HStack {
|
|
|
|
|
VStack {
|
|
|
|
|
|
|
|
|
|
CircleText(text: "N1", color: Color.yellow, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "8", color: Color.purple, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "😝", color: Color.red, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "🍔", color: Color.brown, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "👻", color: Color.orange, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "🤙", color: Color.orange, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
VStack {
|
|
|
|
|
CircleText(text: "69", color: Color.green, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "WWWW", color: Color.cyan, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "CW-A", color: Color.secondary)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "CW-A", color: Color.secondary, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "MOMO", color: Color.mint, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "IIII", color: Color.accentColor, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
CircleText(text: "LCP", color: Color.primary, circleSize: 80)
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
}
|
2023-09-02 18:02:51 -07:00
|
|
|
}
|
2021-09-14 21:38:12 -07:00
|
|
|
}
|
|
|
|
|
}
|