//
//  DetailNavigationBar.swift
//  SodaLive
//
//  Created by klaus on 2023/08/09.
//

import SwiftUI

struct DetailNavigationBar: View {
    
    let title: String
    var backAction: (() -> Void)? = nil
    
    var body: some View {
        HStack(spacing: 0) {
            Button {
                if let backAction = backAction {
                    backAction()
                } else {
                    AppState.shared.back()
                }
            } label: {
                Image("ic_back")
                    .resizable()
                    .frame(width: 20, height: 20)
                
                Text(title)
                    .font(.custom(Font.bold.rawValue, size: 18.3))
                    .foregroundColor(Color(hex: "eeeeee"))
            }
            
            Spacer()
        }
        .padding(.horizontal, 13.3)
        .frame(height: 50)
        .background(Color.black)
    }
}

struct DetailNavigationBar_Previews: PreviewProvider {
    static var previews: some View {
        DetailNavigationBar(title: "이전으로")
    }
}