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>
This commit is contained in:
48
lib/features/rewards/presentation/cubit/reward_cubit.dart
Normal file
48
lib/features/rewards/presentation/cubit/reward_cubit.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
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());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user