first commit
This commit is contained in:
47
lib/models/distraction_type.dart
Normal file
47
lib/models/distraction_type.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
/// Predefined distraction types
|
||||
class DistractionType {
|
||||
static const scrollingSocialMedia = 'scrolling_social_media';
|
||||
static const gotInterrupted = 'got_interrupted';
|
||||
static const feltOverwhelmed = 'felt_overwhelmed';
|
||||
static const justZonedOut = 'just_zoned_out';
|
||||
|
||||
/// Get display name for a distraction type
|
||||
static String getDisplayName(String type) {
|
||||
switch (type) {
|
||||
case scrollingSocialMedia:
|
||||
return 'Scrolling social media';
|
||||
case gotInterrupted:
|
||||
return 'Got interrupted';
|
||||
case feltOverwhelmed:
|
||||
return 'Felt overwhelmed';
|
||||
case justZonedOut:
|
||||
return 'Just zoned out';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
|
||||
/// Get emoji for a distraction type
|
||||
static String getEmoji(String type) {
|
||||
switch (type) {
|
||||
case scrollingSocialMedia:
|
||||
return '📱';
|
||||
case gotInterrupted:
|
||||
return '👥';
|
||||
case feltOverwhelmed:
|
||||
return '😰';
|
||||
case justZonedOut:
|
||||
return '💭';
|
||||
default:
|
||||
return '❓';
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all distraction types
|
||||
static List<String> get all => [
|
||||
scrollingSocialMedia,
|
||||
gotInterrupted,
|
||||
feltOverwhelmed,
|
||||
justZonedOut,
|
||||
];
|
||||
}
|
||||
44
lib/models/focus_session.dart
Normal file
44
lib/models/focus_session.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
56
lib/models/focus_session.g.dart
Normal file
56
lib/models/focus_session.g.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'focus_session.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class FocusSessionAdapter extends TypeAdapter<FocusSession> {
|
||||
@override
|
||||
final int typeId = 0;
|
||||
|
||||
@override
|
||||
FocusSession read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return FocusSession(
|
||||
startTime: fields[0] as DateTime,
|
||||
durationMinutes: fields[1] as int,
|
||||
actualMinutes: fields[2] as int,
|
||||
distractionCount: fields[3] as int,
|
||||
completed: fields[4] as bool,
|
||||
distractionTypes: (fields[5] as List?)?.cast<String>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, FocusSession obj) {
|
||||
writer
|
||||
..writeByte(6)
|
||||
..writeByte(0)
|
||||
..write(obj.startTime)
|
||||
..writeByte(1)
|
||||
..write(obj.durationMinutes)
|
||||
..writeByte(2)
|
||||
..write(obj.actualMinutes)
|
||||
..writeByte(3)
|
||||
..write(obj.distractionCount)
|
||||
..writeByte(4)
|
||||
..write(obj.completed)
|
||||
..writeByte(5)
|
||||
..write(obj.distractionTypes);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is FocusSessionAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
Reference in New Issue
Block a user