//
//  OnboardingTitle.swift
//  Feels (iOS)
//
//  Created by Trey Tartt on 1/20/22.
//

import SwiftUI

struct OnboardingTitle: View {
    static let titleOptions = [
        String(localized: "onboarding_title_title_option_1"),
        String(localized: "onboarding_title_title_option_2"),
        String(localized: "onboarding_title_title_option_3")]
    
    @ObservedObject var onboardingData: OnboardingData
    
    var body: some View {
        ZStack {
            
            Image("average", bundle: .main)
                .foregroundColor(Color(UIColor.darkText))
                .opacity(0.04)
                .scaleEffect(1.2)
                .padding(.bottom, 55)
            
            ScrollView {
                VStack{
                    Text(String(localized: "onboarding_title_title"))
                        .font(.title)
                        .foregroundColor(Color(UIColor.white))
                        .padding([.trailing, .leading], 55)
                        .padding([.top], 25)
                    
                    ForEach(OnboardingTitle.titleOptions, id: \.self) { option in
                        Button(action: {
                            onboardingData.title = option
                        }, label: {
                            Text(option)
                                .font(.system(size: 15))
                                .fontWeight(.bold)
                                .foregroundColor(.white)
                                .padding(10)
                                .background(RoundedRectangle(cornerRadius: 10).stroke().foregroundColor(Color.white))
                                .cornerRadius(10)
                        })
                            .buttonStyle(PlainButtonStyle())
                            .padding([.top], 10)
                    }
                    
                    Text(String(localized: "onboarding_title_type_your_own"))
                        .font(.body)
                        .foregroundColor(Color(UIColor.white))
                        .padding([.top], 25)
                        .padding([.trailing, .leading], 55)
                    
                    TextField("Notification", text: $onboardingData.title)
                        .frame(height: 44)
                        .foregroundColor(Color(UIColor.white))
                        .textFieldStyle(PlainTextFieldStyle())
                        .padding([.leading, .trailing], 4)
                        .cornerRadius(16)
                        .overlay(RoundedRectangle(cornerRadius: 16).stroke(Color.white))
                        .padding([.leading, .trailing], 75)
                        .padding([.top], 45)
                    
                    Spacer()
                }
            }
        }
        .background(.orange)
    }
}

struct OnboardingTitle_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            OnboardingTitle(onboardingData: OnboardingData())
            
            OnboardingTitle(onboardingData: OnboardingData())
                .preferredColorScheme(.dark)
        }
    }
}
