import SwiftUI import Combine extension UIScreen{ static let screenWidth = UIScreen.main.bounds.size.width static let screenHeight = UIScreen.main.bounds.size.height static let screenSize = UIScreen.main.bounds.size } let lightUpProtocol = PassthroughSubject<(Int,Int),Never>() struct ContentView: View { let timer = Timer.publish(every: 0.4, on: .main, in: .common).autoconnect() @State var lightUp = 0 @State var column = 0 var body: some View { ZStack { Color.black .onReceive(timer) { value in let rnd = Int.random(in: 0..<32) doIt(column: rnd) } HStack(alignment: .top, content: { ForEach(0..<24) { foo in LetterView(column: foo) } }) } } func doIt(column: Int) { var lightUp = 0 var row = 0 Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in row += 1 lightUpProtocol.send((lightUp,column)) if lightUp < 32 { lightUp += 1 } else { lightUp = 0 } if row == 32 { timer.invalidate() } } } } struct LetterView: View { @State var column:Int @State var letters:[String] = [] @State var alpha:[Double] = [] @State var color:[Color] = [] @State var ready = false var body: some View { VStack(alignment: .center, spacing: 0, content: { if !ready { Color.clear .frame(width: 0, height: 0) .onAppear { for _ in 0...32 { let rnd = UInt8.random(in: 65...91) letters.append(String(UnicodeScalar(rnd))) alpha.append(0) color.append(Color.white) } ready = true } } else { ForEach ((0..