//
//  MeterNameEditorView.swift
//  USB Meter
//

import SwiftUI

struct MeterNameEditorView: View {
    @EnvironmentObject private var meter: Meter

    @Binding var editingName: Bool
    @State var newName: String

    var body: some View {
        TextField("Name", text: self.$newName, onCommit: {
            self.meter.name = self.newName
            self.editingName = false
        })
        .textFieldStyle(RoundedBorderTextFieldStyle())
        .lineLimit(1)
        .disableAutocorrection(true)
        .multilineTextAlignment(.center)
    }
}