docs: Update README with complete feature documentation

This commit is contained in:
Matt Bruce 2026-01-02 11:59:57 -06:00
parent 7afa45698f
commit 8e788ef212

144
README.md
View File

@ -9,11 +9,11 @@ Bedrock is designed to be the foundation upon which apps are built, providing:
- **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
- **Sound & Haptics**: Generic sound and haptic feedback management
- **Onboarding**: Track user onboarding progress and contextual hints
- **Cloud Sync**: Generic iCloud and local data synchronization
- **Visual Effects**: Confetti, pulsing animations, debug borders
- **Utilities**: Device detection, debugging helpers, 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
@ -21,15 +21,7 @@ Add Bedrock as a dependency in your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/yourname/Bedrock.git", from: "1.0.0")
]
```
Or for local development:
```swift
dependencies: [
.package(path: "../Bedrock")
.package(url: "ssh://git@192.168.1.128:220/mbrucedogs/Bedrock.git", branch: "master")
]
```
@ -99,9 +91,9 @@ public enum MyAppAccentColors: AccentColorProvider {
// Create a complete theme
public enum MyAppTheme: AppColorTheme {
public typealias Surface = DefaultSurfaceColors // Reuse Bedrock defaults
public typealias Surface = DefaultSurfaceColors // Reuse Bedrock defaults
public typealias Text = DefaultTextColors
public typealias Accent = MyAppAccentColors // Custom accents
public typealias Accent = MyAppAccentColors // Custom accents
public typealias Button = DefaultButtonColors
public typealias Status = DefaultStatusColors
public typealias Border = DefaultBorderColors
@ -113,14 +105,26 @@ Button("Action") { }
.background(MyAppTheme.Accent.primary)
```
### Sound & Haptic Feedback
#### Available Color Protocols
Bedrock provides a generic sound manager that works with any app-defined sounds:
| Protocol | Properties |
|----------|------------|
| `SurfaceColorProvider` | primary, secondary, tertiary, overlay, card, groupedFill, sectionFill |
| `TextColorProvider` | primary, secondary, tertiary, disabled, placeholder, inverse |
| `AccentColorProvider` | primary, light, dark, secondary |
| `ButtonColorProvider` | primaryLight, primaryDark, secondary, destructive, cancelText |
| `StatusColorProvider` | success, warning, error, info |
| `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 MySound: String, AppSound {
case tap, success, error
enum MyAppSound: String, AppSound {
case success, error, notification
var resourceName: String { rawValue }
var resourceExtension: String { "mp3" }
@ -130,50 +134,59 @@ enum MySound: String, AppSound {
// Play sounds and haptics
let soundManager = SoundManager.shared
soundManager.play(MySound.success)
soundManager.play(MyAppSound.success)
soundManager.playHaptic(.success)
soundManager.playHaptic(.light)
```
### Onboarding State
Track user onboarding and progressive feature discovery:
Track first-time user experience and contextual hints:
```swift
let onboarding = OnboardingState(appIdentifier: "myApp")
// Register all hint keys for skip functionality
onboarding.registerHintKeys("welcome", "feature1", "feature2")
// Check and show hints
if onboarding.shouldShowHint("welcome") {
// Show welcome hint
onboarding.markHintShown("welcome")
@Observable
class AppState {
let onboarding = OnboardingState(appIdentifier: "myApp")
var showWelcome: Bool {
!onboarding.hasCompletedWelcome
}
}
// Skip or complete onboarding
onboarding.completeWelcome() // Mark as completed
onboarding.skipOnboarding() // Skip all hints
// 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
Synchronize data between iCloud and local storage:
Generic iCloud synchronization for app data:
```swift
// Define your persistable data
// Define your persisted data
struct MyAppData: PersistableData {
static var dataIdentifier = "myApp"
static var empty = MyAppData()
var syncPriority: Int { totalActions }
var syncPriority: Int { score }
var lastModified: Date = .now
var totalActions: Int = 0
var score: Int = 0
}
// Use the cloud sync manager
// Create sync manager
let syncManager = CloudSyncManager<MyAppData>()
await syncManager.save(myData)
let loaded = await syncManager.load()
// Access and modify data
syncManager.data.score += 10
syncManager.save()
```
### Visual Effects
@ -185,25 +198,18 @@ ZStack {
MainContentView()
if showCelebration {
ConfettiView(colors: [.red, .blue, .green, .yellow])
ConfettiView(colors: [.red, .blue, .gold], count: 50)
}
}
```
#### Pulsing Animation
#### Pulsing Attention
```swift
Button("Tap Here") { }
.pulsing(isActive: shouldHighlight, color: .white)
```
#### Debug Borders
```swift
MyComplexView()
.debugBorder(showDebug, color: .red, label: "Header")
```
### Settings Components
Ready-to-use settings UI components:
@ -222,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",
@ -236,6 +245,13 @@ SelectableRow(
)
```
### Debug Tools
```swift
MyComplexView()
.debugBorder(isDebugMode, color: .red, label: "Header")
```
### Device Detection
Adapt your UI based on device characteristics:
@ -247,8 +263,9 @@ if DeviceInfo.isPad {
TabBarView()
}
let bounds = DeviceInfo.screenBounds
let isLandscape = DeviceInfo.isLandscape
if DeviceInfo.isLandscape {
HorizontalLayout()
}
```
## Design System Reference
@ -280,17 +297,14 @@ let isLandscape = DeviceInfo.isLandscape
| `heavy` | 0.8 | Heavy overlays |
| `almostFull` | 0.9 | Nearly opaque |
### Color Protocols
### Animation
| Protocol | Properties |
|----------|------------|
| `SurfaceColorProvider` | primary, secondary, tertiary, overlay, card, groupedFill, sectionFill |
| `TextColorProvider` | primary, secondary, tertiary, disabled, placeholder, inverse |
| `AccentColorProvider` | primary, light, dark, secondary |
| `ButtonColorProvider` | primaryLight, primaryDark, secondary, destructive, cancelText |
| `StatusColorProvider` | success, warning, error, info |
| `BorderColorProvider` | subtle, standard, emphasized, selected |
| `InteractiveColorProvider` | selected, hover, pressed, focus |
| Name | Value | Usage |
|------|-------|-------|
| `quick` | 0.3s | Quick transitions |
| `standard` | 0.5s | Standard animations |
| `springDuration` | 0.4s | Spring animations |
| `staggerDelay` | 0.1s | Staggered animations |
## Requirements
@ -300,4 +314,4 @@ let isLandscape = DeviceInfo.isLandscape
## License
MIT License
Proprietary - All rights reserved.