Initial commit: Fabled Android app
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>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class Conversation {
|
||||
final int id;
|
||||
final String title;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
const Conversation({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
factory Conversation.fromJson(Map<String, dynamic> json) => Conversation(
|
||||
id: json['id'] as int,
|
||||
title: json['title'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
enum MessageRole { user, assistant }
|
||||
|
||||
class Message {
|
||||
final int? id;
|
||||
final int conversationId;
|
||||
final MessageRole role;
|
||||
final String content;
|
||||
final String status; // "complete" | "generating"
|
||||
final DateTime? createdAt;
|
||||
|
||||
const Message({
|
||||
this.id,
|
||||
required this.conversationId,
|
||||
required this.role,
|
||||
required this.content,
|
||||
this.status = 'complete',
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
factory Message.fromJson(Map<String, dynamic> json) => Message(
|
||||
id: json['id'] as int?,
|
||||
conversationId: json['conversation_id'] as int,
|
||||
role: json['role'] == 'user' ? MessageRole.user : MessageRole.assistant,
|
||||
content: json['content'] as String,
|
||||
status: json['status'] as String? ?? 'complete',
|
||||
createdAt: json['created_at'] != null
|
||||
? DateTime.parse(json['created_at'] as String)
|
||||
: null,
|
||||
);
|
||||
|
||||
Message copyWith({String? content, String? status}) => Message(
|
||||
id: id,
|
||||
conversationId: conversationId,
|
||||
role: role,
|
||||
content: content ?? this.content,
|
||||
status: status ?? this.status,
|
||||
createdAt: createdAt,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class Note {
|
||||
final int id;
|
||||
final String title;
|
||||
final String body;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
|
||||
const Note({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.body,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
factory Note.fromJson(Map<String, dynamic> json) => Note(
|
||||
id: json['id'] as int,
|
||||
title: json['title'] as String? ?? '',
|
||||
body: json['body'] as String? ?? '',
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'title': title,
|
||||
'body': body,
|
||||
};
|
||||
|
||||
Note copyWith({String? title, String? body}) => Note(
|
||||
id: id,
|
||||
title: title ?? this.title,
|
||||
body: body ?? this.body,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user