45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import 'package:hive/hive.dart';
|
|
|
|
part 'focus_session.g.dart';
|
|
|
|
@HiveType(typeId: 0)
|
|
class FocusSession extends HiveObject {
|
|
@HiveField(0)
|
|
DateTime startTime;
|
|
|
|
@HiveField(1)
|
|
int durationMinutes; // Planned duration (e.g., 25)
|
|
|
|
@HiveField(2)
|
|
int actualMinutes; // Actual time focused (may be less if stopped early)
|
|
|
|
@HiveField(3)
|
|
int distractionCount; // Simplified: just count distractions
|
|
|
|
@HiveField(4)
|
|
bool completed; // Whether the session was completed or stopped early
|
|
|
|
@HiveField(5)
|
|
List<String> distractionTypes; // List of distraction type strings
|
|
|
|
FocusSession({
|
|
required this.startTime,
|
|
required this.durationMinutes,
|
|
required this.actualMinutes,
|
|
this.distractionCount = 0,
|
|
this.completed = false,
|
|
List<String>? distractionTypes,
|
|
}) : distractionTypes = distractionTypes ?? [];
|
|
|
|
/// Get the date (without time) for grouping sessions by day
|
|
DateTime get date => DateTime(startTime.year, startTime.month, startTime.day);
|
|
|
|
/// Check if this session was today
|
|
bool get isToday {
|
|
final now = DateTime.now();
|
|
return date.year == now.year &&
|
|
date.month == now.month &&
|
|
date.day == now.day;
|
|
}
|
|
}
|