Home > database >  SwiftUI Text Field Integer/Decimal Problem
SwiftUI Text Field Integer/Decimal Problem

Time:04-02

I'm trying to suss out a problem I'm having. Basically, I have a text field for medical lab values, and I want it to display a symbol when out of range (out of normal medical limits) and another symbol when within normal range. These values are then used in formulae in another view in the app.

This is now my second post on this platform, so please forgive any posting faux pas, I'm trying to adhere to the rules as best as possible re: minimum reproducible and making sure my code is formatted properly in the posting. Here's what I have so far:

import SwiftUI

struct EntryMRE: View {
    @Environment(\.managedObjectContext) private var viewContext
    
@State private var showingResults: Int? = 1

@FocusState private var isTextFieldFocused: Bool
@State var isDone = false

@State var isSaving = false //used to periodically save data
@State var saveInterval: Int = 5 //after how many seconds the data is automatically saved

//DataPoints Chemistry
@State var potassium = ""


var body: some View {
    List {
        Section(header: Text("           
  • Related