Skip to content

Latest commit

 

History

History
96 lines (72 loc) · 2.22 KB

README.md

File metadata and controls

96 lines (72 loc) · 2.22 KB

MindGymKit

💪🏿 v0.2.4

This library was created to easily manage health-related functions.

Installation

Carthage

Add the following entry to your Cartfile:

preparing 🙏

CocoaPods

Add the following entry to your Podfile:

preparing 🙏

Then run pod install

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

https://github.com/MaeumGajim/MindGymKit.git

Usage

Info.plist 📄

  • How to allow camera access:

    // Message explaining why the app requested permission to read samples from the HealthKit store.
    Privacy - Health Share Usage Description ⚓️
  • How to allow album access:

    // Message explaining why the app requested permission to save samples to the HealthKit store.
    Privacy - Health Update Usage Description 🦾

⚠️ Don't forget to fill in the value ⚠️

MindGymKit

  • Get today's number of steps:

    let mindGym = MindGymKit()
    
    mindGym.fetchTodayStepCount { stepCount in
         DispatchQueue.main.async {
             if let stepCount = stepCount {
                    print("todayStep: \(stepCount)")
                } else {
                    print("Error")
                }
            }
      }
  • Using a stopwatch:

    let stopwatch = MindGymStopWatchKit()
    
    stopwatch.mainStopwatch.timeUpdate
        .observe(on: MainScheduler.instance)
        .subscribe(onNext: { [weak self] timeString in
            self?.stopWatchLabel.text = timeString
        })
        .disposed(by: disposeBag)
        
    stopwatch.mainStopwatch.recordUpdate
        .observe(on: MainScheduler.instance)
        .subscribe(onNext: { [weak self] lapTimes in
            self?.lapRecords = lapTimes
            self?.lapRecords.append(lapTimes.last ?? "")
            print("Lap record : \(String(describing: self?.lapRecords ?? nil))")
        })
        .disposed(by: disposeBag)