import 'package:daily_challenge/daily_challenge.dart';
import 'package:daily_challenge/data/db/entities/entities.dart';
import 'package:guru_utils/controller/lifecycle_controller.dart';
import 'package:guru_utils/datetime/datetime_utils.dart';

mixin DailyChallengeAware on LifecycleController {
  void playDailyChallenge(DateTime dateTime) {
    final entities =
        DailyChallengeManager.instance.getDailyChallengeByDate(dateTime);
    DailyChallengeManager.instance.playOrReplay(dateTime, entities);
  }

  int getDailyProgress(DateTime dateTime) {
    final entities =
        DailyChallengeManager.instance.getDailyChallengeByDate(dateTime);
    return DailyChallengeManager.instance.getDailyProgress(dateTime, entities);
  }

  Stream<List<DailyChallengeEntity>> observableDailyChallengeData(
      DateTime focusDate) {
    return DailyChallengeManager.instance
        .observableDailyChallengeData(focusDate);
  }
}
