My app has a SwiftUI View that contains both a TextEditor to collect a log entry and a List containing past entries.
When the text editor has a non-empty string, a button is presented to process the entry, add it to the data populating the list, and reset the TextEditor. Presently the button appears suddenly whenever text is typed, and I would love to animate that more smoothly, perhaps by fading in the opacity or scaling up the button. However, I can't figure out where to enter that animation.
@State var newEntryString = "" var body: some View { NavigationView{ VStack{ Text("Create a new log entry.") .padding() TextEditor(text: $newEntryString) .cornerRadius(3.0) .padding() .border(Color.gray, width: 1) .frame(minWidth: 0, idealWidth: 100, maxWidth: .infinity, minHeight: 0, idealHeight: 100, maxHeight: 150, alignment: .center) HStack { Spacer() if !newEntryString.isEmpty{ Button(action: { addEntry() }) { Text("Add Entry") }.buttonStyle(JournalButtonStyle()) .animation(Animation.default.speed(1)) } } Divider() List { ForEach(entrys) { item in Text(item.timestamp!, formatter: entryFormatter).font(.footnote) .foregroundColor(.gray) .padding(.bottom, -10) Text((item.entryString!)) } .onDelete(perform: deleteEntrys) }.onTapGesture { UIApplication.shared.endEditing() }