//
//  MenuAboutAppView.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2023/12/14.
//

import SwiftUI
import PDFKit

struct MenuAboutAppView: View {
    @Binding var path : [MenuPath]
    let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String

    var body: some View {
        VStack{
            MenuTitleView(path: $path, title: MenuPath.AboutApp.title)
            HStack {
                VStack(alignment: .leading, spacing: 10){
                    Text("Version")
                        .font(FontStyle.EmphasisText.font)
                        .foregroundColor(ColorSet.BodyDescriptiion.color)
#if CANARY
                    Text("\(version)" + " Canary")
                        .font(FontStyle.EmphasisText.font)
                        .foregroundColor(ColorSet.Body.color)
#elseif QC
                    Text("\(version)" + " QC")
                        .font(FontStyle.TitleS.font)
                        .foregroundColor(ColorSet.Body.color)
#else
                    Text("\(version)")
                        .font(FontStyle.TitleS.font)
                        .foregroundColor(ColorSet.Body.color)
#endif
                }
                .padding(.horizontal, 30)
                .padding(.vertical, 17)
                Spacer()
            }
            Divider()
                .background(ColorSet.LineColor04.color)

            Spacer().frame(height: 50)

            Text("Policy")
                .font(FontStyle.EmphasisText.font)
                .foregroundColor(ColorSet.BodyDescriptiion.color)
                .frame(maxWidth: .infinity, alignment: .leading)
                .padding(.leading, 30)

            Divider()
                .background(ColorSet.LineColor04.color)
            Button{
                path.append(.TermsOfUse)
            }label: {
                MenuContentView(content: .TermsOfUse)
            }
            Button{
                path.append(.PrivacyStatement)
            }label: {
                MenuContentView(content: .PrivacyStatement)
            }

            Spacer().frame(height: 50)
            Text("Open Source Licenses")
                .font(FontStyle.EmphasisText.font)
                .foregroundColor(ColorSet.BodyDescriptiion.color)
                .frame(maxWidth: .infinity, alignment: .leading)
                .padding(.leading, 30)

            Divider()
                .background(ColorSet.LineColor04.color)

            Text("Azure Notification Hubs SDK for Apple")
                .font(FontStyle.EmphasisText.font)
                .foregroundColor(ColorSet.Body.color)
                .frame(maxWidth: .infinity, alignment: .leading)
                .padding(.leading, 30)
            Spacer()
        }
        .background(ColorSet.BackgroundPrimary.color)
    }
}

#Preview {
    MenuAboutAppView(path: .constant([.AboutApp]))
}
