//
//  ColourGeneratorAppApp.swift
//  ColourGeneratorApp
//
//  Created by WilliamJiamin on 2024/6/19.
//

import SwiftUI

@main
struct ColourGeneratorAppApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
//
//  ContentView.swift
//  ColourGeneratorApp
//
//  Created by WilliamJiamin on 2024/6/19.
//

import SwiftUI

struct ContentView: View {

    let ArrayOfColumns = Array(
        repeating: GridItem(.fixed(100)),
        count: 3
    )

    var body: some View {
        ScrollView {
            LazyVGrid(columns: ArrayOfColumns) {
                ForEach(MockData.colors, id: \.self) { color in
                    color
                        .frame(width: 100, height: 100)
                        .cornerRadius(10)
                }
            }
        }
    }
}

#Preview {
    ContentView()
}
//
//  MockData.swift
//  ColourGeneratorApp
//
//  Created by WilliamJiamin on 2024/6/19.
//

import Foundation
import SwiftUI

struct MockData {
    static var colors: [Color] {
        var array: [Color] = []
        for _ in 0..<100 {
            array.append(Color.random)}
        return array

    } 
}
//
//  Color+Random.swift
//  ColourGeneratorApp
//
//  Created by WilliamJiamin on 2024/6/19.
//

import Foundation
import SwiftUI

extension Color {
    static var random: Color {
        return Color(
            red: .random(in: 0...1),
            green: .random(in: 0...1),
            blue: .random(in: 0...1)
        )
    }

}