4da36aa31d
Flutter Android client for FabledAssistant with: - Session-cookie auth via persistent cookie jar (Dio + cookie_jar) - OAuth/SSO login via in-app WebView (flutter_inappwebview) - Notes: list, detail (markdown render), create/edit - Tasks: list with status tabs, create/edit with priority - Chat: SSE streaming bubbles, conversation management - Quick Capture FAB for rapid note/task creation - Settings screen (change server URL, logout) - Android home screen widget → opens chat - Riverpod state management, go_router navigation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
108 lines
3.0 KiB
Dart
108 lines
3.0 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 DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
const Task({
|
|
required this.id,
|
|
required this.title,
|
|
this.description,
|
|
required this.status,
|
|
required this.priority,
|
|
this.dueDate,
|
|
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,
|
|
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(),
|
|
};
|
|
|
|
Task copyWith({
|
|
String? title,
|
|
String? description,
|
|
TaskStatus? status,
|
|
TaskPriority? priority,
|
|
DateTime? dueDate,
|
|
}) =>
|
|
Task(
|
|
id: id,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
status: status ?? this.status,
|
|
priority: priority ?? this.priority,
|
|
dueDate: dueDate ?? this.dueDate,
|
|
createdAt: createdAt,
|
|
updatedAt: updatedAt,
|
|
);
|
|
}
|