{"id":20716370,"url":"https://github.com/tomortec/simpleexpandableview","last_synced_at":"2025-04-23T13:21:29.510Z","repository":{"id":57681168,"uuid":"492398354","full_name":"Tomortec/SimpleExpandableView","owner":"Tomortec","description":"`SimpleExpandableView` is a SwiftUI view which can collapse and expand the content","archived":false,"fork":false,"pushed_at":"2022-05-19T13:33:08.000Z","size":1828,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T00:03:58.180Z","etag":null,"topics":["expandable","ios","swift","swiftui","tomortec","ui"],"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/Tomortec.png","metadata":{"files":{"readme":"README-zh.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":"2022-05-15T05:44:04.000Z","updated_at":"2025-01-09T09:55:54.000Z","dependencies_parsed_at":"2022-09-13T20:30:48.477Z","dependency_job_id":null,"html_url":"https://github.com/Tomortec/SimpleExpandableView","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleExpandableView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleExpandableView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleExpandableView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tomortec%2FSimpleExpandableView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tomortec","download_url":"https://codeload.github.com/Tomortec/SimpleExpandableView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250439371,"owners_count":21430839,"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":["expandable","ios","swift","swiftui","tomortec","ui"],"created_at":"2024-11-17T03:05:36.519Z","updated_at":"2025-04-23T13:21:29.469Z","avatar_url":"https://github.com/Tomortec.png","language":"Swift","readme":"# SimpleExpandableView\n\n\u003cimg src=\"./screenshot.png\" alt=\"Banner\" width=\"400\"\u003e\n\n\u003cimg src=\"./demo.gif\" alt=\"Demo\" width=\"200\"\u003e \n\n## ExpandableView 结构\n\u003cimg src=\"./pic-structure.png\" alt=\"Structure\" width=\"400\"\u003e\n\n## 小示例\n\n``` Swift\nExpandableView(\n    headerSize: CGSize(width: 250.0, height: 50.0),\n    cardSize: CGSize(width: 250.0, height: 250.0), header: {\n        Text(\"Hello world\")\n            .foregroundColor(.white)\n            .frame(maxWidth: .infinity, maxHeight: .infinity)\n            .background(LinearGradient(colors: [.blue, .cyan], startPoint: .top, endPoint: .bottom))\n    }, content: {\n        VStack {\n            Image(systemName: \"heart.fill\")\n                .resizable()\n                .frame(width: 180, height: 180)\n            Text(\"Hi\")\n                .font(.title2)\n        }\n        .foregroundColor(.white)\n    })\n.cardBackgroundColor(.cyan)\n.shadow(shadowRadius: 0.0)\n.listRowSeparator(.hidden)\n.frame(maxWidth: .infinity) // 居中\n.padding(.vertical, 5.0)\n```\n\n克隆本仓库，在 `Example` 文件夹执行 `pod install` 后在 `Xcode` 运行示例项目来查看 demo\n\n## ExpandableView 接口\n### 初始化\n``` swift\ninit(\n    headerSize: CGSize,\n    cardSize: CGSize,\n    @ViewBuilder header: () -\u003e Header,\n    @ViewBuilder content: () -\u003e Content,\n    onTapped action: (() -\u003e ())? = nil // 当 headerView 被点击时执行的操作\n)\n```\n\n### 方法\n``` swift\n// 改变 header view 的背景颜色\nfunc headerBackgroundColor(_ color: Color)\n\n// 改变 card view 的背景颜色\nfunc cardBackgroundColor(_ color: Color)\n\n// 改变 header view 的圆角大小\nfunc headerCornerRadius(_ radius: CGFloat)\n\n// 改变 card view 的圆角大小\nfunc cardCornerRadius(_ radius: CGFloat)\n\n// 设置 header view 和 card view 的阴影\nfunc shadow(shadowRadius: CGFloat = 6.0, color: Color = .gray, x: CGFloat = 0.0, y: CGFloat = 0.0)\n\n// 使用 content view 的高度来确定 card view 的高度\nfunc dynamicCardHeight()\n```\n\n## ExpandableViewsGroup 接口\n### 初始化\n``` swift\n// 所有 ExpandableView 使用相同的 `headerView`\ninit\u003cHeader\u003e(\n    headerSize: CGSize,\n    cardSize: CGSize,\n    headerView:  () -\u003e Header,\n    contentViews: () -\u003e [AnyView]\n) where Header : View\n\n// 使用泛型\ninit\u003cHeader, Content\u003e(\n    headerSize: CGSize,\n    cardSize: CGSize,\n    headerViews:  () -\u003e [Header],\n    contentViews: () -\u003e [Content]\n)  where Header : View, Content : View\n\n// 使用 AnyView 数组\ninit(\n    headerSize: CGSize,\n    cardSize: CGSize,\n    headerViews:  () -\u003e [AnyView],\n    contentViews: () -\u003e [AnyView]\n)\n\n// 使用可变参数\ninit(\n    headerSize: CGSize,\n    cardSize: CGSize,\n    headerViews:  AnyView...,\n    contentViews: AnyView...\n)\n```\n\n### 方法\n``` swift\n// 设置两个 `ExpandableView` 之间的空间\nfunc verticalSpacing(_ spacing: CGFloat)\n\n// 设置整个组的背景颜色\nfunc backgroundColor(_ color: Color)\n\n// 设置所有 header view 的背景颜色\nfunc headersBackgroundColor(_ color: Color)\n\n// 设置所有 card view 的背景颜色\nfunc cardBackgroundColor(_ color: Color)\n\n// 设置所有 header view 的圆角\nfunc headerCornerRadius(_ radius: CGFloat)\n\n// 设置所有 card view 的圆角\nfunc cardCornerRadius(_ radius: CGFloat)\n\n// 设置所有 header view 和 card view 的阴影\nfunc shadow(shadowRadius: CGFloat = 6.0, color: Color = .gray, x: CGFloat = 0.0, y: CGFloat = 0.0)\n\n// 将所有 `ExpandableView` 设置为 `.dynamicCardHeight()`\nfunc dynamicCardHeight()\n```\n\n执行 Xcode 的 `Product \u003e Build Documentation` 并前往文档中心来查看 `SimpleExpandableView` 的更多接口细节\n\n## Swift 版本\n\nSwift \u003e= 5.0\n\n## 安装方法\n\n`SimpleExpandableView` 已在 [CocoaPods](https://cocoapods.org)发布。添加下列命令到你的 `Podfile` 来安装 `SimpleExpandableView`:\n\n```ruby\npod 'SimpleExpandableView'\n\n# 注意：如果您的 pod 没找到 `SimpleExpandableView`, 请使用下面的命令重试\n# pod `SimpleExpandableView`, :git =\u003e 'https://github.com/Tomortec/SimpleExpandableView.git'\n```\n\n## 作者\n\nTomortec, everything@tomortec.com\n\n## License\n\nSimpleExpandableView is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomortec%2Fsimpleexpandableview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomortec%2Fsimpleexpandableview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomortec%2Fsimpleexpandableview/lists"}