PowView.swift (515B)
1 // 2 // PowView.swift 3 // damus 4 // 5 // Created by William Casarin on 2022-04-16. 6 // 7 8 import Foundation 9 import SwiftUI 10 11 func PowView(_ mpow: Int?) -> some View 12 { 13 let pow = mpow ?? 0 14 return Text(verbatim: "\(pow)") 15 .font(.callout) 16 .foregroundColor(calculate_pow_color(pow)) 17 } 18 19 // TODO: make this less saturated on white theme 20 func calculate_pow_color(_ pow: Int) -> Color 21 { 22 let x = Double(pow) / 30.0; 23 return Color(.sRGB, red: 2.0 * (1.0 - x), green: 2.0 * x, blue: 0, opacity: 0.5) 24 } 25