//
//  BluetoothHelperView.swift
//  USB Meter
//
//  Created by Bogdan Timofte on 07/03/2020.
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
//

import SwiftUI
import CoreBluetooth

struct DeviceHelpView: View {
    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 14) {
                Text("Device Checklist")
                    .font(.system(.title3, design: .rounded).weight(.bold))
                    .frame(maxWidth: .infinity, alignment: .leading)
                    .padding(18)
                    .meterCard(tint: .orange, fillOpacity: 0.18, strokeOpacity: 0.24)

                helpCard(
                    title: "Power",
                    body: "Make sure the meter itself is powered on before trying to connect."
                )
                helpCard(
                    title: "Bluetooth",
                    body: "Confirm Bluetooth is enabled on the device and not disabled from the meter menu."
                )
                helpCard(
                    title: "Existing Connection",
                    body: "If the meter is already connected elsewhere, disconnect it first and then retry from the app."
                )
            }
            .padding()
        }
        .background(
            LinearGradient(
                colors: [.orange.opacity(0.14), Color.clear],
                startPoint: .topLeading,
                endPoint: .bottomTrailing
            )
            .ignoresSafeArea()
        )
        .navigationTitle("Device Help")
        .navigationBarTitleDisplayMode(.inline)
        .sidebarToggleToolbarItem()
    }

    private func helpCard(title: String, body: String) -> some View {
        VStack(alignment: .leading, spacing: 6) {
            Text(title)
                .font(.headline)
            Text(body)
                .font(.footnote)
                .foregroundColor(.secondary)
        }
        .frame(maxWidth: .infinity, alignment: .leading)
        .padding(18)
        .meterCard(tint: .orange, fillOpacity: 0.14, strokeOpacity: 0.20)
    }
}
