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

34 lines
874 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-01-02 23:28:51 -08:00
var circleSize: CGFloat? = 50
var fontSize: CGFloat? = 22
var body: some View {
2022-01-02 10:05:13 -08:00
let font = Font.system(size: fontSize!)
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)
2022-02-23 23:05:47 -10:00
Text(text).textCase(.uppercase).font(font).foregroundColor(.white).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 {
CircleText(text: "RDN", color: Color.accentColor)
2021-09-18 17:10:22 -07:00
.previewLayout(.fixed(width: 300, height: 100))
}
}