mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
add a border to ansipicker, and fix the corner radius
fix light themes having unreadable text added a luminance property to calculate the brighness of the bg color if its > 0.5, choose a light theme to get black text
This commit is contained in:
@@ -27,7 +27,7 @@ struct ShhShellApp: App {
|
|||||||
hostsManager: hostsManager,
|
hostsManager: hostsManager,
|
||||||
keyManager: keyManager
|
keyManager: keyManager
|
||||||
)
|
)
|
||||||
.colorScheme(.dark)
|
.colorScheme(hostsManager.selectedTheme.background.luminance > 0.5 ? .light : .dark)
|
||||||
.tint(hostsManager.selectedTheme.ansi[hostsManager.selectedAnsi].suiColor)
|
.tint(hostsManager.selectedTheme.ansi[hostsManager.selectedAnsi].suiColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,3 +55,12 @@ extension SwiftTerm.Color {
|
|||||||
return UIColor(red: red, green: green, blue: blue, alpha: 1)
|
return UIColor(red: red, green: green, blue: blue, alpha: 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension SwiftTerm.Color {
|
||||||
|
var luminance: Double {
|
||||||
|
let r = Double(red)/65535
|
||||||
|
let g = Double(green)/65535
|
||||||
|
let b = Double(blue)/65535
|
||||||
|
return (0.2126*r + 0.7152*g + 0.0722*b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,34 +11,36 @@ struct AnsiPickerView: View {
|
|||||||
@ObservedObject var hostsManager: HostsManager
|
@ObservedObject var hostsManager: HostsManager
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { geo in
|
ZStack {
|
||||||
VStack(spacing: 0) {
|
RoundedRectangle(cornerRadius: 15)
|
||||||
ForEach(0...1, id: \.self) { row in
|
.aspectRatio(CGSize(width: 4, height: 1), contentMode: .fit)
|
||||||
HStack(spacing: 0) {
|
.foregroundStyle(hostsManager.selectedTheme.foreground.suiColor.opacity(0.7))
|
||||||
ForEach(1...8, id: \.self) { col in
|
GeometryReader { geo in
|
||||||
let index = (col+(row*8))-1
|
VStack(spacing: 0) {
|
||||||
var isSelected: Bool { hostsManager.selectedAnsi == index }
|
ForEach(0...1, id: \.self) { row in
|
||||||
ZStack {
|
HStack(spacing: 0) {
|
||||||
Rectangle()
|
ForEach(1...8, id: \.self) { col in
|
||||||
.fill(hostsManager.selectedTheme.background.suiColor)
|
let index = (col+(row*8))-1
|
||||||
Rectangle()
|
var isSelected: Bool { hostsManager.selectedAnsi == index }
|
||||||
.fill(hostsManager.selectedTheme.ansi[index].suiColor)
|
ZStack {
|
||||||
.padding(isSelected ? 5 : 0)
|
Rectangle()
|
||||||
.clipShape(
|
.fill(hostsManager.selectedTheme.background.suiColor)
|
||||||
RoundedRectangle(
|
RoundedRectangle(cornerRadius: isSelected ? 5 : 0)
|
||||||
cornerRadius: isSelected ? 10 : 0
|
.fill(hostsManager.selectedTheme.ansi[index].suiColor)
|
||||||
)
|
.padding(isSelected ? 5 : 0)
|
||||||
)
|
.onTapGesture {
|
||||||
.onTapGesture {
|
hostsManager.selectAnsi(index)
|
||||||
hostsManager.selectAnsi(index)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.aspectRatio(CGSize(width: 4, height: 1), contentMode: .fit)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||||
|
.padding(5)
|
||||||
}
|
}
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 15))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ struct ThemeManagerView: View {
|
|||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("Your Themes")
|
||||||
|
.padding(.top)
|
||||||
|
.padding(.horizontal)
|
||||||
|
.font(.headline)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
if hostsManager.themes.isEmpty {
|
if hostsManager.themes.isEmpty {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Image(systemName: "paintpalette")
|
Image(systemName: "paintpalette")
|
||||||
|
|||||||
Reference in New Issue
Block a user