diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index f4a3cfe..f3796cf 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -824,7 +824,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 17; + IPHONEOS_DEPLOYMENT_TARGET = 16; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -861,7 +861,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 17; + IPHONEOS_DEPLOYMENT_TARGET = 16; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index 800fca3..6aa6488 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -17,6 +17,10 @@ class HostsManager: ObservableObject, @unchecked Sendable { @Published var selectedTheme: Theme = Theme.defaultTheme @Published var selectedAnsi: Int = 1 + var tint: SwiftUI.Color { + selectedTheme.ansi[selectedAnsi].suiColor + } + init() { loadHosts() loadThemes() diff --git a/ShhShell/ShhShellApp.swift b/ShhShell/ShhShellApp.swift index 4e9aa88..dbc7f0f 100644 --- a/ShhShell/ShhShellApp.swift +++ b/ShhShell/ShhShellApp.swift @@ -28,7 +28,7 @@ struct ShhShellApp: App { keyManager: keyManager ) .colorScheme(hostsManager.selectedTheme.background.luminance > 0.5 ? .light : .dark) - .tint(hostsManager.selectedTheme.ansi[hostsManager.selectedAnsi].suiColor) + .tint(hostsManager.tint) } } } diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift index 4beb0c8..03361b9 100644 --- a/ShhShell/Views/Terminal/ShellTabView.swift +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -16,7 +16,25 @@ struct ShellTabView: View { @Environment(\.dismiss) var dismiss - var foreground: Color { hostsManager.selectedTheme.foreground.suiColor } + var foreground: Color { + let selectedTheme = hostsManager.selectedTheme + let foreground = selectedTheme.foreground + let background = selectedTheme.background + + if selectedTheme.ansi[hostsManager.selectedAnsi].luminance > 0.5 { + if foreground.luminance > 0.5 { + return background.suiColor + } else { + return foreground.suiColor + } + } else { + if foreground.luminance > 0.5 { + return foreground.suiColor + } else { + return background.suiColor + } + } + } var background: Color { hostsManager.selectedTheme.background.suiColor } var body: some View { @@ -32,6 +50,7 @@ struct ShellTabView: View { for session in container.sessions.values { session.handler.disconnect() } + dismiss() } label: { TrafficLightRed() } @@ -41,40 +60,51 @@ struct ShellTabView: View { TrafficLightYellow() } Spacer() - Text(container.sessions[selectedID ?? UUID()]?.handler.title ?? "title") - .bold() - .monospaced() + VStack { + Text(container.sessions[selectedID ?? UUID()]?.handler.title ?? handler?.title ?? "") + .bold() + .foregroundStyle(foreground) + .monospaced() + .contentTransition(.numericText()) + if container.sessionIDs.count == 1 { + Text(container.sessions[selectedID ?? UUID()]?.handler.host.description ?? handler?.host.description ?? "") + .bold() + .foregroundStyle(foreground) + .monospaced() + .font(.caption2) + } + } Spacer() } .padding(.horizontal, 10) .padding(.bottom, 10) - .background(Color.accentColor, ignoresSafeAreaEdges: .all) + .background(hostsManager.tint, ignoresSafeAreaEdges: .all) .frame(height: 30) - HStack(alignment: .center, spacing: 0) { + if container.sessionIDs.count > 1 { ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 0) { ForEach(container.sessionIDs, id: \.self) { id in let selected: Bool = selectedID == id ZStack { Rectangle() - .fill(selected ? .accentColor : background) + .fill(selected ? hostsManager.tint : background) HStack { Spacer() VStack { if !selected { Text(container.sessions[id]!.handler.title) .monospaced() - .foregroundStyle(foreground) + .foregroundStyle(selected ? foreground : hostsManager.tint) .opacity(0.7) .font(.callout) } Text(container.sessions[id]!.handler.host.description) - .foregroundStyle(foreground) + .foregroundStyle(selected ? foreground : hostsManager.tint) .opacity(selected ? 1 : 0.7) .monospaced() .bold(selected) - .font(.caption) + .font(.caption2) } Spacer() } @@ -86,14 +116,14 @@ struct ShellTabView: View { } } } - } - .frame(height: 30) - .onAppear { - if selectedID == nil { - if let handler { - selectedID = handler.sessionID - } else { - dismiss() + .frame(height: 30) + .onAppear { + if selectedID == nil { + if let handler { + selectedID = handler.sessionID + } else { + dismiss() + } } } } @@ -105,6 +135,7 @@ struct ShellTabView: View { handler: session.handler, hostsManager: hostsManager ) + .border(.blue) .onDisappear { if !checkShell(session.handler.state) { if let lastSession = container.sessionIDs.last { @@ -119,6 +150,12 @@ struct ShellTabView: View { } else { if let handler { ShellView(handler: handler, hostsManager: hostsManager) + .onAppear { + if selectedID == nil { + selectedID = handler.sessionID + } + } + .border(.red) } else { Text("No SSH Handler") }