//
//  LoadingView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/09.
//

import SwiftUI

struct LoadingView: View {
    var body: some View {
        ZStack {
            Color.primary.opacity(0.2)
                .ignoresSafeArea()
            
            ZStack {
                ActivityIndicatorView()
                    .frame(width: 100, height: 100)
            }
            .frame(width: 150, height: 150)
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
}

struct LoadingView_Previews: PreviewProvider {
    static var previews: some View {
        LoadingView()
    }
}

struct ActivityIndicatorView: UIViewRepresentable {
    func makeUIView(context: Context) -> some UIActivityIndicatorView {
        let activityIndicator = UIActivityIndicatorView(style: .large)
        activityIndicator.color = UIColor(hex: "80D8FF")
        return activityIndicator
    }
    
    func updateUIView(_ uiView: UIViewType, context: Context) {
        uiView.startAnimating()
    }
}

