The view is being condensed instead of moved up when the keyboard is presented. It works as expected in portrait mode, the issue only presents in landscape mode. Photos attached for clarification. I have tried .edgesIgnoreSafeArea()
, along with the solutions presented on this thread.
VStack {
Text("\(titleText)")
.font(.system(size: 30))
.bold()
VStack {
Text("Item Title")
TextField("Item Title", text: $title)
.formStyle()
}
VStack {
Text("Item Description")
TextField("Item Description", text: $itemDescription)
//TextEditor(text: $itemDescription)
.formStyle()
}
VStack {
Text("Unit Type")
TextField("Each, Total, Hours, LF, etc...", text: $unitType)
.formStyle()
}
VStack {
Text("Unit Cost")
TextField("Cost per unit", text: $unitCost, onEditingChanged: { (isChanged) in
guard !unitCost.isEmpty else { return }
//Ensuring entered text can be converted to required double
if let _ = Double(unitCost) {
isUnitCostValid = true
} else {
isUnitCostValid = false
unitCost = ""
alertTitle = .unitCostError
alertMessage = "Not a valid Unit Cost. Please enter only numbers."
showingAlert = true
}
})
.keyboardType(.numberPad)
.formStyle()
}
Spacer()
Button("\(saveText)") {
//code to print to console coredata path for device
// print(FileManager.default.urls(for: .documentDirectory, in: .userDomainMask))
addNewItem()
}
.font(.system(size: 30))
.frame(maxWidth: 400, maxHeight: 100)
.foregroundColor(.white)
.background(Color.blue)
.clipShape(Capsule())
.disabled(isDisabled)
.opacity(isDisabled ? 0.7 : 1)
.alert(isPresented: $showingAlert) {
Alert(title: Text(alertTitle.rawValue), message: Text(alertMessage), dismissButton: .default(Text("OK"), action: {
if case .saved = alertTitle {
settingsPopper.popToSettings()
//use presentationMode... if not using our custom popper
//presentationMode.wrappedValue.dismiss()
}
}))
}
}
Any ideas?