{"id":13484538,"url":"https://github.com/elai950/AlertToast","last_synced_at":"2025-03-27T16:30:58.505Z","repository":{"id":37263143,"uuid":"337490001","full_name":"elai950/AlertToast","owner":"elai950","description":"Create Apple-like alerts \u0026 toasts using SwiftUI","archived":false,"fork":false,"pushed_at":"2024-07-16T09:15:17.000Z","size":12075,"stargazers_count":2098,"open_issues_count":26,"forks_count":193,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-29T15:33:48.035Z","etag":null,"topics":["alert","alert-controller","alert-toast","alert-toast-swiftui","apple","apple-music","dialog","error-alert","image-alert","popup","swift","swiftui","toast","toast-alert","ui-components","xcode"],"latest_commit_sha":null,"homepage":"https://elai950.github.io/AlertToast/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elai950.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"elaiz","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-02-09T17:55:34.000Z","updated_at":"2024-10-29T15:27:02.000Z","dependencies_parsed_at":"2024-01-16T12:46:57.283Z","dependency_job_id":"ea6366fa-b850-44f1-a670-d0b424c6ae23","html_url":"https://github.com/elai950/AlertToast","commit_stats":{"total_commits":260,"total_committers":12,"mean_commits":"21.666666666666668","dds":"0.31153846153846154","last_synced_commit":"638f38f9daf08e17b7caea22d2fcb9c0a418d1b6"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elai950%2FAlertToast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elai950%2FAlertToast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elai950%2FAlertToast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elai950%2FAlertToast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elai950","download_url":"https://codeload.github.com/elai950/AlertToast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245562956,"owners_count":20635907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alert","alert-controller","alert-toast","alert-toast-swiftui","apple","apple-music","dialog","error-alert","image-alert","popup","swift","swiftui","toast","toast-alert","ui-components","xcode"],"created_at":"2024-07-31T17:01:25.815Z","updated_at":"2025-03-27T16:30:58.498Z","avatar_url":"https://github.com/elai950.png","language":"Swift","funding_links":["https://patreon.com/elaiz","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=5JN5PT55NAHKU"],"categories":["Swift","iOS","Alert","2、技术示范","四、开源库精选（解决80%开发场景，附核心优势）","UI"],"sub_categories":["Android samples","Content","2.2 开发必备的非官方控件","6. 加载与提示","Toast"],"readme":"# AlertToast-SwiftUI [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Get%20over%20170%20free%20design%20blocks%20based%20on%20Bootstrap%204\u0026url=https://froala.com/design-blocks\u0026via=froala\u0026hashtags=bootstrap,design,templates,blocks,developers)\n### Present Apple-like alert \u0026 toast in SwiftUI\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/elai950/AlertToast/blob/master/Assets/GithubCoverNew.png\" width=\"480\"/\u003e\n\u003c/p\u003e\n\n## 🌄 Example\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/elai950/AlertToast/blob/master/Assets/onboarding.png\" style=\"display: block; margin: auto;\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/elai950/AlertToast/blob/master/Assets/ToastExample.gif\" style=\"display: block; margin: auto;\" width=\"180\"/\u003e\n\u003c/p\u003e\n\n## 🔭 Overview\n\nCurrently in SwiftUI, the only way to inform the user about some process that finished for example, is by using `Alert`. Sometimes, you just want to display a message that tells the user that something has completed or that their message was sent. Apple doesn't provide any method other than using Alert, even though they use various types of pop-ups. This results in poor UX, as the user must tap 'OK' or 'Dismiss' for every piece of information they should be notified about\n\nAlert Toast is an open-source library in Github to use with SwiftUI. It allows you to present popups that don't need any user action to dismiss or to validate. Some great usage examples: `Message Sent`, `Poor Network Connection`, `Profile Updated`, `Logged In/Out`, `Favorited`, `Loading` and so on...\n\n\u003cimg src=\"https://img.shields.io/badge/BUILD-1.3.9-green?style=for-the-badge\" /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cimg src=\"https://img.shields.io/badge/PLATFORM-IOS%20|%20MACOS-lightgray?style=for-the-badge\" /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cimg src=\"https://img.shields.io/badge/LICENSE-MIT-lightgray?style=for-the-badge\" /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cimg src=\"https://img.shields.io/badge/MADE WITH-SWIFTUI-orange?style=for-the-badge\" /\u003e\n\n* Built with pure SwiftUI.\n* 3 Display modes: `Alert` (pop at the center), `HUD` (drop from the top) and `Banner` (pop/slide from the bottom).\n* `Complete`, `Error` `SystemImage`, `Image`, `Loading`, and `Regular` (Only Text).\n* Supports Light \u0026 Dark Mode.\n* Works with **any** kind of view builder.\n* Localization support.\n* Font \u0026 Background customization.\n\n#### If you like the project, don't forget to `put star 🌟`.\n\n\u003ca href=\"mailto:elai950@gmail.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/EMAIL-ELAI-informational?style=for-the-badge\u0026logo=minutemailer\u0026logoColor=white\"\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"https://www.linkedin.com/in/elai-zuberman-8120a073/\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/LINKEDIN-informational?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\" \u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=5JN5PT55NAHKU\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Donate-informational?style=for-the-badge\u0026logo=paypal\u0026logoColor=white\" \u003e\u003c/a\u003e\n\n₿ Bitcoin donation address:\n```\n0xec48bfa813a773fa2394aec23f97da5cb4d5ff02\n```\n- Send only BTC to this deposit address.\n- Ensure the network is BNB Smart Chain (BEP20).\n\n## Navigation\n\n- [Installation](#-installation)\n    - [CocoaPods](#cocoapods)\n    - [Swift Package Manager](#swift-package-manager)\n    - [Manually](#manually)\n- [Usage](#-usage)\n    - [Usage example with regular alert](#usage-example-with-regular-alert)\n    - [Complete Modifier Example](#complete-modifier-example)\n    - [Alert Toast Parameters](#alert-toast-parameters)\n - [Article](#-article)\n - [Contributing](#-contributing)\n - [Author](#-author)\n - [License](#-license)\n\n## 💻 Installation\n\n### Cocoapods\n\n[AlertToast Cocapods Website](https://cocoapods.org/pods/AlertToast)\n\nCocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate `AlertToast` into your Xcode project using CocoaPods, specify it in your Podfile:\n\n```ruby\npod 'AlertToast'\n```\n\n------\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.\n\nTo integrate `AlertToast` into your Xcode project using Xcode 12, specify it in `File \u003e Swift Packages \u003e Add Package Dependency...`:\n\n```ogdl\nhttps://github.com/elai950/AlertToast.git, :branch=\"master\"\n```\n\nFor Xcode 13, please refer [this article](https://iiroalhonen.medium.com/adding-a-swift-package-dependency-in-xcode-13-937b2caaf218) to install `AlertToast` \n\n------\n\n### Manually\n\nIf you prefer not to use any of dependency managers, you can integrate `AlertToast` into your project manually. Put `Sources/AlertToast` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.\n\n## 🧳 Requirements\n\n- iOS 13.0+ | macOS 11+\n- Xcode 12.0+ | Swift 5+\n\n## 🛠 Usage\n\nFirst, add `import AlertToast` on every `swift` file you would like to use `AlertToast`.\n\nThen, use the `.toast` view modifier:\n\n**Parameters:**\n\n- `isPresenting`: (MUST) assign a `Binding\u003cBool\u003e` to show or dismiss alert.\n- `duration`: default is 2, set 0 to disable auto dismiss.\n- `tapToDismiss`: default is `true`, set `false` to disable.\n- `alert`: (MUST) expects `AlertToast`.\n\n#### Usage example with regular alert\n\n```swift \nimport AlertToast\nimport SwiftUI\n\nstruct ContentView: View{\n\n    @State private var showToast = false\n\n    var body: some View{\n        VStack{\n\n            Button(\"Show Toast\"){\n                 showToast.toggle()\n            }\n        }\n        .toast(isPresenting: $showToast){\n\n            // `.alert` is the default displayMode\n            AlertToast(type: .regular, title: \"Message Sent!\")\n            \n            //Choose .hud to toast alert from the top of the screen\n            //AlertToast(displayMode: .hud, type: .regular, title: \"Message Sent!\")\n            \n            //Choose .banner to slide/pop alert from the bottom of the screen\n            //AlertToast(displayMode: .banner(.slide), type: .regular, title: \"Message Sent!\")\n        }\n    }\n}\n```\n\n#### Complete Modifier Example\n\n```swift\n.toast(isPresenting: $showAlert, duration: 2, tapToDismiss: true, alert: {\n   //AlertToast goes here\n}, onTap: {\n   //onTap would call either if `tapToDismis` is true/false\n   //If tapToDismiss is true, onTap would call and then dismis the alert\n}, completion: {\n   //Completion block after dismiss\n})\n```\n\n### Alert Toast Parameters\n\n```swift\nAlertToast(displayMode: DisplayMode,\n           type: AlertType,\n           title: Optional(String),\n           subTitle: Optional(String),\n           style: Optional(AlertStyle))\n           \n//This is the available customizations parameters:\nAlertStyle(backgroundColor: Color?,\n            titleColor: Color?,\n            subTitleColor: Color?,\n            titleFont: Font?,\n            subTitleFont: Font?)\n```\n\n#### Available Alert Types:\n- **Regular:** text only (Title and Subtitle).\n- **Complete:** animated checkmark.\n- **Error:** animated xmark.\n- **System Image:** name image from `SFSymbols`.\n- **Image:** name image from Assets.\n- **Loading:** Activity Indicator (Spinner).\n\n#### Alert dialog view modifier (with default settings):\n```swift\n.toast(isPresenting: Binding\u003cBool\u003e, duration: Double = 2, tapToDismiss: true, alert: () -\u003e AlertToast , onTap: () -\u003e (), completion: () -\u003e () )\n```\n\n#### Simple Text Alert:\n```swift\nAlertToast(type: .regular, title: Optional(String), subTitle: Optional(String))\n```\n\n#### Complete/Error Alert:\n```swift\nAlertToast(type: .complete(Color)/.error(Color), title: Optional(String), subTitle: Optional(String))\n```\n\n#### System Image Alert:\n```swift\nAlertToast(type: .systemImage(String, Color), title: Optional(String), subTitle: Optional(String))\n```\n\n#### Image Alert:\n```swift\nAlertToast(type: .image(String), title: Optional(String), subTitle: Optional(String))\n```\n\n#### Loading Alert:\n```swift\n//When using loading, duration won't auto dismiss and tapToDismiss is set to false\nAlertToast(type: .loading, title: Optional(String), subTitle: Optional(String))\n```\n\nYou can add many `.toast` on a single view.\n\n## 📖 Article\n\nI wrote an article that contains more usage examples.\n\n[Medium - How to toast an alert in SwiftUI](https://elaizuberman.medium.com/presenting-apples-music-alerts-in-swiftui-7f5c32cebed6)\n\n## 👨‍💻 Contributors\n\nAll issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated.\n\n- [@barnard-b](https://github.com/barnard-b)\n\n## ✍️ Author\n\nElai Zuberman\n\n## 📃 License\n\n`AlertToast` is available under the MIT license. See the [LICENSE](https://github.com/elai950/AlertToast/blob/master/LICENSE.md) file for more info.\n\n---\n\n- [Jump Up](#-overview)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felai950%2FAlertToast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felai950%2FAlertToast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felai950%2FAlertToast/lists"}