|
Bogdan Timofte
authored
a week ago
|
1
|
//
|
|
Bogdan Timofte
authored
a week ago
|
2
|
// MeterNameEditorView.swift
|
|
Bogdan Timofte
authored
a week ago
|
3
|
// USB Meter
|
|
|
4
|
//
|
|
|
5
|
|
|
|
6
|
import SwiftUI
|
|
|
7
|
|
|
Bogdan Timofte
authored
a week ago
|
8
|
struct MeterNameEditorView: View {
|
|
Bogdan Timofte
authored
a week ago
|
9
|
@EnvironmentObject private var meter: Meter
|
|
|
10
|
|
|
|
11
|
@Binding var editingName: Bool
|
|
|
12
|
@State var newName: String
|
|
|
13
|
|
|
|
14
|
var body: some View {
|
|
|
15
|
TextField("Name", text: self.$newName, onCommit: {
|
|
|
16
|
self.meter.name = self.newName
|
|
|
17
|
self.editingName = false
|
|
|
18
|
})
|
|
|
19
|
.textFieldStyle(RoundedBorderTextFieldStyle())
|
|
|
20
|
.lineLimit(1)
|
|
|
21
|
.disableAutocorrection(true)
|
|
|
22
|
.multilineTextAlignment(.center)
|
|
|
23
|
}
|
|
|
24
|
}
|