//
//  ViaryItemView.swift
//  iosApp
//
//  Created by Fumiya Tanaka on 2021/05/20.
//  Copyright © 2021 orgName. All rights reserved.
//

import SwiftUI
import shared

struct ViaryItemView: View {
    
    let viary: Viary
    let isExpand: Bool
    
    var body: some View {
        VStack(alignment: .leading) {
            HStack {
                Text(viary.title).bold().foregroundColor(.textColor)
                Spacer()
            }
            if isExpand {
                HStack {
                    Text(viary.content)
                        .fontWeight(.light)
                        .lineLimit(nil)                       
                    Spacer()
                }
                .padding()
                .background(Color.mainColor)
                .foregroundColor(.backgroundColor)
                .cornerRadius(8)
            }
        }
        .contentShape(Rectangle())
    }
}

struct ViaryItemView_Previews: PreviewProvider {
    static var previews: some View {
        ViaryItemView(viary: Viary(id: 0, title: "Test", content: "Content", date: SharedDatetimeInstant().shareCurrentInstant()), isExpand: true)
    }
}
