got it working by overlaying another view on top, still need to fix the brightness issue tho

This commit is contained in:
neon443
2025-08-26 16:04:07 +01:00
parent f85ef3deaf
commit e24ef96ccb
5 changed files with 84 additions and 36 deletions

View File

@@ -17,7 +17,8 @@ using namespace metal;
//scanlines
newCol *= 0.5 + 0.5 * sin(uv.y * 1250.0);
half4 output = half4(color.xyz*newCol, 1);
// half4 output = half4(layer.sample(pos).xyz*newCol, 1);
half4 output = half4(color.xyz*newCol*0.24, 0.25);
return output;
}

View File

@@ -18,6 +18,13 @@ struct ContentView: View {
hostsManager.selectedTheme.background.suiColor.opacity(0.7)
.ignoresSafeArea(.all)
List {
ForEach(0..<6) {
Color.red.frame(width: 60, height: 60, alignment: .center)
.brightness(Double($0) * 0.2)
.overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"),
alignment: .bottom)
.border(Color.gray)
}
SessionsListView(
handler: handler,
hostsManager: hostsManager,

View File

@@ -0,0 +1,33 @@
//
// CRTView.swift
// ShhShell
//
// Created by neon443 on 25/08/2025.
//
import SwiftUI
struct CRTView: View {
@State var startTime: Date = .now
var body: some View {
TimelineView(.animation) { tl in
let time = tl.date.distance(to: startTime)
Rectangle()
.foregroundStyle(.white.opacity(0.1))
.visualEffect { content, proxy in
content
.colorEffect(
ShaderLibrary.crt(
.float2(proxy.size),
.float(time)
)
)
}
}
}
}
#Preview {
CRTView()
}

View File

@@ -20,44 +20,47 @@ struct ShellView: View {
var body: some View {
NavigationStack {
let time = startTime.timeIntervalSinceNow
ZStack {
TimelineView(.animation) { tl in
let time = tl.date.distance(to: startTime)
let shaderEnabled = hostsManager.settings.filter == .crt
hostsManager.selectedTheme.background.suiColor
.ignoresSafeArea(.all)
TerminalController(handler: handler, hostsManager: hostsManager)
Group {
Color.gray.opacity(0.2)
.transition(.opacity)
Image(systemName: "bell.fill")
.foregroundStyle(
hostsManager.selectedTheme.background.luminance > 0.5 ?
.black : .white
)
.font(.largeTitle)
.shadow(color: .black, radius: 5)
}
.opacity(handler.bell ? 1 : 0)
.onChange(of: handler.bell) { _ in
guard handler.bell else { return }
if hostsManager.settings.bellHaptic {
Haptic.warning.trigger()
}
if hostsManager.settings.bellSound {
AudioServicesPlaySystemSound(1103)
hostsManager.selectedTheme.background.suiColor
.ignoresSafeArea(.all)
TerminalController(handler: handler, hostsManager: hostsManager)
// .visualEffect { content, proxy in
// content
// .layerEffect(
// ShaderLibrary.crt(
// .float2(proxy.size),
// .float(time)
// ),
// maxSampleOffset: .zero
// )
// }
.overlay {
if hostsManager.settings.filter == .crt {
CRTView()
}
}
.visualEffect { content, proxy in
content
.colorEffect(
ShaderLibrary.crt(
.float2(proxy.size),
.float(time)
),
isEnabled: shaderEnabled
)
Group {
Color.gray.opacity(0.2)
.transition(.opacity)
Image(systemName: "bell.fill")
.foregroundStyle(
hostsManager.selectedTheme.background.luminance > 0.5 ?
.black : .white
)
.font(.largeTitle)
.shadow(color: .black, radius: 5)
}
.opacity(handler.bell ? 1 : 0)
.onChange(of: handler.bell) { _ in
guard handler.bell else { return }
if hostsManager.settings.bellHaptic {
Haptic.warning.trigger()
}
if hostsManager.settings.bellSound {
AudioServicesPlaySystemSound(1103)
}
}
}