Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift UI Display Text In List, change every few seconds #1350

Open
enzyme69 opened this issue Dec 17, 2023 · 0 comments
Open

Swift UI Display Text In List, change every few seconds #1350

enzyme69 opened this issue Dec 17, 2023 · 0 comments

Comments

@enzyme69
Copy link
Owner

import SwiftUI

struct ContentView: View {
    let words: [String] = [
        "Your pixels bloom where doubt wilts. Tend your garden, samurai of polygons.",
        "Imperfections are brushstrokes of soul. Embrace the happy accidents, young padawan.",
        "Render not just textures, but emotions. Every mesh sings a silent song, hear it.",
        "The canvas is infinite, the deadline finite. Pace yourself, grasshopper, savor the journey.",
        "Critique is not a chisel, but a whetstone. Sharpen your skills, not your anxieties.",
        "Inspiration is everywhere, not just in tutorials. Open your eyes, apprentice, the world is your reference library.",
        "Comparison is a thief of progress. Steal only techniques, young master, leave your originality intact.",
        "Technical hurdles are merely stepping stones. Leap over them, young Jedi, reach for the summit of your vision.",
        "Community is your dojo, collaboration your sparring partner. Train together, grow together.",
        "The greatest masterpiece is not the final render, but the journey of creation. Forge your own legend, pixel by pixel."
    ]    
    
    @State private var currentWordIndex: Int = 0
    @State private var backgroundColor = Color.pink
    
    let timer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect()
    
    var body: some View {
        ZStack {
            Color(backgroundColor)
                .edgesIgnoringSafeArea(.all) // Fill the entire screen
            
            if currentWordIndex < words.count {
                Text(words[currentWordIndex])
                    .font(.largeTitle)
                    .font(.system(size: 200))
                    .bold()
                    .padding(.horizontal, 30) // 
            }
        }
        .onReceive(timer) { _ in
            withAnimation {
                if currentWordIndex < words.count - 1 {
                    currentWordIndex += 1
                } else {
                    timer.upstream.connect().cancel()
                }
            }
        }
    }
}




Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant