//
//  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.SupplementText.font)
                        .foregroundColor(ColorSet.BodyDescriptiion.color)
#if CANARY
                    Text("\(version)" + " Canary")
                        .font(FontStyle.SupplementText.font)
                        .foregroundColor(ColorSet.Body.color)
                        .padding(.leading, 20)
#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.SupplementText.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)
//            }
//            .padding(.leading, 20)
//
//            Button{
//                path.append(.PrivacyStatement)
//            }label: {
//                MenuContentView(content: .PrivacyStatement)
//            }
//            .padding(.leading, 20)

            HStack {
                NavigationLink {
                    LocalWebView(policy: .constant(.TermsOfUse))
                } label: {
                    Text("Terms Of Use")
                        .font(FontStyle.EmphasisText.font)
                        .foregroundColor(ColorSet.Body.color)

                    Spacer()

                    Image("ink_01")
                        .resizable()
                        .frame(width: 22, height: 22)
                }
                .padding(.vertical, 17)
                .padding(.horizontal, 30)
            }

            HStack {
                NavigationLink {
                    LocalWebView(policy: .constant(.PrivacyStatement))
                } label: {
                    Text("Privacy Statement")
                        .font(FontStyle.EmphasisText.font)
                        .foregroundColor(ColorSet.Body.color)

                    Spacer()

                    Image("ink_01")
                        .resizable()
                        .frame(width: 22, height: 22)
                }
                .padding(.vertical, 17)
                .padding(.horizontal, 30)
            }

            Spacer().frame(height: 50)
            Text("Open Source Licenses")
                .font(FontStyle.SupplementText.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, 50)
                .padding(.top, 17)

            VStack(spacing: 30) {
                Link("https://github.com/Azure/azure-notificationhubs-ios/blob/main/LICENSE", destination: URL(string: HttpRequestType.ApachLicens.rawValue)!)
            }
            .padding(.top, 2)
            .padding(.horizontal, 50)
            .font(FontStyle.RadioButtonText.font)
            .foregroundColor(ColorSet.Body.color)
            Spacer()
        }
        .background(ColorSet.BackgroundPrimary.color)
    }
}

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