Meshtastic-Apple/Meshtastic/Views/Helpers/CircleText.swift

37 lines
968 B
Swift
Raw Normal View History

/*
Abstract:
A view draws a circle in the background of the shortName text
*/
import SwiftUI
struct CircleText: View {
var text: String
var color: Color
2022-06-13 14:39:21 -07:00
var circleSize: CGFloat? = 60
var fontSize: CGFloat? = 20
var brightness: Double? = 0
2023-03-31 12:08:42 -07:00
var textColor: Color? = .white
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)
.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
}
}
}
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))
}
}