mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Font scaling for Short name circle text
This commit is contained in:
parent
87a1115727
commit
c25a60942d
1 changed files with 8 additions and 6 deletions
|
|
@ -8,23 +8,22 @@ import SwiftUI
|
|||
struct CircleText: View {
|
||||
var text: String
|
||||
var color: Color
|
||||
var circleSize: CGFloat? = 45
|
||||
var circleSize: CGFloat = 45
|
||||
var textColor: Color? = .white
|
||||
|
||||
var body: some View {
|
||||
|
||||
let font = Font.system(size: (text.count == 1) ? ((circleSize ?? 45) * 0.75) : (text.count == 2 ? ((circleSize ?? 45) * 0.52) : (text.count == 3 ? ((circleSize ?? 45) * 0.42) : ((circleSize ?? 45) * 0.32))))
|
||||
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(color)
|
||||
.frame(width: circleSize, height: circleSize)
|
||||
Text(text)
|
||||
.textCase(.uppercase)
|
||||
.font(font)
|
||||
.foregroundColor(textColor)
|
||||
.fixedSize()
|
||||
.frame(width: circleSize, height: circleSize, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
.font(.system(size: 500))
|
||||
.minimumScaleFactor(0.001)
|
||||
.frame(width: circleSize * 0.90,
|
||||
height: circleSize * 0.90, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +31,9 @@ struct CircleText: View {
|
|||
struct CircleText_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CircleText(text: "MOMO", color: Color.accentColor, circleSize: 80)
|
||||
CircleText(text: "WWWW", color: Color.accentColor, circleSize: 80)
|
||||
CircleText(text: "LCP", color: Color.accentColor, circleSize: 80)
|
||||
CircleText(text: "8", color: Color.accentColor, circleSize: 80)
|
||||
.previewLayout(.fixed(width: 300, height: 100))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue