Compare commits
2 Commits
fa7d848f52
...
8e788ef212
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e788ef212 | |||
| 7afa45698f |
168
README.md
168
README.md
@ -6,10 +6,14 @@ A foundational design system and UI component library for building consistent, b
|
||||
|
||||
Bedrock is designed to be the foundation upon which apps are built, providing:
|
||||
|
||||
- **Design System**: Consistent spacing, typography, and animations
|
||||
- **Design System**: Consistent spacing, typography, colors, and animations
|
||||
- **Color Protocols**: Define consistent color naming with custom palettes per app
|
||||
- **Settings Components**: Ready-to-use toggle, picker, and selector views
|
||||
- **Utilities**: Common helpers for device detection, debugging, and more
|
||||
- **Sound & Haptics**: Generic sound manager with haptic feedback support
|
||||
- **Onboarding**: First-time user experience and contextual hints
|
||||
- **Cloud Sync**: Generic iCloud data synchronization
|
||||
- **Visual Effects**: Confetti celebrations, pulsing animations
|
||||
- **Utilities**: Device detection, debugging tools, and more
|
||||
|
||||
## Installation
|
||||
|
||||
@ -17,7 +21,7 @@ Add Bedrock as a dependency in your `Package.swift`:
|
||||
|
||||
```swift
|
||||
dependencies: [
|
||||
.package(path: "../Bedrock")
|
||||
.package(url: "ssh://git@192.168.1.128:220/mbrucedogs/Bedrock.git", branch: "master")
|
||||
]
|
||||
```
|
||||
|
||||
@ -77,28 +81,28 @@ VStack { }
|
||||
Apps can define custom color palettes by conforming to the color protocols:
|
||||
|
||||
```swift
|
||||
// In CasinoKit - define casino-themed accent colors
|
||||
public enum CasinoAccentColors: AccentColorProvider {
|
||||
public static let primary = Color(red: 0.9, green: 0.75, blue: 0.3) // Gold
|
||||
// Define custom accent colors
|
||||
public enum MyAppAccentColors: AccentColorProvider {
|
||||
public static let primary = Color(red: 0.9, green: 0.75, blue: 0.3)
|
||||
public static let light = Color(red: 1.0, green: 0.85, blue: 0.4)
|
||||
public static let dark = Color(red: 0.7, green: 0.55, blue: 0.2)
|
||||
public static let secondary = Color(red: 0.2, green: 0.7, blue: 0.7) // Teal
|
||||
public static let secondary = Color(red: 0.2, green: 0.7, blue: 0.7)
|
||||
}
|
||||
|
||||
// Create a complete theme
|
||||
public enum CasinoTheme: AppColorTheme {
|
||||
public typealias Surface = CasinoSurfaceColors
|
||||
public typealias Text = DefaultTextColors // Reuse Bedrock defaults
|
||||
public typealias Accent = CasinoAccentColors // Custom gold accents
|
||||
public typealias Button = CasinoButtonColors
|
||||
public typealias Status = DefaultStatusColors // Reuse Bedrock defaults
|
||||
public enum MyAppTheme: AppColorTheme {
|
||||
public typealias Surface = DefaultSurfaceColors // Reuse Bedrock defaults
|
||||
public typealias Text = DefaultTextColors
|
||||
public typealias Accent = MyAppAccentColors // Custom accents
|
||||
public typealias Button = DefaultButtonColors
|
||||
public typealias Status = DefaultStatusColors
|
||||
public typealias Border = DefaultBorderColors
|
||||
public typealias Interactive = DefaultInteractiveColors
|
||||
}
|
||||
|
||||
// Use in views
|
||||
Button("Deal") { }
|
||||
.background(CasinoTheme.Accent.primary)
|
||||
Button("Action") { }
|
||||
.background(MyAppTheme.Accent.primary)
|
||||
```
|
||||
|
||||
#### Available Color Protocols
|
||||
@ -113,6 +117,99 @@ Button("Deal") { }
|
||||
| `BorderColorProvider` | subtle, standard, emphasized, selected |
|
||||
| `InteractiveColorProvider` | selected, hover, pressed, focus |
|
||||
|
||||
### Sound & Haptics
|
||||
|
||||
Generic sound manager that works with any app-defined sounds:
|
||||
|
||||
```swift
|
||||
// Define your app's sounds
|
||||
enum MyAppSound: String, AppSound {
|
||||
case success, error, notification
|
||||
|
||||
var resourceName: String { rawValue }
|
||||
var resourceExtension: String { "mp3" }
|
||||
var bundle: Bundle { .main }
|
||||
var fallbackSystemSoundID: UInt32? { nil }
|
||||
}
|
||||
|
||||
// Play sounds and haptics
|
||||
let soundManager = SoundManager.shared
|
||||
soundManager.play(MyAppSound.success)
|
||||
soundManager.playHaptic(.success)
|
||||
soundManager.playHaptic(.light)
|
||||
```
|
||||
|
||||
### Onboarding State
|
||||
|
||||
Track first-time user experience and contextual hints:
|
||||
|
||||
```swift
|
||||
@Observable
|
||||
class AppState {
|
||||
let onboarding = OnboardingState(appIdentifier: "myApp")
|
||||
|
||||
var showWelcome: Bool {
|
||||
!onboarding.hasCompletedWelcome
|
||||
}
|
||||
}
|
||||
|
||||
// Register hints for skip functionality
|
||||
onboarding.registerHintKeys("firstBet", "settings", "tutorial")
|
||||
|
||||
// Check if hints should show
|
||||
if onboarding.shouldShowHint("firstBet") {
|
||||
// Show hint
|
||||
onboarding.markHintShown("firstBet")
|
||||
}
|
||||
|
||||
// Complete onboarding
|
||||
onboarding.completeWelcome()
|
||||
```
|
||||
|
||||
### Cloud Sync
|
||||
|
||||
Generic iCloud synchronization for app data:
|
||||
|
||||
```swift
|
||||
// Define your persisted data
|
||||
struct MyAppData: PersistableData {
|
||||
static var dataIdentifier = "myApp"
|
||||
static var empty = MyAppData()
|
||||
|
||||
var syncPriority: Int { score }
|
||||
var lastModified: Date = .now
|
||||
var score: Int = 0
|
||||
}
|
||||
|
||||
// Create sync manager
|
||||
let syncManager = CloudSyncManager<MyAppData>()
|
||||
|
||||
// Access and modify data
|
||||
syncManager.data.score += 10
|
||||
syncManager.save()
|
||||
```
|
||||
|
||||
### Visual Effects
|
||||
|
||||
#### Confetti
|
||||
|
||||
```swift
|
||||
ZStack {
|
||||
MainContentView()
|
||||
|
||||
if showCelebration {
|
||||
ConfettiView(colors: [.red, .blue, .gold], count: 50)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Pulsing Attention
|
||||
|
||||
```swift
|
||||
Button("Tap Here") { }
|
||||
.pulsing(isActive: shouldHighlight, color: .white)
|
||||
```
|
||||
|
||||
### Settings Components
|
||||
|
||||
Ready-to-use settings UI components:
|
||||
@ -131,11 +228,14 @@ VolumePicker(label: "Volume", volume: $soundVolume)
|
||||
// Segmented picker
|
||||
SegmentedPicker(
|
||||
title: "Theme",
|
||||
options: [("Light", "light"), ("Dark", "dark"), ("Auto", "auto")],
|
||||
options: [
|
||||
SegmentedOption(label: "Light", value: "light"),
|
||||
SegmentedOption(label: "Dark", value: "dark")
|
||||
],
|
||||
selection: $theme
|
||||
)
|
||||
|
||||
// Selectable row
|
||||
// Selectable row with badge
|
||||
SelectableRow(
|
||||
title: "Premium Plan",
|
||||
subtitle: "Unlock all features",
|
||||
@ -145,6 +245,13 @@ SelectableRow(
|
||||
)
|
||||
```
|
||||
|
||||
### Debug Tools
|
||||
|
||||
```swift
|
||||
MyComplexView()
|
||||
.debugBorder(isDebugMode, color: .red, label: "Header")
|
||||
```
|
||||
|
||||
### Device Detection
|
||||
|
||||
Adapt your UI based on device characteristics:
|
||||
@ -155,6 +262,10 @@ if DeviceInfo.isPad {
|
||||
} else {
|
||||
TabBarView()
|
||||
}
|
||||
|
||||
if DeviceInfo.isLandscape {
|
||||
HorizontalLayout()
|
||||
}
|
||||
```
|
||||
|
||||
## Design System Reference
|
||||
@ -186,22 +297,21 @@ if DeviceInfo.isPad {
|
||||
| `heavy` | 0.8 | Heavy overlays |
|
||||
| `almostFull` | 0.9 | Nearly opaque |
|
||||
|
||||
### Default Colors
|
||||
### Animation
|
||||
|
||||
Default colors use a neutral blue accent. Apps should define custom themes for branding:
|
||||
|
||||
| Category | Purpose |
|
||||
|----------|---------|
|
||||
| `Color.Surface.*` | Background colors |
|
||||
| `Color.Text.*` | Text colors |
|
||||
| `Color.Accent.*` | Accent/highlight colors (default: blue) |
|
||||
| `Color.Button.*` | Button colors |
|
||||
| `Color.Status.*` | Success/warning/error colors |
|
||||
| `Color.Border.*` | Border and divider colors |
|
||||
| `Color.Interactive.*` | Interactive state colors |
|
||||
| Name | Value | Usage |
|
||||
|------|-------|-------|
|
||||
| `quick` | 0.3s | Quick transitions |
|
||||
| `standard` | 0.5s | Standard animations |
|
||||
| `springDuration` | 0.4s | Spring animations |
|
||||
| `staggerDelay` | 0.1s | Staggered animations |
|
||||
|
||||
## Requirements
|
||||
|
||||
- iOS 18.0+
|
||||
- macOS 15.0+
|
||||
- Swift 6.0+
|
||||
|
||||
## License
|
||||
|
||||
Proprietary - All rights reserved.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user