Compare commits

...

2 Commits

168
README.md
View File

@ -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: 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 - **Color Protocols**: Define consistent color naming with custom palettes per app
- **Settings Components**: Ready-to-use toggle, picker, and selector views - **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 ## Installation
@ -17,7 +21,7 @@ Add Bedrock as a dependency in your `Package.swift`:
```swift ```swift
dependencies: [ 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: Apps can define custom color palettes by conforming to the color protocols:
```swift ```swift
// In CasinoKit - define casino-themed accent colors // Define custom accent colors
public enum CasinoAccentColors: AccentColorProvider { public enum MyAppAccentColors: AccentColorProvider {
public static let primary = Color(red: 0.9, green: 0.75, blue: 0.3) // Gold 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 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 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 // Create a complete theme
public enum CasinoTheme: AppColorTheme { public enum MyAppTheme: AppColorTheme {
public typealias Surface = CasinoSurfaceColors public typealias Surface = DefaultSurfaceColors // Reuse Bedrock defaults
public typealias Text = DefaultTextColors // Reuse Bedrock defaults public typealias Text = DefaultTextColors
public typealias Accent = CasinoAccentColors // Custom gold accents public typealias Accent = MyAppAccentColors // Custom accents
public typealias Button = CasinoButtonColors public typealias Button = DefaultButtonColors
public typealias Status = DefaultStatusColors // Reuse Bedrock defaults public typealias Status = DefaultStatusColors
public typealias Border = DefaultBorderColors public typealias Border = DefaultBorderColors
public typealias Interactive = DefaultInteractiveColors public typealias Interactive = DefaultInteractiveColors
} }
// Use in views // Use in views
Button("Deal") { } Button("Action") { }
.background(CasinoTheme.Accent.primary) .background(MyAppTheme.Accent.primary)
``` ```
#### Available Color Protocols #### Available Color Protocols
@ -113,6 +117,99 @@ Button("Deal") { }
| `BorderColorProvider` | subtle, standard, emphasized, selected | | `BorderColorProvider` | subtle, standard, emphasized, selected |
| `InteractiveColorProvider` | selected, hover, pressed, focus | | `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 ### Settings Components
Ready-to-use settings UI components: Ready-to-use settings UI components:
@ -131,11 +228,14 @@ VolumePicker(label: "Volume", volume: $soundVolume)
// Segmented picker // Segmented picker
SegmentedPicker( SegmentedPicker(
title: "Theme", title: "Theme",
options: [("Light", "light"), ("Dark", "dark"), ("Auto", "auto")], options: [
SegmentedOption(label: "Light", value: "light"),
SegmentedOption(label: "Dark", value: "dark")
],
selection: $theme selection: $theme
) )
// Selectable row // Selectable row with badge
SelectableRow( SelectableRow(
title: "Premium Plan", title: "Premium Plan",
subtitle: "Unlock all features", subtitle: "Unlock all features",
@ -145,6 +245,13 @@ SelectableRow(
) )
``` ```
### Debug Tools
```swift
MyComplexView()
.debugBorder(isDebugMode, color: .red, label: "Header")
```
### Device Detection ### Device Detection
Adapt your UI based on device characteristics: Adapt your UI based on device characteristics:
@ -155,6 +262,10 @@ if DeviceInfo.isPad {
} else { } else {
TabBarView() TabBarView()
} }
if DeviceInfo.isLandscape {
HorizontalLayout()
}
``` ```
## Design System Reference ## Design System Reference
@ -186,22 +297,21 @@ if DeviceInfo.isPad {
| `heavy` | 0.8 | Heavy overlays | | `heavy` | 0.8 | Heavy overlays |
| `almostFull` | 0.9 | Nearly opaque | | `almostFull` | 0.9 | Nearly opaque |
### Default Colors ### Animation
Default colors use a neutral blue accent. Apps should define custom themes for branding: | Name | Value | Usage |
|------|-------|-------|
| Category | Purpose | | `quick` | 0.3s | Quick transitions |
|----------|---------| | `standard` | 0.5s | Standard animations |
| `Color.Surface.*` | Background colors | | `springDuration` | 0.4s | Spring animations |
| `Color.Text.*` | Text colors | | `staggerDelay` | 0.1s | Staggered animations |
| `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 |
## Requirements ## Requirements
- iOS 18.0+ - iOS 18.0+
- macOS 15.0+ - macOS 15.0+
- Swift 6.0+ - Swift 6.0+
## License
Proprietary - All rights reserved.