//
//  TermsView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/10.
//

import SwiftUI
import RichText

struct TermsView: View {
    
    let isPrivacyPolicy: Bool
    
    @ObservedObject var viewModel = TermsViewModel()
    
    var body: some View {
        BaseView(isLoading: $viewModel.isLoading) {
            VStack(spacing: 0) {
                DetailNavigationBar(title: viewModel.title)
                
                ScrollView(.vertical, showsIndicators: false) {
                    RichText(html: viewModel.description)
                        .frame(width: screenSize().width - 26.7)
                }
            }
        }
        .onAppear {
            if isPrivacyPolicy {
                viewModel.getPrivacyPolicy()
            } else {
                viewModel.getTermsOfService()
            }
        }
    }
}

struct TermsView_Previews: PreviewProvider {
    static var previews: some View {
        TermsView(isPrivacyPolicy: false)
    }
}
