Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB16250655: Alert buttons should support loading states for async tasks #591

Open
samhenrigold opened this issue Jan 6, 2025 · 0 comments

Comments

@samhenrigold
Copy link

  • Date: 2025-01-06
  • Resolution: Open
  • Area: SwiftUI
  • OS: iOS
  • Type: Suggestion
  • Keywords: .alert ProgressView

Description

SwiftUI alerts currently lack support for showing loading states when performing asynchronous tasks, which makes it difficult to provide feedback during operations that take time to complete. See attachment for what my ideal outcome looks like.

Current Behavior:
When using SwiftUI alerts with buttons that trigger async operations (like saving data or making network requests), there's no great way to:

  • Show a loading indicator on the action button
  • Disable user input while processing
  • Keep the cancel button active for aborting the operation

For example, consider a "Rename Item" alert with a text field:

  1. User enters new name in text field
  2. User taps "Save" button
  3. App needs to perform async operation (e.g., API call, some file operation over the network)
    During this time, I would want to:
    • Replace "Save" button with progress indicator
    • Disable text field during save
    • Keep "Cancel" button enabled for abort option

There’s a hacky workaround at the moment, but it’s anything but elegant.

Files

AlertWithActivityView

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant