{"id":24714429,"url":"https://github.com/ml-opensource/rye","last_synced_at":"2025-12-11T23:00:16.627Z","repository":{"id":47360710,"uuid":"190000337","full_name":"ml-opensource/Rye","owner":"ml-opensource","description":"A framework for displaying non intrusive alerts to your users","archived":false,"fork":false,"pushed_at":"2022-10-06T15:16:58.000Z","size":364,"stargazers_count":13,"open_issues_count":1,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-24T06:50:01.644Z","etag":null,"topics":["ios","snackbar","snackbar-ios","swift","toast"],"latest_commit_sha":null,"homepage":"","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/ml-opensource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-03T12:25:36.000Z","updated_at":"2024-05-23T13:00:01.000Z","dependencies_parsed_at":"2022-08-17T22:45:25.072Z","dependency_job_id":null,"html_url":"https://github.com/ml-opensource/Rye","commit_stats":null,"previous_names":["nodes-ios/rye"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ml-opensource/Rye","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-opensource%2FRye","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-opensource%2FRye/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-opensource%2FRye/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-opensource%2FRye/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ml-opensource","download_url":"https://codeload.github.com/ml-opensource/Rye/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ml-opensource%2FRye/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001443,"owners_count":26083078,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ios","snackbar","snackbar-ios","swift","toast"],"created_at":"2025-01-27T08:16:34.434Z","updated_at":"2025-10-09T12:31:32.876Z","avatar_url":"https://github.com/ml-opensource.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍞 Rye\n\n![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange)\n[![Carthage Compatible](https://img.shields.io/badge/carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Rye.svg)](https://cocoapods.org/pods/Rye)\n![Platforms](https://img.shields.io/badge/platforms-iOS%20-lightgrey.svg)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nodes-ios/Rye/blob/master/LICENSE)\n\n\n## Intro\n\nRye allows you to present non intrusive alerts to your users.\n\nYou can choose to display the default Rye alert type or go fully custom and display your own `UIView`.\n\n### Examples\n\n\n| ![](ExampleImages/example1.png) | ![](ExampleImages/example2.png)  | ![](ExampleImages/example3.png)  |\n|----------------|---|---|\n|      \u003ccenter\u003eCustom Rye alert with Image\u003c/center\u003e      |  \u003ccenter\u003eCustom Rye alert with Button\u003c/center\u003e  |  \u003ccenter\u003eDefault Rye alert\u003c/center\u003e |\n\n## 📝 Requirements\n\niOS 11.4  \nSwift 5\n\n## 📦 Installation\n\n### Swift Package Manager\nCopy this repository URL, and add the repo into your Package Dependencies:\n```\nhttps://github.com/nodes-ios/Rye.git\n```\n\n### Carthage\n```bash\ngithub \"nodes-ios/Rye\"\n```\n\n### Cocoapods\n```bash\npod 'Rye'\n```\n\n## 💻 Usage\n\n### Principles\n\nTo display a Rye alert you declare a new `RyeViewController` and then call:\n\n- `show()`: to show the alert\n- `dismiss()`: to dismiss the alert\n\n**Note:** Depending on which `dismissMode` you have selected, you may not need to dismiss the alert yourself, see the section about [`displayModes`](#display-modes) below for more information.\n\nAt the very minimum you need to consider:\n\n- which text to show\n- whether to show a standard alert or bring your own custom view to the party\n- where to show the alert (`top` or `bottom`)\n\n#### Show Text\n\nTo show a text using a Rye alert you need to create a `RyeConfiguration`. This is a dictionary allowing you to configure various UI related aspects of your Rye alert. For more information on available keys, please refer to the [Possible Rye Configuration Values](#possible-rye-configuration-values) section.\n\nOne of the values you can add to a `RyeConfiguration` is a text to show in your alert.\n\n```swift\nlet ryeConfiguration: RyeConfiguration = [ Rye.Configuration.Key.text: \"Message for the user\" ]\n```\n\n#### Alert Type\n\nYou can use the default Rye alert or you can create your own UIView and use that instead. To determine which to use, you use the `Rye.ViewType` enum defined like so:\n\n```swift\npublic enum ViewType {\n    case standard(configuration: RyeConfiguration?)\n    case custom(UIView, configuration: RyeConfiguration?)\n}\n```\n\nAs you can see, both the `standard` and the `custom` ViewType takes an optional `RyeConfiguration` as a parameter. This means that you don't _have_ to provide a `RyeConfiguration` in which case default values will be used for all parameters including the text (but you probably don't want an alert showing the text \"Add a message\", do you?).\n\n Additionally, the `custom` ViewType takes your custom UIView that you would like to use. \n \n Note that some of the `RyeConfiguration` keys are not relevant when using a custom view. More specificaly, these are the keys not used when you decide to use a `custom` view for your message:\n\n - backgroundColor\n - textColor\n - textFont\n - text\n - cornerRadius\n\n \n For more on the `AnimationType` please refer to the section [Animation Type](#animation-type) below.\n\n#### Where To Show the Alert?\n\nWhere to show a Rye alert is determined by the `Rye.Position` and `Rye.Alignment` enums which are defined like so:\n\n```swift\npublic enum Position {\n    case top(inset: CGFloat)\n    case bottom(inset: CGFloat)\n}\n```\n\n```swift\npublic enum Alignment {\n    case leading(inset: CGFloat)\n    case center\n    case trailing(inset: CGFloat)\n}\n```\n\nIf the alignment is not specified at init time, it will default to `.center` alignment.\n\nFor more on `Rye.Position` and `Rye.Alignment`, please refer to the section [Position \u0026 Alignment](#position-and-alignment) below.\n\n### Display a Default Rye\n\nFollowing these principles, we are now ready to show our first Rye alert.\n\n```swift\nimport Rye\n...\nlet ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text: \"Message for the user\"]\nlet rye = RyeViewController(\n   viewType: .standard(configuration: ryeConfiguration),\n   at: .bottom(inset: 16)\n)\nrye.show()\n```\n\nThis will result in a Rye alert with the text \"Message for the user\" appearing at the bottom of the screen, and then disappearing automatically after 2.5 seconds.\n\n### Control the Dismiss Type\n\nIf you would like the Rye alert to disappear in a different way, you can pass a `dismissMode` parameter when creating the `RyeViewController`\n\n```swift\nimport Rye\n...\nlet ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text: \"Message for the user\"]\nlet rye = RyeViewController(\n   dismissMode: .gesture,\n   viewType: .standard(configuration: ryeConfiguration),\n   at: .bottom(inset: 16)\n)\nrye.show()\n```\n\nThe alert will now stay on the screen until the user taps or swipes at it.\n\n### Display Default Rye with Custom Configuration\n\nIf you want to have more control over the alert view, you can add keys and values to the `RyeConfiguration` dictionary as shown below:\n\n```swift\nimport Rye\n...\nlet ryeConfiguration: RyeConfiguration = [\n    Rye.Configuration.Key.text: \"Error message for the user\",\n    Rye.Configuration.Key.backgroundColor: UIColor.red.withAlphaComponent(0.4),\n    Rye.Configuration.Key.animationType: Rye.AnimationType.fadeInOut\n]\n\nlet rye = RyeViewController(\n   viewType: .standard(configuration: ryeConfiguration),\n   at: .bottom(inset: 16)\n)\nrye.show()\n```\n\n### Display Rye with a Custom `UIView`\n\nFor even more control you can create your own subclass of `UIView` and use `.custom` for the `viewType` parameter\n\n```swift\nimport Rye\n...\n\nlet customView = YourCustomView()\nlet rye = RyeViewController(viewType: .custom(customView))\n\nrye.show()\n```\n\n### Dismiss Completion\nIf you would like to execute some code when the Rye alert is dismissed you can pass a `dismissCompletion` code block when calling `show` like so:\n\n```swift\nimport Rye\n...\nlet ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text: \"Message for the user\"]\nlet rye = RyeViewController(\n   viewType: .standard(configuration: ryeConfiguration),\n   at: .bottom(inset: 16)\n)\n\nrye.show(withDismissCompletion: {\n    print(\"Goodbye from Rye, time to dy..die\")  \n})\n```\n\n### Dismiss Rye Alerts Manually\n\nIf you have selected to show a Rye alert as `.nonDismissable` you have to dismiss it yourself. Keep a reference to the `RyeViewController` and call `dismiss` when you are ready to let go.\n\n```swift\nimport Rye\n...\nvar rye: RyeViewController?\n\nlet ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text: \"Message for the user\"]\nrye = RyeViewController(\n   dismissMode: .nonDismissable,\n   viewType: .standard(configuration: ryeConfiguration),\n   at: .bottom(inset: 16)\n)\n\nrye?.show()\n\n...at a later point in time\nrye?.dismiss()\n```\n\n### Descriptions of Parameters\n\nBelow you can find descriptions of the various parameters used to control a Rye alert.\n\n#### Display Modes\n\nRye supports three different `displayMode` values which can be passed when creating a new `RyeViewController`:\n\n- `automatic`: The alert appears and disappears automatically after a specified interval.\n- `gesture`: To dismiss the alert you can tap or swipe it.\n- `nonDismissable`: The alert will stay permanently on the screen until it is dismissed by calling `dismiss()` on your `RyeViewController` instance.\n\nIf you do not pass this value when creating a new `RyeViewController`, a default value of `automatic` with a default interval of 2.5 seconds is used (the default interval is defined in `Rye.defaultDismissInterval`)\n\n#### Position and Alignment\n\nYou can specify if the Rye alert should be shown at the top or bottom of the screen. This is specified via the `position` parameter at init time. The `position` parameter takes an associated value, that allows you to define an inset.\n\nBy default Rye will calculate the safe area insets for you, so be sure to specify only the extra desired inset.\n\nSimilarly, you can set the alignment of the Rye via the `aligned` parameter. The `.leading` and `.trailing` alignments also take an associated value, that allows you to define an inset.\nIf the `aligned` parameter is not specified at init time, it will default to `.center`\n\n#### Animation Type\n\nRye provides two animation types:\n\n- `slideInOut`: slides the view in from either top or bottom (depending on which `Position` you have selected). When dismissed the view slides out in the same direction.\n- `fadeInOut`: fades the view in and out again when dismissed.\n\nTo control how long the animation will take, please use the `animationDuration` key of the `RyeConfiguration` and provide a `TimeInterval` value.\n\nIf you _do not_ provide a value for `animationDuration`, a standard value of 0.3 seconds is used.\n\n#### Ignore Safe Areas\n\nWhen determining where to show the Rye message you can select whether to include `safeLayoutArea` insets in the calculation or not.\n\nThis is done by setting the `.ignoreSafeAreas` value in the `RyeConfiguration`.\n\nThe default value is `false`, meaning that safe area insets will be used in the calculation.\n\n#### Possible Rye Configuration Values\n\nThe following keys can be used in the configuration dictionary:\n\n    .backgroundColor (must be a UIColor)\n    .textColor (must be a UIColor)\n    .textFont (must be a UIFont)\n    .text (must be a String)\n    .cornerRadius (must be a CGFloat)\n    .animationType (must be a Rye.AnimationType)\n    .animationDuration (must be a TimeInterval)\n    .ignoreSafeAreas (must be a bool)\n\nIf configuration is set to nil, a default configuration will be used. Any options set, will override the default state.\n\n## ⚠️ Gotchas\n\nIn order to display a Rye message, a `parentView` is needed to determine _in relation to what_ the Rye message is positioned.\n\nIf you try to display a Rye message before a `parentView` can be obtained, you will see this warning in the console of your IDE.\n\n\u003e A parentView could not be found to display the Rye message on. Are you trying to show a Rye message before the view lifecycle is ready to display views?\n\nThis can be seen if you try to call `show()` on a `RyeViewController` in `viewDidLoad()` of a `UIViewController` for instance.\n\n\n## Example Project\nTo learn more, please refer to the RyeExample project contained in this repository.\n\n## ⬆️ Updating from v1.x.x to v2.0.0\nIn version 2.0.0 of Rye we changed the way you display messages.\n\nGone is the distinction between `.toast` and `.snackBar`. Instead, every message is now displayed in a separate `UIWindow` at the very top level of your view stack and you must decide how to dismiss the message with the previously described [`displayModes`](#display-modes).\n\nThis also means that the previous init method: `RyeViewController.init(alertType:viewType:at:timeAlive:)` has been deprecated. If you use this init method with version 2.0.0 you will receive a deprecation warning during compilation.\n\nYou can - if you stubbornly insist - still use the now old `init` method. Behind the scenes Rye will create a new `RyeViewController` for you and set the `displayMode` based on these rules:\n\n_If_ you have added a `timeAlive` value, that `timeAlive` will be used to create a `displayMode` with a value of `.automatic(interval: timeAlive)`\n\n_If_ you have _not_ added a `timeAlive` value, the `displayMode` will be `.nonDismissable`.\n\n## 👥 Credits\nMade with ❤️ at [Nodes](http://nodesagency.com).\n\n## 📄 License\n**Rye** is available under the MIT license. See the [LICENSE](https://github.com/nodes-ios/Rye/blob/master/LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fml-opensource%2Frye","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fml-opensource%2Frye","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fml-opensource%2Frye/lists"}