/
siblun
/
ReadFlow
Обзор
Документация
Войти
/
siblun
/
ReadFlow
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
lib/domain/models/session_model.dart
52 строки
1 KB
siblun
Add docs
21 апр 2026, 16:13
21 апр 2026, 16:13
c40d018
Код
Авторство
О чём код?
/// Сессия чтения. Описывает временной интервал и количество прочитанных страниц. class Session{ final String id; final String bookId; final int startPage; final int endPage; final DateTime startTime; final DateTime? endTime; final String? note; Session({ required this.id, required this.bookId, required this.startPage, required this.endPage, required this.startTime, this.endTime, this.note, }); bool get isCompleted => endTime != null; int get pagesRead => endPage - startPage; int get durationSeconds { if (endTime == null) return 0; return endTime!.difference(startTime).inSeconds; } int get durationMinutes => (durationSeconds / 60).round(); String get durationFormatted { final hours = durationSeconds ~/ 3600; final minutes = (durationSeconds % 3600) ~/ 60; if (hours > 0) { return '$hoursч $minutesм'; } return '$minutesм'; } Session copyWith({ int? endPage, DateTime? endTime, String? note, }) { return Session( id: id, bookId: bookId, startPage: startPage, endPage: endPage ?? this.endPage, startTime: startTime, endTime: endTime ?? this.endTime, note: note ?? this.note, ); } }