Skip to content

Commit 60cc9b5

Browse files
committed
init
0 parents  commit 60cc9b5

12 files changed

Lines changed: 1517 additions & 0 deletions

.gitignore

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Xcode
2+
.DS_Store
3+
*/xcuserdata
4+
*.xccheckout
5+
*.moved-aside
6+
DerivedData
7+
*.hmap
8+
*.ipa
9+
*.xcuserstate
10+
*.xcscmblueprint
11+
12+
# Swift Package Manager
13+
.build/
14+
Packages/
15+
*.xcodeproj
16+
.xcode/
17+
.swiftpm/
18+
19+
# Build
20+
build/
21+
*.o
22+
*.a
23+
*.dylib
24+
*.framework
25+
*.swiftmodule
26+
27+
# Swift
28+
*.swiftdoc
29+
*.swiftmodule
30+
*.swiftsourceinfo
31+
32+
# Playgrounds
33+
timeline.xctimeline
34+
playground.xcworkspace
35+
36+
# CocoaPods
37+
Pods/
38+
Podfile.lock
39+
40+
# Carthage
41+
Carthage/
42+
Cartfile.resolved
43+
44+
# Fastlane
45+
fastlane/report.xml
46+
fastlane/Preview.html
47+
fastlane/screenshots
48+
fastlane/test_output
49+
50+
# AppCode
51+
.idea/
52+
53+
# VSCode
54+
.vscode/
55+
56+
# Local Swift Package Configuration
57+
.swiftpm/configuration/registries.json
58+
.swiftpm/config/registries.json
59+
60+
# SwiftLint
61+
.swiftlintcache
62+
63+
# Tuist
64+
.tuist-cache/
65+
66+
# Per-user debug configuration
67+
*.lldbinit
68+
69+
# SwiftUI Preview Devices
70+
Preview Devices/
71+
72+
# macOS
73+
*.DS_Store
74+
.AppleDouble
75+
.LSOverride
76+
77+
# Temporary files
78+
*.swp
79+
*~
80+
*.lock
81+
82+
# Logs and diagnostics
83+
*.log
84+
*.trash
85+
86+
# Local development environment files
87+
.env
88+
.env.local
89+
.env.*.local
90+
91+
# Custom local files that should be ignored
92+
local.properties
93+
local.xcconfig
94+
95+
# Documentation
96+
docs/_build/
97+
docs/.DS_Store
98+
99+
# Test coverage reports
100+
*.profraw
101+
*.profdata
102+
coverage/
103+
*.gcda
104+
*.gcno
105+
106+
# Benchmarking
107+
benchmark/build/

Package.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// swift-tools-version: 6.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "BootstrapButtonKit",
8+
platforms: [
9+
.iOS(.v14),
10+
.macOS(.v11),
11+
.tvOS(.v13),
12+
.watchOS(.v6)
13+
],
14+
products: [
15+
// Products define the executables and libraries a package produces, making them visible to other packages.
16+
.library(
17+
name: "BootstrapButtonKit",
18+
targets: ["BootstrapButtonKit"]),
19+
],
20+
targets: [
21+
// Targets are the basic building blocks of a package, defining a module or a test suite.
22+
// Targets can depend on other targets in this package and products from dependencies.
23+
.target(
24+
name: "BootstrapButtonKit"),
25+
26+
]
27+
)

README.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# BootstrapStyle SwiftUI Components
2+
3+
![SwiftUI](https://img.shields.io/badge/SwiftUI-5.9+-blue.svg)
4+
![Platforms](https://img.shields.io/badge/Platforms-iOS%20%7C%20macOS%20%7C%20tvOS-lightgrey.svg)
5+
![License](https://img.shields.io/badge/License-MIT-green.svg)
6+
7+
一个受Bootstrap启发的SwiftUI组件库,提供美观、一致的按钮样式和颜色系统。
8+
9+
## 功能特性
10+
11+
- 🎨 完整的Bootstrap风格颜色系统
12+
- 🔘 多种按钮样式和变体
13+
- 📱 响应式设计,适配所有Apple平台
14+
- ⚙️ 高度可定制的外观
15+
- 🏗️ 易于集成和使用
16+
17+
## 安装
18+
19+
### Swift Package Manager
20+
21+
在Package.swift中添加以下依赖:
22+
23+
```swift
24+
dependencies: [
25+
.package(url: "https://github.com/swiftuihome/BootstrapButtonKit.git", from: "1.0.0")
26+
]
27+
```
28+
29+
或通过Xcode的"File > Add Packages..."菜单添加。
30+
31+
## 颜色系统
32+
33+
### 主题颜色 (无色调变化)
34+
35+
```swift
36+
public enum ThemeColor: String, CaseIterable {
37+
case primary, secondary, success, danger, warning, info, light, dark, black, white
38+
}
39+
```
40+
41+
### 彩色 (带色调变化)
42+
43+
```swift
44+
public enum ShadedColor: String, CaseIterable {
45+
case blue, indigo, purple, pink, red, orange, yellow, green, teal, cyan, gray
46+
}
47+
48+
public enum Shade: Int, CaseIterable {
49+
case s100 = 100, s200 = 200, s300 = 300, s400 = 400,
50+
s500 = 500, s600 = 600, s700 = 700, s800 = 800, s900 = 900
51+
}
52+
```
53+
54+
## 按钮使用指南
55+
56+
### 基本用法
57+
58+
```swift
59+
Button("Click Me") {
60+
// 按钮动作
61+
}
62+
.bootstrapButtonStyle(tint: .primary) // 使用主色调
63+
```
64+
65+
### 按钮样式选项
66+
67+
| 参数 | 类型 | 默认值 | 描述 |
68+
| --------- | ------------------------ | ------------ | ---------------------------------------- |
69+
| `tint` | `BootstrapColor` | `.blue()` | 按钮颜色 |
70+
| `size` | `BootstrapButtonSize` | `.medium` | 按钮尺寸 (`small`, `medium`, `large`) |
71+
| `variant` | `BootstrapButtonVariant` | `.solid` | 按钮变体 (`solid`, `outline`) |
72+
| `layout` | `BootstrapButtonLayout` | `.expanded` | 布局模式 (`compact`, `expanded`) |
73+
| `rounded` | `BootstrapButtonRounded` | `.custom(6)` | 圆角样式 (`square`, `capsule`, `custom`) |
74+
75+
### 预定义按钮样式
76+
77+
#### 主题色按钮
78+
79+
```swift
80+
.primaryButtonStyle() // 主要按钮
81+
.secondaryButtonStyle() // 次要按钮
82+
.successButtonStyle() // 成功按钮
83+
.dangerButtonStyle() // 危险按钮
84+
.warningButtonStyle() // 警告按钮
85+
.infoButtonStyle() // 信息按钮
86+
.lightButtonStyle() // 浅色按钮
87+
.darkButtonStyle() // 深色按钮
88+
.blackButtonStyle() // 黑色按钮
89+
.whiteButtonStyle() // 白色按钮
90+
```
91+
92+
#### 彩色按钮 (可指定色调)
93+
94+
```swift
95+
.blueButtonStyle(.s500) // 蓝色按钮
96+
.indigoButtonStyle(.s600) // 靛蓝按钮
97+
.purpleButtonStyle(.s700) // 紫色按钮
98+
.pinkButtonStyle(.s500) // 粉色按钮
99+
.redButtonStyle(.s600) // 红色按钮
100+
.orangeButtonStyle(.s500) // 橙色按钮
101+
.yellowButtonStyle(.s500) // 黄色按钮
102+
.greenButtonStyle(.s600) // 绿色按钮
103+
.tealButtonStyle(.s500) // 蓝绿色按钮
104+
.cyanButtonStyle(.s500) // 青色按钮
105+
.grayButtonStyle(.s500) // 灰色按钮
106+
```
107+
108+
### 完整示例
109+
110+
```swift
111+
VStack(spacing: 20) {
112+
// 主题色按钮示例
113+
Button("Primary Button") {}
114+
.primaryButtonStyle()
115+
116+
Button("Danger Outline") {}
117+
.dangerButtonStyle(variant: .outline)
118+
119+
// 彩色按钮示例
120+
Button("Blue 500") {}
121+
.blueButtonStyle()
122+
123+
Button("Red 600") {}
124+
.redButtonStyle(.s600, size: .large)
125+
126+
// 自定义按钮
127+
Button("Custom Button") {}
128+
.bootstrapButtonStyle(
129+
tint: .purple(.s700),
130+
size: .small,
131+
variant: .outline,
132+
rounded: .capsule
133+
)
134+
}
135+
.padding()
136+
```
137+
138+
## 颜色预览
139+
140+
您可以使用内置的`BootstrapButtonView`来预览所有可用颜色和样式:
141+
142+
```swift
143+
struct ContentView: View {
144+
var body: some View {
145+
BootstrapButtonView()
146+
}
147+
}
148+
```
149+
150+
## 贡献指南
151+
152+
欢迎提交Pull Request或Issue。在提交代码前请确保:
153+
1. 代码符合Swift风格指南
154+
2. 添加必要的测试
155+
3. 更新相关文档
156+
157+
## 许可证
158+
159+
本项目采用MIT许可证。详见[LICENSE](LICENSE)文件。

0 commit comments

Comments
 (0)