fceae5529d
## New: Projects - Project model, API, repository, Riverpod provider - ProjectListScreen: active/archived sections, create dialog, long-press status/delete - ProjectSelector widget: DropdownButtonFormField for note + task editors - Projects tab added to shell (bottom nav + navigation rail, 4th position) - /projects route registered in GoRouter ShellRoute ## Updated: Note model - Added tags: List<String>, projectId: int?, milestoneId: int? - NotesApi.create/update pass tags and project_id - NotesRepository and NotesNotifier signatures updated - NoteEditScreen: chip-based tag input + ProjectSelector ## Updated: Task model - Added projectId: int?, milestoneId: int?, parentId: int? - TasksApi.create passes project_id; update payload includes project_id - TasksRepository and TasksNotifier signatures updated - TaskEditScreen: ProjectSelector added; project_id sent on save ## Provider fix - ProjectsNotifier.update renamed to updateProject to avoid conflict with AsyncNotifier.update(FutureOr<State> Function(State)) base method Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
134 lines
3.8 KiB
Dart
134 lines
3.8 KiB
Dart
enum TaskStatus { todo, inProgress, done }
|
|
|
|
enum TaskPriority { none, low, medium, high }
|
|
|
|
extension TaskStatusExtension on TaskStatus {
|
|
String get value => switch (this) {
|
|
TaskStatus.todo => 'todo',
|
|
TaskStatus.inProgress => 'in_progress',
|
|
TaskStatus.done => 'done',
|
|
};
|
|
|
|
String get label => switch (this) {
|
|
TaskStatus.todo => 'To Do',
|
|
TaskStatus.inProgress => 'In Progress',
|
|
TaskStatus.done => 'Done',
|
|
};
|
|
|
|
static TaskStatus fromString(String? s) => switch (s) {
|
|
'in_progress' => TaskStatus.inProgress,
|
|
'done' => TaskStatus.done,
|
|
_ => TaskStatus.todo,
|
|
};
|
|
}
|
|
|
|
extension TaskPriorityExtension on TaskPriority {
|
|
String get value => switch (this) {
|
|
TaskPriority.none => 'none',
|
|
TaskPriority.low => 'low',
|
|
TaskPriority.medium => 'medium',
|
|
TaskPriority.high => 'high',
|
|
};
|
|
|
|
String get label => switch (this) {
|
|
TaskPriority.none => 'None',
|
|
TaskPriority.low => 'Low',
|
|
TaskPriority.medium => 'Medium',
|
|
TaskPriority.high => 'High',
|
|
};
|
|
|
|
static TaskPriority fromString(String? s) => switch (s) {
|
|
'high' => TaskPriority.high,
|
|
'medium' => TaskPriority.medium,
|
|
'low' => TaskPriority.low,
|
|
_ => TaskPriority.none,
|
|
};
|
|
}
|
|
|
|
class Task {
|
|
final int id;
|
|
final String title;
|
|
final String? description;
|
|
final TaskStatus status;
|
|
final TaskPriority priority;
|
|
final DateTime? dueDate;
|
|
final int? projectId;
|
|
final int? milestoneId;
|
|
final int? parentId;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
const Task({
|
|
required this.id,
|
|
required this.title,
|
|
this.description,
|
|
required this.status,
|
|
required this.priority,
|
|
this.dueDate,
|
|
this.projectId,
|
|
this.milestoneId,
|
|
this.parentId,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory Task.fromJson(Map<String, dynamic> json) => Task(
|
|
id: json['id'] as int,
|
|
title: json['title'] as String? ?? '',
|
|
description: json['body'] as String?,
|
|
status: TaskStatusExtension.fromString(json['status'] as String?),
|
|
priority: TaskPriorityExtension.fromString(json['priority'] as String?),
|
|
dueDate: json['due_date'] != null
|
|
? DateTime.parse(json['due_date'] as String)
|
|
: null,
|
|
projectId: json['project_id'] as int?,
|
|
milestoneId: json['milestone_id'] as int?,
|
|
parentId: json['parent_id'] as int?,
|
|
createdAt: DateTime.parse(json['created_at'] as String),
|
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'title': title,
|
|
'body': description,
|
|
'status': status.value,
|
|
'priority': priority.value,
|
|
'due_date': dueDate?.toIso8601String(),
|
|
'project_id': projectId,
|
|
'milestone_id': milestoneId,
|
|
'parent_id': parentId,
|
|
};
|
|
|
|
Task copyWith({
|
|
String? title,
|
|
String? description,
|
|
TaskStatus? status,
|
|
TaskPriority? priority,
|
|
DateTime? dueDate,
|
|
Object? projectId = _undefined,
|
|
Object? milestoneId = _undefined,
|
|
Object? parentId = _undefined,
|
|
}) =>
|
|
Task(
|
|
id: id,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
status: status ?? this.status,
|
|
priority: priority ?? this.priority,
|
|
dueDate: dueDate ?? this.dueDate,
|
|
projectId: identical(projectId, _undefined)
|
|
? this.projectId
|
|
: projectId as int?,
|
|
milestoneId: identical(milestoneId, _undefined)
|
|
? this.milestoneId
|
|
: milestoneId as int?,
|
|
parentId: identical(parentId, _undefined)
|
|
? this.parentId
|
|
: parentId as int?,
|
|
createdAt: createdAt,
|
|
updatedAt: updatedAt,
|
|
);
|
|
|
|
static const _undefined = Object();
|
|
}
|