rensbreur / SwiftTUI

SwiftUI for terminal applications
MIT License
1.21k stars 44 forks source link

Example app soundcld #29

Closed seneca1github closed 5 months ago

seneca1github commented 5 months ago

Hello, i cannot find it, can you show me somewhere? I am trying to mimic the same userinterface @rensbreur

rensbreur commented 5 months ago

You're right, I cannot currently make that public, I need to update the readme. However, everything you see can be done with SwiftTUI (the version as it is on the main branch). For example, it's using borders with a custom style and a negative padding for the "split panels" and custom xterm colors. Let me know if you need help with anything specific!

seneca1github commented 5 months ago

I am trying to make live graphs for cpu usage, with 4 panels for each core. Can you help with an example?

rensbreur commented 5 months ago

This is basically what I did for the waveform

struct WaveformView: View {
    let samples: [Double]
    let height: Extended = 5

    var body: some View {
        HStack(alignment: .bottom) {
            ForEach(0 ..< samples.count, id: \.self) { i in
                Color.orange
                    .frame(width: 1, height: Extended(samples[i]) * height)
            }
        }
        .frame(height: height, alignment: .bottomLeading)
    }
}

And here is the progressbar:

struct PlayerProgressBar: View {
    @ObservedObject var playbackProgress = Player.shared.playbackProgress

    var body: some View {
        GeometryReader { geo in
            Color.progressBarForeground
                .frame(width: Extended(Int(Double(geo.width.intValue) * playbackProgress.progress)))
        }
        .frame(height: 1)
        .background(.progressBarBackground)
    }
}