Files
focusflow/lib/features/rewards/presentation/cubit/reward_cubit.dart
Oracle Public Cloud User 50931d839d Initial scaffold: FocusFlow ADHD Task Manager Flutter app
BLoC/Cubit state management, ADHD-friendly theme (calming teal, no red),
GetIt DI, GoRouter navigation. Screens: task dashboard, focus mode,
task create/detail, streaks, time perception, settings, onboarding, auth.
Custom widgets: TaskCard, RewardPopup, StreakRing, GentleNudgeCard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:53:58 +00:00

49 lines
1.6 KiB
Dart

import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:focusflow_shared/focusflow_shared.dart';
// ── States ─────────────────────────────────────────────────────────
sealed class RewardState extends Equatable {
const RewardState();
@override
List<Object?> get props => [];
}
class RewardIdle extends RewardState {}
class RewardShowing extends RewardState {
final Reward reward;
const RewardShowing(this.reward);
@override
List<Object?> get props => [reward];
}
class RewardDismissed extends RewardState {}
// ── Cubit ──────────────────────────────────────────────────────────
/// Manages the reward overlay display lifecycle.
///
/// Flow:
/// 1. After a task is completed, call [showReward].
/// 2. The UI renders [RewardPopup] when state is [RewardShowing].
/// 3. User taps dismiss -> call [dismiss].
class RewardCubit extends Cubit<RewardState> {
RewardCubit() : super(RewardIdle());
/// Show a reward to the user.
void showReward(Reward reward) {
emit(RewardShowing(reward));
}
/// Dismiss the current reward and return to idle.
void dismiss() {
emit(RewardDismissed());
// Brief delay then return to idle so the cubit is ready for the next reward.
Future<void>.delayed(const Duration(milliseconds: 300), () {
if (!isClosed) emit(RewardIdle());
});
}
}