.toolbar { ToolbarItemGroup(placement: .keyboard) { Spacer() Button(action: { if let currentFavesIndex: Int = dataModel.faves.firstIndex(where: { $0.id == focus }) { // found match on first text field in row withAnimation(.easeInOut(duration: 0.3)) { proxy.scrollTo(dataModel.faves[max(currentFavesIndex - 2, 0)].id) } let previousFave = dataModel.faves[max(currentFavesIndex - 1, 0)] DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { focus = (currentFavesIndex > 0) ? previousFave.favoriteID : previousFave.id } } else if let currentFavesIndex: Int = dataModel.faves.firstIndex(where: { $0.favoriteID == focus }) { // found match on second text field in row DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { focus = dataModel.faves[currentFavesIndex].id } } }) { Text("Previous") .padding(.horizontal, 5) } .tint(Color(UIColor.systemGray3)) .buttonStyle(.borderedProminent) .buttonBorderShape(.roundedRectangle) .controlSize(.small) Button(action: { if let currentFavesIndex: Int = dataModel.faves.firstIndex(where: { $0.id == focus }) { // found match on first text field in row DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { focus = dataModel.faves[currentFavesIndex].favoriteID } } else if let currentFavesIndex: Int = dataModel.faves.firstIndex(where: { $0.favoriteID == focus }) { // found match on second text field in row withAnimation(.easeInOut(duration: 0.3)) { proxy.scrollTo(dataModel.faves[min(currentFavesIndex + 2, dataModel.faves.count - 1)].id) } let nextFave = dataModel.faves[ min(currentFavesIndex + 1, dataModel.faves.count - 1) ] DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { focus = (currentFavesIndex < dataModel.faves.count - 1) ? nextFave.id : nextFave.favoriteID } } }) { Text("Next") .padding(.horizontal, 5) } .tint(Color(UIColor.systemGray3)) .buttonStyle(.borderedProminent) .buttonBorderShape(.roundedRectangle) .controlSize(.small) .padding(.horizontal, 20) }