Skip to content

Commit e57267f

Browse files
committed
feat: Update color handling in views and improve background theming
1 parent 99bde02 commit e57267f

13 files changed

+395
-222
lines changed

Sources/Color+Theme.swift

+41-26
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,74 @@ import SwiftUI
99

1010
extension Color {
1111
struct Theme {
12-
/// A soft, paper-like gradient for light mode,
13-
/// and a darker gradient for dark mode.
12+
13+
/// Primary background gradient
1414
static func primaryGradient(isDarkMode: Bool) -> LinearGradient {
1515
isDarkMode
16+
// A near-black gradient with slight variation
1617
? LinearGradient(
17-
colors: [Color(hex: "2D2438"), Color(hex: "1A1B2E")],
18+
colors: [
19+
Color(hex: "111111"),
20+
Color(hex: "1A1A1A")
21+
],
1822
startPoint: .topLeading,
1923
endPoint: .bottomTrailing
2024
)
2125
: LinearGradient(
22-
// Subtle, near-white tones with a hint of lavender
26+
// Light/paper-like for normal mode
2327
colors: [Color(hex: "F7F5FC"), Color(hex: "FEFEFF")],
2428
startPoint: .topLeading,
2529
endPoint: .bottomTrailing
2630
)
2731
}
2832

29-
/// The background for chat bubbles or panels.
30-
/// Light mode is a clean, paper-like white with slight opacity,
31-
/// while dark mode uses a semi-opaque gray.
32-
static func bubbleBackground(isDarkMode: Bool) -> Color {
33-
isDarkMode
34-
? Color(hex: "2A2A2A").opacity(0.7)
35-
: Color.white.opacity(0.9)
33+
/// Chat bubble background
34+
/// For dark mode: user bubbles get a richer purple or dark gray,
35+
/// assistant bubbles get a simpler dark gray.
36+
static func bubbleBackground(isDarkMode: Bool, isUser: Bool) -> Color {
37+
guard isDarkMode else {
38+
return Color.white.opacity(0.9) // paper-like in light mode
39+
}
40+
// In dark mode:
41+
if isUser {
42+
// A subtle purple-tinted dark color for the user bubble
43+
return Color(hex: "292137") // tweak to preference (hint of purple)
44+
} else {
45+
// A neutral dark gray for assistant
46+
return Color(hex: "1E1E1E")
47+
}
3648
}
3749

38-
/// Primary text color. Lighter gray in dark mode, deep charcoal in light mode.
50+
/// Primary text color
3951
static func textPrimary(isDarkMode: Bool) -> Color {
4052
isDarkMode
41-
? Color(hex: "E1E1E1")
42-
: Color(hex: "2A2A2A") // a soft black for paper-like contrast
53+
? Color(hex: "E5E5E5") // softer white to reduce glare
54+
: Color(hex: "2A2A2A")
4355
}
4456

45-
/// Secondary text color. Dimmer in dark mode, mid-gray in light mode.
57+
/// Secondary text color
4658
static func textSecondary(isDarkMode: Bool) -> Color {
4759
isDarkMode
4860
? Color(hex: "A0A0A0")
4961
: Color(hex: "707070")
5062
}
5163

52-
/// A refined purple gradient for Ophelia’s accent highlights,
53-
/// leaning toward elegance in both modes.
64+
/// Ophelia’s accent gradient (buttons, highlights, etc.)
5465
static func accentGradient(isDarkMode: Bool) -> LinearGradient {
5566
isDarkMode
5667
? LinearGradient(
57-
colors: [Color(hex: "B389FF"), Color(hex: "7E3CE2")],
58-
startPoint: .leading,
59-
endPoint: .trailing
68+
colors: [
69+
Color(hex: "9B6BD1"),
70+
Color(hex: "6B3EA6")
71+
],
72+
startPoint: .topLeading,
73+
endPoint: .bottomTrailing
6074
)
6175
: LinearGradient(
62-
// Soft, sophisticated purples for a regal look
63-
colors: [Color(hex: "CAB2F2"), Color(hex: "8A2BE2")],
76+
colors: [
77+
Color(hex: "CAB2F2"),
78+
Color(hex: "8A2BE2")
79+
],
6480
startPoint: .leading,
6581
endPoint: .trailing
6682
)
@@ -74,23 +90,22 @@ extension Color {
7490
Scanner(string: hexValue).scanHexInt64(&int)
7591
let a, r, g, b: UInt64
7692
switch hexValue.count {
77-
case 3: // RGB (12-bit)
93+
case 3:
7894
(a, r, g, b) = (255, (int >> 8) * 17,
7995
(int >> 4 & 0xF) * 17,
8096
(int & 0xF) * 17)
81-
case 6: // RGB (24-bit)
97+
case 6:
8298
(a, r, g, b) = (255, int >> 16,
8399
int >> 8 & 0xFF,
84100
int & 0xFF)
85-
case 8: // ARGB (32-bit)
101+
case 8:
86102
(a, r, g, b) = ((int >> 24) & 0xFF,
87103
(int >> 16) & 0xFF,
88104
(int >> 8) & 0xFF,
89105
int & 0xFF)
90106
default:
91107
(a, r, g, b) = (255, 0, 0, 0)
92108
}
93-
94109
self.init(
95110
.sRGB,
96111
red: Double(r) / 255,

0 commit comments

Comments
 (0)