{"id":25065549,"url":"https://github.com/rlarjsdn3/tsalertcontroller-ios","last_synced_at":"2025-03-31T13:27:36.952Z","repository":{"id":270928724,"uuid":"909662712","full_name":"rlarjsdn3/TSAlertController-iOS","owner":"rlarjsdn3","description":"✨An elegant Alert library written in Swift","archived":false,"fork":false,"pushed_at":"2025-03-28T02:32:47.000Z","size":1077,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-28T03:25:58.503Z","etag":null,"topics":["alertcontroller","cocoapods","open-source","swift","swiftpackagemanager","uikit"],"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/rlarjsdn3.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":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-29T12:18:18.000Z","updated_at":"2025-03-28T02:32:48.000Z","dependencies_parsed_at":"2025-01-04T05:25:51.061Z","dependency_job_id":"0882b20c-ca28-401e-896d-4c0969a353c3","html_url":"https://github.com/rlarjsdn3/TSAlertController-iOS","commit_stats":null,"previous_names":["rlarjsdn3/tsalertcontroller-ios"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlarjsdn3%2FTSAlertController-iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlarjsdn3%2FTSAlertController-iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlarjsdn3%2FTSAlertController-iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlarjsdn3%2FTSAlertController-iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rlarjsdn3","download_url":"https://codeload.github.com/rlarjsdn3/TSAlertController-iOS/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246473278,"owners_count":20783238,"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":["alertcontroller","cocoapods","open-source","swift","swiftpackagemanager","uikit"],"created_at":"2025-02-06T19:44:14.609Z","updated_at":"2025-03-31T13:27:36.941Z","avatar_url":"https://github.com/rlarjsdn3.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSAlertController\n\n\u003cdiv align=\"left\"\u003e\n\n\u003ca href=\"https://cocoapods.org/pods/TSAlertController\"\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/v/TSAlertController.svg?style=flat\" alt=\"Version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org/pods/TSAlertController\"\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/l/TSAlertController.svg?style=flat\" alt=\"License\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org/pods/TSAlertController\"\u003e\n    \u003cimg src=\"https://img.shields.io/cocoapods/p/TSAlertController.svg?style=flat\" alt=\"Platform\"\u003e\n\u003c/a\u003e\n\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./Screenshot/Example_02.png\" width=\"24%\"\u003e\n    \u003cimg src=\"./Screenshot/Example_03.png\" width=\"24%\"\u003e\n    \u003cimg src=\"./Screenshot/Example_04.png\" width=\"24%\"\u003e\n    \u003cimg src=\"./Screenshot/Example_05.png\" width=\"24%\"\u003e\n\u003c/p\u003e\n\n## Usage\n\nTo display a simple alert:\n\n```swift\nlet alert = TSAlertController(\n    title: \"The title of the alert\",\n    message: \"Descriptive text that provides more details about the reason for the alert.\",\n    preferredStyle: .alert\n)\n\nlet okAction = TSAlertAction(title: \"OK\")\nalert.addAction(okAction)\n\npresent(alert, animated: true)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n\n\u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_01.png\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\nTSAlertController mimics the interface of [UIAlertController]() and references other APIs to minimize the learning curve. The customization method has been designed in a similar way to [UIButton.Configuration] and [UIBarAppearance], allowing developers to easily modify the appearance and behavior of the alert using familiar APIs.\n\n\nAnd like [UIAlertController](), you can also add a [UITextField]() to the alert:\n\n```swift\nlet alert = TSAlertController(\n    title: \"Sign In\",\n    message: \"Please enter your username and password to access your account.\",\n    options: [.dismissOnTapOutside],\n    preferredStyle: .alert\n    )\n\nlet okAction = TSAlertAction(title: \"Sign In\")\nalert.addAction(okAction)\nalert.preferredAction = okAction\n\nlet cancelAction = TSAlertAction(title: \"Cancel\", style: .cancel)\ncancelAction.configuration.backgroundColor = .systemBlue\nalert.addAction(cancelAction)\n\nalert.addTextField { textfield in\n    textfield.placeholder = \"Username\"\n}\nalert.addTextField { textfield in\n    textfield.placeholder = \"Password\"\n}\n\npresent(alert, animated: true)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n\n\u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_02.png\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\n\n### Customizing Appearance\n\nTo customize fonts, text color, alignment, button group axis, and more, use `TSAlertController.ViewConfiguration`:\n\n```swift\nlet alert = TSAlertController(\n    title: \"Current Location Not Available\",\n    message: \"Your current location can't be determined at this time.\",\n    preferredStyle: .alert\n)\nlet color = UIColor(red: 251.0 / 255.0, green: 251.0 / 255.0, blue: 236.0 / 255.0, alpha: 1)\nalert.viewConfiguration.titleTextAlignment = .center\nalert.viewConfiguration.titleTextAttributes = [.font: UIFont(name: \"Wanderlust\", size: 30), .foregroundColor: UIColor.systemTeal]\nalert.viewConfiguration.messageTextAlignment = .center\nalert.viewConfiguration.messageTextAttributes = [.font: UIFont(name: \"Wanderlust\", size: 26), .foregroundColor: UIColor.systemOrange]\nalert.viewConfiguration.backgroundColor = .color(color)\nalert.viewConfiguration.buttonGroupAxis = .vertical\n\nlet okAction = TSAlertAction(title: \"Cancel\", style: .cancel)\nokAction.configuration.titleAttributes = [.font: UIFont(name: \"Wanderlust\", size: 22), .foregroundColor: UIColor.white]\nalert.addAction(okAction)\n\nlet goToSettingAction = TSAlertAction(title: \"Go to Setting\")\ngoToSettingAction.configuration.titleAttributes = [.font: UIFont(name: \"Wanderlust\", size: 22), .foregroundColor: UIColor.white]\ngoToSettingAction.configuration.backgroundColor = .systemBlue\nalert.addAction(goToSettingAction)\n\npresent(alert, animated: true)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n\n\u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_03.png\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\nFor more details, refer to the [ViewConfiguration]() section.\n\n\n### Interactive Features\n\nTSAlertController also supports interactive user actions:\n\n```swift\nlet actionSheet = TSAlertController(\n    title: \"What kind of inquiry do you have?\",\n    options: [.interactiveScaleAndDrag, .dismissOnSwipeDown, .dismissOnTapOutside],\n    preferredStyle: .floatingSheet\n)\nactionSheet.viewConfiguration.margin = .init(buttonLeft: 5, buttonRight: 5)\n\nlet config = TSButton.Configuration(\n    imageSpacing: 15,\n    preferredSymbolConfigurationForImage: .init(paletteColors: [.label]),\n    accessoryImage: UIImage(systemName: \"chevron.right\"),\n    preferredSymbolConfigurationForAccessoryImage: .init(paletteColors: [.label]),\n    contentAlignment: .left,\n    backgroundColor: .clear\n)\n\nlet appUsageInquiry = TSAlertAction(title: \"App Usage Inquiry\")\nappUsageInquiry.configuration = config\n// ... \n\nlet paymentIssue = TSAlertAction(title: \"Payment Issues\")\n// ...\n\nlet accountSupport = TSAlertAction(title: \"Account \u0026 Login Issues\")\n// ...\n\nlet bugReport = TSAlertAction(title: \"Bug Report\")\n// ...\n\npresent(actionSheet, animated: true)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n\n\u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_04.png\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\nAs you can see in the preview and infer from the option names, various user interactions can be added to the alert. The `.dismissOnSwipeDown` option allows the alert to disappear when swiped down beyond a certain distance. Similarly, `.dismissOnTapOutside` makes the alert disappear when the dimmed background area outside the alert is tapped.\n\n\n### Transiton And Animation\n\nTSAlertController supports several transition and animation options:\n\n```swift\nlet alert = TSAlertController(\n    title: \"Save it for later?\", \n    message: \"Your current progress will not be saved.\", \n    preferredStyle: .alert\n)\nalert.viewConfiguration.buttonGroupAxis = .vertical\n\nalert.configuration.enteringTransition = .slideUp\nalert.configuration.exitingTransition = .fadeOut\n\nalert.configuration.headerAnimation = .slide\nalert.configuration.buttonGroupAnimation = .fadeIn\n\n// ...\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n\n\u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_06.gif\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\nTransitions define how the alert appears on the screen when the present(_:animated:) method is called, as their names suggest. Animations determine how the internal views of the alert animate when the alert appears.\n\n\n### Alert With Custom View\n\nYou can add a custom-designed view as the header of the alert:\n\n```swift\nlet marketCap = MarketCapView()\nlet actionSheet = TSAlertController(\n    marketCap,\n    options: [.dismissOnSwipeDown, .interactiveScaleAndDrag],\n    preferredStyle: .floatingSheet\n)\n\nlet okAction = TSAlertAction(title: \"Confirm\")\nokAction.configuration.backgroundColor = .systemBlue\nactionSheet.addAction(okAction)\n\npresent(actionSheet, animated: true)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003ePreview\u003c/summary\u003e\n  \n  \u003cbr\u003e\n\n\u003cimg src=\"./Screenshot/Example_05.png\" width=\"250px\"\u003e\n\n\u003c/details\u003e\n\n\n\n### Configuration options\n\nThe `TSAlertController.Configuration` struct defines various behaviors for the alert, including animations and UI preferences.\n\n| Name                   | Description                                                 | Type                                              | Default |\n|------------------------|-------------------------------------------------------------|---------------------------------------------------|---------|\n| `enteringTransition`   | The transition animation type when the alert appears. For `.actionSheet`, it defaults to `.slideUp`. For `.alert`, it defaults to `.fadeInAndScaleDown`. | `TSAlertController.EnteringTransitionType?`      | `nil`   |\n| `exitingTransition`    | The transition animation type when the alert disappears. For `.actionSheet`, it defaults to `.slideDown`. For `.alert`, it defaults to `.fadeOut`. | `TSAlertController.ExitingTransitionType?`       | `nil`   |\n| `headerAnimation`      | The animation type for the alert’s header when presented.  | `TSAlertController.AnimationType?`               | `nil`   |\n| `buttonGroupAnimation` | The animation type for the button group when presented.    | `TSAlertController.AnimationType?`               | `nil`   |\n| `prefersGrabberVisible` | A Boolean value indicating whether a grabber (handle) should be visible. This property applies only to `.actionSheet`, as .alert does not display a grabber. | `Bool` | `true` |\n\n\n### ViewConfiguration options\n\nThe `TSAlertController.ViewConfiguration` struct defines various visual and layout configurations for the alert.\n\n| Name                              |                                    Description                                           | Type                                         | Default |\n|-----------------------------------|------------------------------------------------------------------------------------------|----------------------------------------------|---------|\n| `titleHeight`                     | The fixed height of the title area. If `nil`, the height adjusts dynamically.            | `CGFloat?`                                  | `nil`   |\n| `messageHeight`                   | The fixed height of the message area. If `nil`, the height adjusts dynamically.          | `CGFloat?`                                  | `nil`   |\n| `buttonHeight`                    | The height of each button in the button group.                                          | `CGFloat`                                   | `45`    |\n| `grabberColor`                    | The color of the grabber (handle) used for dragging.                                    | `UIColor?`                                  | `.grabber` |\n| `titleAttributes`             | Text attributes for styling the title.                                                  | `[NSAttributedString.Key: Any]?`            | Headline font with `.alertLabel` color |\n| `titleAlignment`              | The text alignment of the title.                                                        | `NSTextAlignment`                           | `.left` |\n| `titleNumberOfLines`              | The number of lines for the title. If `0`, the title expands dynamically.               | `Int`                                       | `0`     |\n| `messageTextAttributes`           | Text attributes for styling the message.                                                | `[NSAttributedString.Key: Any]?`            | Subheadline font with `.alertSecondaryLabel` color |\n| `messageTextAlignment`            | The text alignment of the message.                                                      | `NSTextAlignment`                           | `.left` |\n| `messageNumberOfLines`            | The number of lines for the message. If `0`, the message expands dynamically.           | `Int`                                       | `0`     |\n| `textFieldContainerBorderColor`   | The border color of the container wrapping the text field. This also changes the color of the separator line.                        | `CGColor?` | `.alertGray` |\n| `textFieldContainerBorderWidth`   | The border width of the container wrapping the text field. This also changeds the thickness of the separator line.                             | `CGFloat`                                   | `0.75`  |\n| `backgroundColor`                 | The background style of the alert.                                                      | `Background`                                | `.alertBackground` |\n| `backgroundBorderColor`           | The border color of the alert’s background.                                             | `CGColor?`                                  | `nil`   |\n| `backgroundBorderWidth`           | The border width of the alert’s background.                                             | `CGFloat`                                   | `0`     |\n| `shadow`                          | The shadow configuration for the alert view.                                            | `Shadow?`                                   | `nil`   |\n| `cornerRadius`                    | The corner radius of the alert view.                                                    | `CGFloat`                                   | `20`    |\n| `dimmedBackgroundViewColor`       | The background color of the dimmed overlay behind the alert.                            | `Background?`                               | `.black` with 0.75 opacity |\n| `margin` | The margins applied around the alert view, defining the spacing between the alert’s boundary and its content, including the button group. | `LayoutMargin` | `.init()` |\n| `spacing`                         | The spacing settings applied within the alert layout.                                   | `LayoutSpacing`                             | `.init()` |\n| `size`                            | The size configuration of the alert.                                                    | `LayoutSize`                                | `.init()` |\n| `buttonGroupAxis`                 | The axis layout of the button group (horizontal or vertical).                           | `ButtonGroupAxis`                           | `.automatic` |\n\n---\n\n#### Background Options\n\nThe `TSAlertController.ViewConfiguration.Background` enum defines different background styles for the alert.\n\n| Name       | Description |\n|------------|------------|\n| `.blur(UIBlurEffect.Style)` | Uses a blurred background with the specified `UIBlurEffect.Style`. |\n| `.color(UIColor)` | Uses a solid color background. |\n| `.gradient([CGColor], startPoint: CGPoint, endPoint: CGPoint, locations: [NSNumber]?)` | Uses a gradient background with customizable colors, direction, and location stops. |\n\n---\n\n#### LayoutMargin Options\n\nThe `TSAlertController.ViewConfiguration.LayoutMargin` struct defines margin settings for content and buttons.\n\n| Name            | Description                               | Type     | Default |\n|----------------|-------------------------------------------|---------|---------|\n| `contentTop`   | The top margin for the content area.      | `CGFloat` | `22.5`  |\n| `contentLeft`  | The left margin for the content area.     | `CGFloat` | `17.5`  |\n| `contentRight` | The right margin for the content area.    | `CGFloat` | `17.5`  |\n| `buttonLeft`   | The left margin for the button area.      | `CGFloat` | `17.5`  |\n| `buttonRight`  | The right margin for the button area.     | `CGFloat` | `17.5`  |\n| `buttonBottom` | The bottom margin for the button area.    | `CGFloat` | `17.5`  |\n\n---\n\n#### LayoutSpacing Options\n\nThe `TSAlertController.ViewConfiguration.LayoutSpacing` struct defines spacing settings within the alert layout.\n\n| Name                      | Description                                           | Type     | Default |\n|---------------------------|-------------------------------------------------------|---------|---------|\n| `titleMessageSpacing`     | Spacing between the title and the message.           | `CGFloat` | `12.5`  |\n| `messageTextfieldSpacing` | Spacing between the message and the text field. Ignored if no text field is present.     | `CGFloat` | `12.5`  |\n| `textfieldButtonSpacing`  | Spacing between the text field and the button. If there is no text field, this spacing applies between the message and the button.      | `CGFloat` | `16.5`  |\n| `buttonSpacing`           | Spacing between buttons in the button group.        | `CGFloat` | `7.5`   |\n| `keyboardSpacing`         | Spacing between the bottom of the alert and the keyboard. The default value is 20 for action sheets and 100 for alerts. | `CGFloat` | `100`   |\n\n---\n\n#### LayoutSize Options\n\nThe `TSAlertController.ViewConfiguration.LayoutSize` struct defines the width and height constraints of the alert.\n\n| Name    | Description                         | Type                         | Default |\n|---------|-------------------------------------|------------------------------|---------|\n| `width` | Width constraint for the alert.    | `LayoutSize.Constraint`      | `.proportional()` |\n| `height` | Height constraint for the alert.  | `LayoutSize.Constraint`      | `.proportional()` |\n\n---\n\n#### LayoutSize.Constraint Options\n\nThe `TSAlertController.ViewConfiguration.LayoutSize.Constraint` enum defines different constraints for width and height.\n\n| Name | Description |\n|------|------------|\n| `.fixed(CGFloat)` | Sets a fixed size for the alert. |\n| `.flexible(minimum: CGFloat, maximum: CGFloat)` | Sets a flexible size with minimum and maximum values. |\n| `.proportional(minimumRatio: CGFloat, maximumRatio: CGFloat)` | Sets a size relative to the screen size. |\n\n---\n\n#### ButtonGroupAxis Options\n\nThe `TSAlertController.ViewConfiguration.ButtonGroupAxis` enum defines the layout direction of buttons in the alert.\n\n| Name          | Description |\n|--------------|------------|\n| `.automatic` | Uses a horizontal layout if there are two or fewer buttons; otherwise, uses a vertical layout. |\n| `.vertical`  | Forces a vertical button layout. |\n| `.horizontal` | Forces a horizontal button layout. |\n\n \n## Examples\n\nYou can find the example files [here](./Example/TSAlertController/Presentation/ViewController.swift).\n\n\n ## Roadmap\n\nYou can check the upcoming changes for TSAlertController [here](./ROADMAP.md).\n \n \n \n## Installation\n\n### Swift Package Manager\n\nYou can use The Swift Package Manager to install TSAlertController by adding the description to your Package.swift file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/rlarjsdn3/TSAlertController-iOS.git\", from: \"1.0.0\")\n]\n```\n\n### CocoaPods\n\n```ruby\npod \"TSAlertController\"\n```\n\n## Requirements\n\nSwift 5.0+ | iOS 15.0+\n\n\n\n## Contributing\n\nAll types of contributions are welcome, from minor typo fixes and comment improvements to adding new features! Bug reports and feature requests are also highly appreciated, and I will actively review them.  \n\nTSAlertController is continuously updated with the goal of providing an easy-to-use, modern, and elegant alert system for everyone. I truly appreciate your support! 😃   \n\n\u003cdiv align=\"left\"\u003e\n\n\u003c!-- Replace with actual contributor images --\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://via.placeholder.com/80\" width=\"80\" height=\"80\" style=\"border-radius: 50%; margin: 5px;\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://via.placeholder.com/80\" width=\"80\" height=\"80\" style=\"border-radius: 50%; margin: 5px;\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://via.placeholder.com/80\" width=\"80\" height=\"80\" style=\"border-radius: 50%; margin: 5px;\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://via.placeholder.com/80\" width=\"80\" height=\"80\" style=\"border-radius: 50%; margin: 5px;\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://via.placeholder.com/80\" width=\"80\" height=\"80\" style=\"border-radius: 50%; margin: 5px;\"\u003e\u003c/a\u003e\n\n\u003c/div\u003e\n\n## License\n\nTSAlertController is available under the [MIT license](./LICENSE). See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlarjsdn3%2Ftsalertcontroller-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frlarjsdn3%2Ftsalertcontroller-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlarjsdn3%2Ftsalertcontroller-ios/lists"}