{"id":2470,"url":"https://github.com/schmidyy/Loaf","last_synced_at":"2025-08-06T16:30:52.357Z","repository":{"id":34240435,"uuid":"169164789","full_name":"schmidyy/Loaf","owner":"schmidyy","description":"🍞 A Swifty Framework for Easy iOS Toasts ","archived":false,"fork":false,"pushed_at":"2023-05-25T08:57:37.000Z","size":119,"stargazers_count":1094,"open_issues_count":19,"forks_count":101,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-30T13:03:53.573Z","etag":null,"topics":[],"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/schmidyy.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-04T23:17:35.000Z","updated_at":"2024-11-21T18:45:26.000Z","dependencies_parsed_at":"2024-01-02T21:14:45.813Z","dependency_job_id":"57610996-6220-4fd8-8199-79e91dc25466","html_url":"https://github.com/schmidyy/Loaf","commit_stats":{"total_commits":50,"total_committers":6,"mean_commits":8.333333333333334,"dds":0.12,"last_synced_commit":"ce8059a0c484f4ddf3bc63eb094a2ae7b4d4d0f7"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmidyy%2FLoaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmidyy%2FLoaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmidyy%2FLoaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schmidyy%2FLoaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schmidyy","download_url":"https://codeload.github.com/schmidyy/Loaf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228639107,"owners_count":17949931,"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":[],"created_at":"2024-01-05T20:16:14.526Z","updated_at":"2024-12-09T16:31:00.061Z","avatar_url":"https://github.com/schmidyy.png","language":"Swift","readme":"\u003cH1 align=\"center\"\u003e\nLoaf 🍞\n\u003c/H1\u003e\n\u003cH4 align=\"center\"\u003e\nInspired by Android's Toast,\u003c/br\u003e\nLoaf is a Swifty Framework for Easy iOS Toasts\u003c/br\u003e\n\u003c/H4\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://cocoapods.org/pods/Loaf\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/cocoapods/v/Loaf.svg?style=flat\"\u003e\u003c/a\u003e \n\u003ca href=\"https://github.com/schmidyy/Loaf/blob/master/LICENSE\"\u003e\u003cimg alt=\"Liscence\" src=\"https://img.shields.io/cocoapods/l/Loaf.svg?style=flat\"\u003e\u003c/a\u003e \n\u003ca href=\"https://developer.apple.com/\"\u003e\u003cimg alt=\"Platform\" src=\"https://img.shields.io/badge/platform-iOS-green.svg\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg alt=\"Swift4.2\" src=\"https://img.shields.io/badge/language-Swift4.2-orange.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"http://clayallsopp.github.io/readme-score?url=https://github.com/schmidyy/loaf\"\u003e\u003cimg alt=\"Readme Score\" src=\"http://readme-score-api.herokuapp.com/score.svg?url=https://github.com/schmidyy/loaf\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n____\n\n## Usage\n\nFrom any view controller, a Loaf can be presented by calling:\n```swift\nLoaf(\"Message goes here\", sender: self).show()\n```\nWhich will result in:\n\n\u003cimg width=\"400\" alt=\"screen shot 2019-02-27 at 3 59 07 pm\" src=\"https://user-images.githubusercontent.com/22358682/53522566-a2b1f880-3aa8-11e9-8451-f555811f85ed.png\"\u003e\n\nBellow, I will discuss how to further customize your Loaf!\n\n## Playground\n\nI've provided an example project to showcase uses of Loaf! Simply clone this repo, and open `LoafExamples.xcodeproj`. From here you can see and experiment custom Loaf styles in `Examples.swift`\n\n## Customization\n\n### Basic styles\n\nLoaf comes with 4 basic style out of the box.\n\n| Success | Error |\n| ------- | ----- |\n| \u003cimg width=\"525\" alt=\"screen shot 2019-02-27 at 3 45 44 pm\" src=\"https://user-images.githubusercontent.com/22358682/53521918-4f8b7600-3aa7-11e9-934d-866e04189e99.png\"\u003e | \u003cimg width=\"525\" alt=\"screen shot 2019-02-27 at 3 45 52 pm\" src=\"https://user-images.githubusercontent.com/22358682/53521932-59ad7480-3aa7-11e9-8ba5-f6adef7002e2.png\"\u003e |\n\n| Warning | Info |\n| ------- | ---- |\n| \u003cimg width=\"525\" alt=\"screen shot 2019-02-27 at 3 45 58 pm\" src=\"https://user-images.githubusercontent.com/22358682/53521946-629e4600-3aa7-11e9-8a1e-542048d05afc.png\"\u003e | \u003cimg width=\"525\" alt=\"screen shot 2019-02-27 at 3 53 26 pm\" src=\"https://user-images.githubusercontent.com/22358682/53522180-db050700-3aa7-11e9-8363-b28f1c21b186.png\"\u003e |\n\nThese styles can be specified in the `style` property.\nFor instance, to use `Success` styled Loaf, call it like so:\n```swift\nLoaf(\"This is a success loaf\", state: .success, sender: self).show()\n```\n\n### Custom styles\n\nLoaf allows you to specify a custom style! This will let you set the colors, font, icon. and icon alignment. Here are some examples of custom Loaf styles!\n\n| Colors and icon | Right icon alignment | No icon |\n| ---- | ---- | ---- |\n| \u003cimg width=\"517\" alt=\"screen shot 2019-02-27 at 6 09 33 pm\" src=\"https://user-images.githubusercontent.com/22358682/53529532-e3b30880-3aba-11e9-9d07-4a4ffd0acee8.png\"\u003e | \u003cimg width=\"517\" alt=\"screen shot 2019-02-27 at 6 13 13 pm\" src=\"https://user-images.githubusercontent.com/22358682/53529721-73f14d80-3abb-11e9-830e-1e007fcca84a.png\"\u003e | \u003cimg width=\"517\" alt=\"screen shot 2019-02-27 at 6 13 22 pm\" src=\"https://user-images.githubusercontent.com/22358682/53529730-7bb0f200-3abb-11e9-98aa-5aa705266260.png\"\u003e |\n\nAll of these properties are specified as part of custom state, like so:\n```swift\nLoaf(\"Switched to light mode\", state: .custom(.init(backgroundColor: .black, icon: UIImage(named: \"moon\"))), sender: self).show()\n```\n\n### Presenting and dismissing\n\nLoaf allows you to specify the presenting and dismissing direction. The presenting direction is independant from the dismissal direction. Here are some examples:\n\n| Vertical | Left |\n| ---- | ---- |\n| ![vertical](https://user-images.githubusercontent.com/22358682/53534239-f71a9f80-3acb-11e9-8010-c7915012a187.gif) | ![left](https://user-images.githubusercontent.com/22358682/53534240-f7b33600-3acb-11e9-8b10-b6d2cb3199a2.gif) |\n\n| Right | Mix |\n| ---- | ---- |\n| ![right](https://user-images.githubusercontent.com/22358682/53534241-f7b33600-3acb-11e9-8e55-457c5a2f32d2.gif) | ![mix](https://user-images.githubusercontent.com/22358682/53534242-f7b33600-3acb-11e9-9e74-88653d469746.gif) |\n\nThese are specified in the function signature, like so:\n```swift\nLoaf(\"Loaf message\", presentingDirection: .left, dismissingDirection: .vertical, sender: self).show()\n```\n\n### Location\n\nToasts are typically presented at the bottom of the screen, but Loaf allows you to also present them at the top of the screen. Here is an example of a Loaf being presented at the top of the view:\n\n\u003cimg width=\"400\" alt=\"screen shot 2019-02-27 at 8 30 04 pm\" src=\"https://user-images.githubusercontent.com/22358682/53534861-92147900-3ace-11e9-8668-361ec311698a.png\"\u003e\n\nThis is also specified in the function signature, like so:\n```swift\nLoaf(\"Loaf message\", location: .top, sender: self).show()\n```\n\n### Other\n\nSpecify the presentation duration. When presenting a Loaf with `.show()`, a presentation duration can be specified. The default value is 4s, but there are presets for 2s and 8s. This is done by using `.show(.short)` for 2s, or `.show(.long)` for 8s. A custom duration can also be specified with `.show(.custom(x))`, where x represents the duration in seconds.\n\n**⚠️ New in `0.5.0`:**\n\n- A completion handler can be specified in the Loaf `show()` function signature. This block will be called when the dismissal animation is completed, or when the Loaf is tapped. This completion handler is now passed with a enum representing whether the Loaf was tapped or timmed out. Here is an example of using a completion handler:\n\n```swift\nLoaf(example.rawValue, sender: self).show { dismissalType in\n     switch dismissalType {\n          case .tapped: print(\"Tapped!\")\n          case .timedOut: print(\"Timmed out!\")\n     }\n}\n```\n\n- A Loaf's width can be specified via the `Style` component. The width can be specifed as a fixed size (i.e. 280px) or as a percentage of the screen's width. (i.e. `0.8` -\u003e 80%). Here is some example usage:\n\n```Swift\nLoaf(example.rawValue, state: .custom(.init(backgroundColor: .black, width: .screenPercentage(0.8))), sender: self).show()\n```\n\n- Loaf's will now be presented above tab bars, when possible.\n- Loaf's can be manually dismissed through a global method: \n\n```swift\nLoaf.dismiss(sender: self) // Where `self` is the Loaf's presenter\n```\n\n____\n\n## Installation\n\n### Cocoapods\n\nLoaf is on Cocoapods! After [setting up Cocoapods in your project](https://guides.cocoapods.org/), simply add the folowing to your Podfile:\n```\npod 'Loaf'\n```\nthen run `pod install` from the directory containing the Podfile!\n\nDon't forget to include `import Loaf` in every file you'd like to use Loaf\n\n### Requirements\n\n- Swift 4.2+\n- iOS 9.0+\n\n### Contributing\n\nPull requests, feature requests and bug reports are welcome 🚀\n\n____\n\nThanks to [@kirkbyo](https://github.com/kirkbyo) for helping me through the tough parts of this 💪\n\n\u003cp align=\"center\"\u003e\nMade with ❤️ in 🇨🇦 by \u003ca href=\"https://twitter.com/devschmidy\"\u003eMat Schmid\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":["UI","Libs","Content","Swift","UI [🔝](#readme)"],"sub_categories":["Alert \u0026 Action Sheet","UI","Alert"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschmidyy%2FLoaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschmidyy%2FLoaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschmidyy%2FLoaf/lists"}