Skip to content

v1.0.0: Initial SleepChartKit Release

Choose a tag to compare

@DanielJamesTronca DanielJamesTronca released this 23 Jul 16:55
· 8 commits to main since this release

πŸŽ‰ Initial Release

Welcome to SleepChartKit - A clean, lightweight SwiftUI package for displaying beautiful sleep stage visualizations with comprehensive HealthKit integration.

✨ Core Features

πŸ“Š Timeline Visualization

  • Interactive sleep stage timeline with smooth stage transitions
  • Canvas-based rendering for precise control and performance
  • Time axis with clear labels showing sleep session duration
  • Color-coded sleep stages with intuitive visual representation

πŸ₯ HealthKit Integration

  • Native HKCategorySample support with automatic conversion
  • Direct HealthKit integration - no manual conversion needed
  • Type-safe sleep stage mapping between HealthKit and SleepChartKit
  • iOS 16+ optimized with backwards compatibility

🎨 Customization System

  • Flexible color providers - define custom color schemes for sleep stages
  • Localization support - configurable display names for internationalization
  • Custom duration formatting - personalize how sleep durations are displayed
  • Extensible architecture following SOLID principles

πŸ—οΈ Architecture

Core Components

  • SleepChartView - Main timeline chart container
  • SleepTimelineGraph - Timeline visualization with Canvas
  • SleepTimeAxisView - Time labels and axis
  • SleepLegendView - Sleep stage legend and duration summary

Data Models

  • SleepSample - Represents a sleep period with stage, start, and end times
  • SleepStage - Comprehensive enum covering all sleep stages
  • TimeSpan - Time axis label generation

Services (Protocol-Based)

  • SleepStageColorProvider - Customizable stage colors
  • SleepStageDisplayNameProvider - Localized stage names
  • DurationFormatter - Custom duration text formatting
  • TimeSpanGenerator - Flexible time axis customization

πŸ“± Platform Support

  • iOS 15.0+
  • macOS 12.0+
  • watchOS 8.0+
  • tvOS 15.0+

πŸš€ Quick Start

```swift
import SwiftUI
import SleepChartKit

struct ContentView: View {
let sleepSamples = [
SleepSample(stage: .asleepDeep, startDate: date1, endDate: date2),
SleepSample(stage: .asleepCore, startDate: date2, endDate: date3),
SleepSample(stage: .asleepREM, startDate: date3, endDate: date4)
]

var body: some View {
    SleepChartView(samples: sleepSamples)
        .padding()
}

}
```

HealthKit Integration

```swift
// Direct HealthKit integration (iOS 16+)
SleepChartView(healthKitSamples: healthKitSamples)

// Manual conversion
let sleepSamples = SleepSample.samples(from: healthKitSamples)
SleepChartView(samples: sleepSamples)
```

🎯 Sleep Stages Supported

  • Awake - Periods of wakefulness during sleep
  • REM Sleep - Rapid Eye Movement sleep phases
  • Core/Light Sleep - Standard sleep stages
  • Deep Sleep - Restorative deep sleep periods
  • Unspecified Sleep - General sleep periods
  • In Bed - Time spent in bed (intelligently filtered)

πŸ§ͺ Quality Assurance

  • Comprehensive test suite with full coverage
  • Swift Package Manager ready
  • Clean, documented code following Swift best practices
  • Memory efficient with optimized rendering

This initial release provides a solid foundation for sleep data visualization in SwiftUI applications with excellent HealthKit integration and extensive customization options.