{"id":21467791,"url":"https://github.com/pikacode/popupui","last_synced_at":"2025-07-15T05:32:07.654Z","repository":{"id":228071450,"uuid":"771368665","full_name":"pikacode/PopupUI","owner":"pikacode","description":"Toast \u0026 Popup any View by SwiftUI！      SwiftUI 实现的弹窗控件，简单易用！       便利の SwiftUI PopupView！","archived":false,"fork":false,"pushed_at":"2024-04-12T00:47:39.000Z","size":116273,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-20T10:46:08.754Z","etag":null,"topics":["hud","popup","popupview","popview","swift","swiftui","swiftui-components","swiftui-framework","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/pikacode.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,"dei":null}},"created_at":"2024-03-13T07:07:33.000Z","updated_at":"2024-10-22T10:27:46.000Z","dependencies_parsed_at":"2024-04-10T01:52:51.016Z","dependency_job_id":null,"html_url":"https://github.com/pikacode/PopupUI","commit_stats":null,"previous_names":["pikacode/popupui"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikacode%2FPopupUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikacode%2FPopupUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikacode%2FPopupUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pikacode%2FPopupUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pikacode","download_url":"https://codeload.github.com/pikacode/PopupUI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226018640,"owners_count":17560703,"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":["hud","popup","popupview","popview","swift","swiftui","swiftui-components","swiftui-framework","toast"],"created_at":"2024-11-23T08:19:46.301Z","updated_at":"2024-11-23T08:19:46.851Z","avatar_url":"https://github.com/pikacode.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PopupUI\n**Easy to Toast \u0026 Popup any View by SwiftUI！**\n\nSwiftUI 实现的弹窗控件，简单易用！[《中文文档》](README_CN.md)\n\nSwiftUI で作られた PopupView は、簡単で使いやすいです！[『日本語のREADME』](README_JP.md)\n\n\n \n\n## Screenshot\n|   Center Prompt                   | Center Confirmation           | Bottom Confirmation                |\n| -------------------------- | -------------------------- | ----------------------- |\n| ![](Screenshot/center_1.gif) | ![](Screenshot/center_2.gif) | ![](Screenshot/bottom_1.gif) |\n| Bottom Input                   | Sidebar                   | Top Notification                |\n| ![](Screenshot/bottom_2.gif) | ![](Screenshot/left.gif) | ![](Screenshot/top_1.gif) |\n| Top Prompt                   | Background Color                   | Code Generation                |\n| ![](Screenshot/top_2.gif) | ![](Screenshot/background.gif) | ![](Screenshot/code.gif) |\n\n\n　\n## Installation\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/pikacode/PopupUI.git\")\n]\n```\n\n\n### Cocoapods\n\n```ruby\npod 'PopupUI'\n```\n\n  \n\n## Usage\n```swift\nimport PopupUI\n```\n\n### Basic Usage\n\n#### 1.Adding\nAdd `.popupUI()` after a view to pop up within it's scope:\n```swift\nvar body: some View {\n    VStack {\n        ...\n    }\n    .popupUI()  // \u003c-- Add to the view\n}\n```\n**Or** add to the root view, only once to pop up throughout the entire application:\n```swift\n@main\nstruct PopupUI_demoApp: App {\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n                .popupUI()  // \u003c-- Add to the root view\n        }\n    }\n}\n```\n\n#### 2.Showing\n```swift\nPopupUI\n    .show(Text(\"Hello, PopupUI!\"))\n```\n\n\n#### 3.Hiding\n```swift\nPopupUI\n    .hide()     // Hide the last popup \n```\n\n\n​    \n### Advanced Usage\n#### Show with custom parameters\nCustomize various parameters:\n```swift\nPopupUI\n    .show(YourCustomView())                 // The view to be shown\n    .from(.bottom)                          // The direction from which the view is shown\n    .stay(2)                                // The duration of the view staying\n    .to(.center, .easeOut(duration: 0.3))   // The direction to which the view is hidden and the animation\n    .background(Color.black.opacity(0.3))   // The background view\n    .padding(24)                            // The padding of the view\n    .isSafeArea(true)                       // Whether to avoid the safe area\n    .id(\"Unique Popup ID\")                  // The unique identifier, when not passed, the same id is used by default, so only one popup can be displayed at a time, you can display multiple popups at the same time by setting different ids\n    .isAvoidKeyboard(true)                  // Whether to avoid the keyboard\n    .isBackgroundOpaque(true)               // Whether to prevent the user from interacting with the background view\n    .dismissWhenTapBackground(true)         // Whether to hide when the background view is tapped\n    .scaleFrom(0.5)                         // show: value -\u003e 1\n    .scaleTo(0.5)                           // hide: 1 -\u003e value\n    .opacityFrom(0.5)                       // show: value -\u003e 1\n    .opacityTo(0.5)                         // hide: 1 -\u003e value\n    .duplicatedIdBehavior(.ignore)          // When the id is duplicated: .ignore: the lasteat will be ignored / .replace: the lasteat will replace the previous one\n    .dismissCallback { id in                // The callback when the view is hidden\n        print(\"Popup dismissed: \\(id)\")\n    }\n```\n\nOr display a view and customize the parameters through the closure:\n```swift\nPopupUI\n    .show {\n        VStack {\n            ...\n        }\n    } config: { config in\n        config.from = ...\n    }\n```\n\n#### Hide a specified popup\n```swift\nPopupUI\n    .hide(\"Unique Popup ID\")    // Hide the specified popup\n```\n\n  \n\n#### Global Configuration\nCustomize the default parameters through `PopupConfiguration.default` to simplify the popup code:\n```swift\nlet configuration = PopupConfiguration()\nconfiguration.stay = 2\nconfiguration.to = .center\n...\nPopupConfiguration.default = configuration\n```\nOr:\n```swift\nPopupConfiguration\n    .default\n    .stay(2)\n    .to(.center)\n    ...\n```\n   \n  \n  \n#### Define several style templates\nDefine all styles in App as several templates to simplify the popup code:\n\n```swift\nextension PopupConfiguration {      //PopupStyle\n    static var center: PopupConfiguration {\n            PopupConfiguration()\n                        .from(.center)\n                        .to(.center, .easeOut)\n                        ...\n    }\n    \n    static var bottom: PopupConfiguration {\n            PopupConfiguration()\n                        .from(.bottom)\n                        .isOpaque(false)\n                        ...                                    \n    }\n}\n                                    \nPopupUI\n    .show(CenterView())\n    .config(.center)        //.style(.center)\n\nPopupUI\n    .show(BottomView())\n    .config(.bottom)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpikacode%2Fpopupui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpikacode%2Fpopupui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpikacode%2Fpopupui/lists"}