fixing coloring of the header and some ui stuff

This commit is contained in:
talksik
2021-12-14 17:42:38 -08:00
parent 532f8cd50a
commit c3aa79fef1
2 changed files with 34 additions and 25 deletions
+29 -23
View File
@@ -8,31 +8,30 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
extension UIColor { extension Color {
public convenience init?(hex: String) { init(hex: String) {
let r, g, b, a: CGFloat let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int: UInt64 = 0
if hex.hasPrefix("#") { Scanner(string: hex).scanHexInt64(&int)
let start = hex.index(hex.startIndex, offsetBy: 1) let a, r, g, b: UInt64
let hexColor = String(hex[start...]) switch hex.count {
case 3: // RGB (12-bit)
if hexColor.count == 8 { (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
let scanner = Scanner(string: hexColor) case 6: // RGB (24-bit)
var hexNumber: UInt64 = 0 (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF)
case 8: // ARGB (32-bit)
if scanner.scanHexInt64(&hexNumber) { (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF)
r = CGFloat((hexNumber & 0xff000000) >> 24) / 255 default:
g = CGFloat((hexNumber & 0x00ff0000) >> 16) / 255 (a, r, g, b) = (1, 1, 1, 0)
b = CGFloat((hexNumber & 0x0000ff00) >> 8) / 255
a = CGFloat(hexNumber & 0x000000ff) / 255
self.init(red: r, green: g, blue: b, alpha: a)
return
}
}
} }
return nil self.init(
.sRGB,
red: Double(r) / 255,
green: Double(g) / 255,
blue: Double(b) / 255,
opacity: Double(a) / 255
)
} }
} }
@@ -41,4 +40,11 @@ final class NirvanaColor {
static let bgLightGrey:Color = Color(red: 0.898, green: 0.898, blue: 0.898) static let bgLightGrey:Color = Color(red: 0.898, green: 0.898, blue: 0.898)
static let white: Color = Color.white static let white: Color = Color.white
static let black: Color = Color.black static let black: Color = Color.black
// turqouise and stones color palettes
static let light:Color = Color(hex: "2a416a")
static let orangy:Color = Color(hex: "305955")
static let solidTeal:Color = Color(hex: "258786")
static let dimTeal:Color = Color(hex: "ca7558")
static let solidBlue:Color = Color(hex: "9ec2b6")
} }
+5 -2
View File
@@ -26,12 +26,15 @@ struct HeaderView: View {
.aspectRatio(contentMode: .fill) .aspectRatio(contentMode: .fill)
.frame(width: 40, height: 40) .frame(width: 40, height: 40)
.clipShape(Circle()) .clipShape(Circle())
.padding() .padding(5)
.shadow(radius:5) .shadow(radius:5)
} }
} }
.background(Color(self.averageColor))
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
// .background(Color(self.averageColor)) // color based on user's profilepicture dominant color
.background(NirvanaColor.solidBlue)
.cornerRadius(100)
.padding(.horizontal)
.onAppear{ .onAppear{
// set background color based on profile picture tint // set background color based on profile picture tint
if authStore.sessionState == SessionState.isAuthenticated { if authStore.sessionState == SessionState.isAuthenticated {