commit eabf37e35c88fe8556860dcf5d97d23e3c7a4280
parent e11147b21705028ded9030bd3a8a7c4fe7a35108
Author: William Casarin <jb55@jb55.com>
Date: Mon, 27 Mar 2023 12:38:59 -0400
Refactor damus color references
Diffstat:
17 files changed, 47 insertions(+), 46 deletions(-)
diff --git a/damus/Components/CustomPicker.swift b/damus/Components/CustomPicker.swift
@@ -8,8 +8,8 @@
import SwiftUI
let RECTANGLE_GRADIENT = LinearGradient(gradient: Gradient(colors: [
- Color("DamusPurple"),
- Color("DamusBlue")
+ DamusColors.purple,
+ DamusColors.blue
]), startPoint: .leading, endPoint: .trailing)
struct CustomPicker<SelectionValue: Hashable, Content: View>: View {
@@ -56,6 +56,6 @@ struct CustomPicker<SelectionValue: Hashable, Content: View>: View {
}
func textColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
}
diff --git a/damus/Components/DamusColors.swift b/damus/Components/DamusColors.swift
@@ -9,13 +9,14 @@ import Foundation
import SwiftUI
class DamusColors {
- static let adaptableGray = Color("DamusAdaptableGrey")
+ static let adaptableGrey = Color("DamusAdaptableGrey")
static let white = Color("DamusWhite")
static let black = Color("DamusBlack")
- static let lightGray = Color("DamusLightGray")
- static let mediumGray = Color("DamusMediumGray")
- static let darkGray = Color("DamusDarkGray")
+ static let lightGrey = Color("DamusLightGrey")
+ static let mediumGrey = Color("DamusMediumGrey")
+ static let darkGrey = Color("DamusDarkGray")
static let green = Color("DamusGreen")
- static let purple = Color("DamusGreen")
+ static let purple = Color("DamusPurple")
+ static let blue = Color("DamusBlue")
}
diff --git a/damus/Components/InvoiceView.swift b/damus/Components/InvoiceView.swift
@@ -29,7 +29,7 @@ struct InvoiceView: View {
.foregroundColor(.gray)
} else {
Image(systemName: "checkmark.circle")
- .foregroundColor(Color("DamusGreen"))
+ .foregroundColor(DamusColors.green)
}
}
}
diff --git a/damus/ContentView.swift b/damus/ContentView.swift
@@ -211,7 +211,7 @@ struct ContentView: View {
Image("damus-home")
.resizable()
.frame(width:30,height:30)
- .shadow(color: Color("DamusPurple"), radius: 2)
+ .shadow(color: DamusColors.purple, radius: 2)
.opacity(isSideBarOpened ? 0 : 1)
.animation(isSideBarOpened ? .none : .default, value: isSideBarOpened)
} else {
diff --git a/damus/Views/ActionBar/ShareAction.swift b/damus/Views/ActionBar/ShareAction.swift
@@ -29,7 +29,7 @@ struct ShareAction: View {
var body: some View {
- let col = colorScheme == .light ? Color("DamusMediumGrey") : Color("DamusWhite")
+ let col = colorScheme == .light ? DamusColors.mediumGrey : DamusColors.white
VStack {
Text("Share Note", comment: "Title text to indicate that the buttons below are meant to be used to share a note with others.")
@@ -75,10 +75,10 @@ struct ShareAction: View {
}) {
Text(NSLocalizedString("Cancel", comment: "Button to cancel a repost."))
.frame(minWidth: 300, maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .center)
- .foregroundColor(colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite"))
+ .foregroundColor(colorScheme == .light ? DamusColors.black : DamusColors.white)
.overlay {
RoundedRectangle(cornerRadius: 24)
- .stroke(colorScheme == .light ? Color("DamusMediumGrey") : Color("DamusWhite"), lineWidth: 1)
+ .stroke(colorScheme == .light ? DamusColors.mediumGrey : DamusColors.white, lineWidth: 1)
}
.padding(EdgeInsets(top: 10, leading: 50, bottom: 25, trailing: 50))
}
diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift
@@ -39,7 +39,7 @@ struct ConfigView: View {
}
func textColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
func authenticateLocally(completion: @escaping (Bool) -> Void) {
diff --git a/damus/Views/EditMetadataView.swift b/damus/Views/EditMetadataView.swift
@@ -83,7 +83,7 @@ struct EditMetadataView: View {
}
func imageBorderColor() -> Color {
- colorScheme == .light ? Color("DamusWhite") : Color("DamusBlack")
+ colorScheme == .light ? DamusColors.white : DamusColors.black
}
func save() {
diff --git a/damus/Views/Events/MutedEventView.swift b/damus/Views/Events/MutedEventView.swift
@@ -30,7 +30,7 @@ struct MutedEventView: View {
var MutedBox: some View {
ZStack {
RoundedRectangle(cornerRadius: 20)
- .foregroundColor(Color("DamusAdaptableGrey"))
+ .foregroundColor(DamusColors.adaptableGrey)
HStack {
Text("Post from a user you've blocked", comment: "Text to indicate that what is being shown is a post from a user who has been blocked.")
diff --git a/damus/Views/Events/ZapEvent.swift b/damus/Views/Events/ZapEvent.swift
@@ -20,7 +20,7 @@ struct ZapEvent: View {
if zap.private_request != nil {
Image(systemName: "lock.fill")
- .foregroundColor(Color("DamusGreen"))
+ .foregroundColor(DamusColors.green)
.help(NSLocalizedString("Only you can see this message and who sent it.", comment: "Help text on green lock icon that explains that only the current user can see the message of a zap event and who sent the zap."))
}
}
diff --git a/damus/Views/FollowButtonView.swift b/damus/Views/FollowButtonView.swift
@@ -50,11 +50,11 @@ struct FollowButtonView: View {
}
func filledTextColor() -> Color {
- colorScheme == .light ? Color("DamusWhite") : Color("DamusBlack")
+ colorScheme == .light ? DamusColors.white : DamusColors.black
}
func fillColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
func emptyColor() -> Color {
@@ -62,7 +62,7 @@ struct FollowButtonView: View {
}
func borderColor() -> Color {
- colorScheme == .light ? Color("DamusDarkGrey") : Color("DamusLightGrey")
+ colorScheme == .light ? DamusColors.darkGrey : DamusColors.lightGrey
}
}
diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift
@@ -190,14 +190,14 @@ struct NoteContentView: View {
func hashtag_str(_ htag: String) -> AttributedString {
var attributedString = AttributedString(stringLiteral: "#\(htag)")
attributedString.link = URL(string: "damus:t:\(htag)")
- attributedString.foregroundColor = Color("DamusPurple")
+ attributedString.foregroundColor = DamusColors.purple
return attributedString
}
func url_str(_ url: URL) -> AttributedString {
var attributedString = AttributedString(stringLiteral: url.absoluteString)
attributedString.link = url
- attributedString.foregroundColor = Color("DamusPurple")
+ attributedString.foregroundColor = DamusColors.purple
return attributedString
}
@@ -209,13 +209,13 @@ func mention_str(_ m: Mention, profiles: Profiles) -> AttributedString {
let disp = Profile.displayName(profile: profile, pubkey: pk).username
var attributedString = AttributedString(stringLiteral: "@\(disp)")
attributedString.link = URL(string: "damus:\(encode_pubkey_uri(m.ref))")
- attributedString.foregroundColor = Color("DamusPurple")
+ attributedString.foregroundColor = DamusColors.purple
return attributedString
case .event:
let bevid = bech32_note_id(m.ref.ref_id) ?? m.ref.ref_id
var attributedString = AttributedString(stringLiteral: "@\(abbrev_pubkey(bevid))")
attributedString.link = URL(string: "damus:\(encode_event_id_uri(m.ref))")
- attributedString.foregroundColor = Color("DamusPurple")
+ attributedString.foregroundColor = DamusColors.purple
return attributedString
}
}
diff --git a/damus/Views/Notifications/EventGroupView.swift b/damus/Views/Notifications/EventGroupView.swift
@@ -184,7 +184,7 @@ struct EventGroupView: View {
switch group {
case .repost:
Image(systemName: "arrow.2.squarepath")
- .foregroundColor(Color("DamusGreen"))
+ .foregroundColor(DamusColors.green)
case .reaction:
LINEAR_GRADIENT
.mask(Image("shaka-full")
diff --git a/damus/Views/PostButton.swift b/damus/Views/PostButton.swift
@@ -10,8 +10,8 @@ import SwiftUI
let BUTTON_SIZE = 57.0
let LINEAR_GRADIENT = LinearGradient(gradient: Gradient(colors: [
- Color("DamusPurple"),
- Color("DamusBlue")
+ DamusColors.purple,
+ DamusColors.blue
]), startPoint: .topTrailing, endPoint: .bottomTrailing)
func PostButton(action: @escaping () -> ()) -> some View {
diff --git a/damus/Views/Profile/FollowsYou.swift b/damus/Views/Profile/FollowsYou.swift
@@ -16,7 +16,7 @@ struct FollowsYou: View {
.foregroundColor(.gray)
.background {
RoundedRectangle(cornerRadius: 5.0)
- .foregroundColor(Color("DamusAdaptableGrey"))
+ .foregroundColor(DamusColors.adaptableGrey)
}
.font(.footnote)
}
diff --git a/damus/Views/Profile/ProfileView.swift b/damus/Views/Profile/ProfileView.swift
@@ -87,11 +87,11 @@ struct EditButton: View {
}
func fillColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
func borderColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
}
@@ -144,7 +144,7 @@ struct ProfileView: View {
@Environment(\.presentationMode) var presentationMode
func imageBorderColor() -> Color {
- colorScheme == .light ? Color("DamusWhite") : Color("DamusBlack")
+ colorScheme == .light ? DamusColors.white : DamusColors.black
}
func bannerBlurViewOpacity() -> Double {
@@ -236,7 +236,7 @@ struct ProfileView: View {
}
.padding(.top, 5)
.padding(.horizontal)
- .accentColor(Color("DamusWhite"))
+ .accentColor(DamusColors.white)
}
func lnButton(lnurl: String, profile: Profile) -> some View {
@@ -493,7 +493,7 @@ struct KeyView: View {
@State private var isCopied = false
func keyColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
private func copyPubkey(_ pubkey: String) {
@@ -530,7 +530,7 @@ struct KeyView: View {
}
.padding(2)
.padding([.leading, .trailing], 3)
- .background(RoundedRectangle(cornerRadius: 11).foregroundColor(Color("DamusAdaptableGrey")))
+ .background(RoundedRectangle(cornerRadius: 11).foregroundColor(DamusColors.adaptableGrey))
if isCopied != true {
Button {
@@ -555,7 +555,7 @@ struct KeyView: View {
.font(.footnote)
.layoutPriority(1)
}
- .foregroundColor(Color("DamusGreen"))
+ .foregroundColor(DamusColors.green)
}
}
}
diff --git a/damus/Views/QRCodeView.swift b/damus/Views/QRCodeView.swift
@@ -42,23 +42,23 @@ struct QRCodeView: View {
let profile = damus_state.profiles.lookup(id: damus_state.pubkey)
if (damus_state.profiles.lookup(id: damus_state.pubkey)?.picture) != nil {
- ProfilePicView(pubkey: damus_state.pubkey, size: 90.0, highlight: .custom(Color("DamusWhite"), 4.0), profiles: damus_state.profiles)
+ ProfilePicView(pubkey: damus_state.pubkey, size: 90.0, highlight: .custom(DamusColors.white, 4.0), profiles: damus_state.profiles)
.padding(.top, 50)
} else {
Image(systemName: "person.fill")
.font(.system(size: 60))
- .foregroundColor(Color("DamusWhite"))
+ .foregroundColor(DamusColors.white)
.padding(.top, 50)
}
if let display_name = profile?.display_name {
Text(display_name)
- .foregroundColor(Color("DamusWhite"))
+ .foregroundColor(DamusColors.white)
.font(.system(size: 24, weight: .heavy))
}
if let name = profile?.name {
Text("@" + name)
- .foregroundColor(Color("DamusWhite"))
+ .foregroundColor(DamusColors.white)
.font(.body)
}
@@ -73,19 +73,19 @@ struct QRCodeView: View {
.padding()
.cornerRadius(10)
.overlay(RoundedRectangle(cornerRadius: 10)
- .stroke(Color("DamusWhite"), lineWidth: 1))
+ .stroke(DamusColors.white, lineWidth: 1))
.shadow(radius: 10)
}
Spacer()
Text("Follow me on nostr", comment: "Text on QR code view to prompt viewer looking at screen to follow the user.")
- .foregroundColor(Color("DamusWhite"))
+ .foregroundColor(DamusColors.white)
.font(.system(size: 24, weight: .heavy))
.padding(.top)
Text("Scan the code", comment: "Text on QR code view to prompt viewer to scan the QR code on screen with their device camera.")
- .foregroundColor(Color("DamusWhite"))
+ .foregroundColor(DamusColors.white)
.font(.system(size: 18, weight: .ultraLight))
Spacer()
diff --git a/damus/Views/SideMenuView.swift b/damus/Views/SideMenuView.swift
@@ -20,11 +20,11 @@ struct SideMenuView: View {
let verticalSpacing: CGFloat = 20
func fillColor() -> Color {
- colorScheme == .light ? Color("DamusWhite") : Color("DamusBlack")
+ colorScheme == .light ? DamusColors.white : DamusColors.black
}
func textColor() -> Color {
- colorScheme == .light ? Color("DamusBlack") : Color("DamusWhite")
+ colorScheme == .light ? DamusColors.black : DamusColors.white
}
var body: some View {
@@ -32,7 +32,7 @@ struct SideMenuView: View {
GeometryReader { _ in
EmptyView()
}
- .background(Color("DamusDarkGrey").opacity(0.6))
+ .background(DamusColors.darkGrey.opacity(0.6))
.opacity(isSidebarVisible ? 1 : 0)
.animation(.default, value: isSidebarVisible)
.onTapGesture {
@@ -69,7 +69,7 @@ struct SideMenuView: View {
}
if let name = profile?.name {
Text("@" + name)
- .foregroundColor(Color("DamusMediumGrey"))
+ .foregroundColor(DamusColors.mediumGrey)
.font(.body)
.lineLimit(1)
}