//
//  MenuInfomarionView.swift
//  Sailassist
//
//  Created by Mamoru Sugita on 2023/12/26.
//

import SwiftUI

struct MenuInfomarionView: View {
    @Binding var path : [MenuPath]

    var body: some View {
        VStack{
//            MenuTitleView(path: $path, title: MenuPath.Information.title)
            
            ScrollView{
                VStack(spacing: 0){
                    InformationView(title: "半角文字", bodyStr: String(repeating: halfString, count: 157))
                    InformationView(title: "全角文字", bodyStr: String(repeating: halfString2, count: 82))
                }
                .padding()
                .background(.black)
            }
        }
    }
    
    
    private struct InformationView: View {
        var title: String
        var bodyStr: String
        @State var isExtend = false
        var body: some View {
            VStack(alignment: .leading, spacing: 0){
                HStack{
                    Text(title)
                        .foregroundColor(.white)
                    
                    Spacer()
                    
                    Button {
                        isExtend.toggle()
                    } label: {
                        Image(systemName: isExtend ? "plus" : "minus")
                            .foregroundColor(.white)
                    }
                    
                }
                .padding()
                .background(.gray)
                
                if isExtend {
                    Text(bodyStr)
                        .multilineTextAlignment(.leading)
                        .padding(EdgeInsets(top: 5, leading: 10, bottom: 5, trailing: 10))
                }
            }
            .background(.white)
            
        }
    }
}

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


let halfString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
let halfString2 = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"
