feat(notes): Add notes feature with editor page and drawer integration
This commit is contained in:
214
lib/core/models/note.dart
Normal file
214
lib/core/models/note.dart
Normal file
@@ -0,0 +1,214 @@
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'note.freezed.dart';
|
||||
part 'note.g.dart';
|
||||
|
||||
/// Content structure for a note, supporting multiple formats.
|
||||
@freezed
|
||||
sealed class NoteContent with _$NoteContent {
|
||||
const factory NoteContent({
|
||||
/// Raw JSON content from rich text editor (if any)
|
||||
Object? json,
|
||||
|
||||
/// HTML representation
|
||||
@Default('') String html,
|
||||
|
||||
/// Markdown representation
|
||||
@Default('') String md,
|
||||
}) = _NoteContent;
|
||||
|
||||
factory NoteContent.fromJson(Map<String, dynamic> json) =>
|
||||
_$NoteContentFromJson(json);
|
||||
}
|
||||
|
||||
/// Data payload for a note, containing content and optional files/versions.
|
||||
@freezed
|
||||
sealed class NoteData with _$NoteData {
|
||||
const factory NoteData({
|
||||
/// The main content of the note
|
||||
@Default(NoteContent()) NoteContent content,
|
||||
|
||||
/// Previous versions for undo/history
|
||||
@Default([]) List<NoteContent> versions,
|
||||
|
||||
/// Attached files (if any)
|
||||
@_FileListConverter() List<Map<String, dynamic>>? files,
|
||||
}) = _NoteData;
|
||||
|
||||
factory NoteData.fromJson(Map<String, dynamic> json) =>
|
||||
_$NoteDataFromJson(json);
|
||||
}
|
||||
|
||||
/// Converter for files list which can be null or a list of maps.
|
||||
class _FileListConverter
|
||||
implements JsonConverter<List<Map<String, dynamic>>?, Object?> {
|
||||
const _FileListConverter();
|
||||
|
||||
@override
|
||||
List<Map<String, dynamic>>? fromJson(Object? json) {
|
||||
if (json == null) return null;
|
||||
if (json is List) {
|
||||
return json.whereType<Map<String, dynamic>>().toList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Object? toJson(List<Map<String, dynamic>>? object) => object;
|
||||
}
|
||||
|
||||
/// User information associated with a note.
|
||||
@freezed
|
||||
sealed class NoteUser with _$NoteUser {
|
||||
const factory NoteUser({
|
||||
required String id,
|
||||
String? name,
|
||||
String? email,
|
||||
@JsonKey(name: 'profile_image_url') String? profileImageUrl,
|
||||
}) = _NoteUser;
|
||||
|
||||
factory NoteUser.fromJson(Map<String, dynamic> json) =>
|
||||
_$NoteUserFromJson(json);
|
||||
}
|
||||
|
||||
/// A Note model matching the OpenWebUI notes API structure.
|
||||
@freezed
|
||||
sealed class Note with _$Note {
|
||||
const Note._();
|
||||
|
||||
const factory Note({
|
||||
required String id,
|
||||
@JsonKey(name: 'user_id') required String userId,
|
||||
required String title,
|
||||
|
||||
/// Note content and associated data
|
||||
@_NoteDataConverter() @Default(NoteData()) NoteData data,
|
||||
|
||||
/// Additional metadata
|
||||
@_MetadataConverter() Map<String, dynamic>? meta,
|
||||
|
||||
/// Access control settings
|
||||
@JsonKey(name: 'access_control')
|
||||
@_MetadataConverter()
|
||||
Map<String, dynamic>? accessControl,
|
||||
|
||||
/// Creation timestamp in nanoseconds
|
||||
@JsonKey(name: 'created_at') required int createdAt,
|
||||
|
||||
/// Last update timestamp in nanoseconds
|
||||
@JsonKey(name: 'updated_at') required int updatedAt,
|
||||
|
||||
/// User who created the note (optional, from extended response)
|
||||
NoteUser? user,
|
||||
}) = _Note;
|
||||
|
||||
factory Note.fromJson(Map<String, dynamic> json) => _$NoteFromJson(json);
|
||||
|
||||
/// Get created date as DateTime
|
||||
DateTime get createdDateTime =>
|
||||
DateTime.fromMicrosecondsSinceEpoch(createdAt ~/ 1000);
|
||||
|
||||
/// Get updated date as DateTime
|
||||
DateTime get updatedDateTime =>
|
||||
DateTime.fromMicrosecondsSinceEpoch(updatedAt ~/ 1000);
|
||||
|
||||
/// Get the markdown content of the note
|
||||
String get markdownContent => data.content.md;
|
||||
|
||||
/// Get the HTML content of the note
|
||||
String get htmlContent => data.content.html;
|
||||
|
||||
/// Check if the note has content
|
||||
bool get hasContent =>
|
||||
data.content.md.isNotEmpty || data.content.html.isNotEmpty;
|
||||
}
|
||||
|
||||
/// Converter for NoteData that handles both object and null cases.
|
||||
class _NoteDataConverter implements JsonConverter<NoteData, Object?> {
|
||||
const _NoteDataConverter();
|
||||
|
||||
@override
|
||||
NoteData fromJson(Object? json) {
|
||||
if (json == null) return const NoteData();
|
||||
if (json is Map<String, dynamic>) {
|
||||
// Handle the nested content structure
|
||||
final contentJson = json['content'];
|
||||
NoteContent content = const NoteContent();
|
||||
if (contentJson is Map<String, dynamic>) {
|
||||
content = NoteContent.fromJson(contentJson);
|
||||
}
|
||||
|
||||
// Handle versions
|
||||
final versionsJson = json['versions'];
|
||||
List<NoteContent> versions = [];
|
||||
if (versionsJson is List) {
|
||||
versions = versionsJson
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map((v) => NoteContent.fromJson(v))
|
||||
.toList();
|
||||
}
|
||||
|
||||
// Handle files
|
||||
final filesJson = json['files'];
|
||||
List<Map<String, dynamic>>? files;
|
||||
if (filesJson is List) {
|
||||
files = filesJson.whereType<Map<String, dynamic>>().toList();
|
||||
}
|
||||
|
||||
return NoteData(content: content, versions: versions, files: files);
|
||||
}
|
||||
return const NoteData();
|
||||
}
|
||||
|
||||
@override
|
||||
Object? toJson(NoteData object) => object.toJson();
|
||||
}
|
||||
|
||||
/// Converter for metadata maps.
|
||||
class _MetadataConverter
|
||||
implements JsonConverter<Map<String, dynamic>?, Object?> {
|
||||
const _MetadataConverter();
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? fromJson(Object? json) {
|
||||
if (json == null) return null;
|
||||
if (json is Map<String, dynamic>) return json;
|
||||
if (json is Map) {
|
||||
return json.map((key, value) => MapEntry(key.toString(), value));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Object? toJson(Map<String, dynamic>? object) => object;
|
||||
}
|
||||
|
||||
/// Form data for creating a new note.
|
||||
@freezed
|
||||
sealed class NoteForm with _$NoteForm {
|
||||
const factory NoteForm({
|
||||
required String title,
|
||||
NoteData? data,
|
||||
Map<String, dynamic>? meta,
|
||||
@JsonKey(name: 'access_control') Map<String, dynamic>? accessControl,
|
||||
}) = _NoteForm;
|
||||
|
||||
factory NoteForm.fromJson(Map<String, dynamic> json) =>
|
||||
_$NoteFormFromJson(json);
|
||||
}
|
||||
|
||||
/// Form data for updating a note.
|
||||
@freezed
|
||||
sealed class NoteUpdateForm with _$NoteUpdateForm {
|
||||
const factory NoteUpdateForm({
|
||||
String? title,
|
||||
NoteData? data,
|
||||
Map<String, dynamic>? meta,
|
||||
@JsonKey(name: 'access_control') Map<String, dynamic>? accessControl,
|
||||
}) = _NoteUpdateForm;
|
||||
|
||||
factory NoteUpdateForm.fromJson(Map<String, dynamic> json) =>
|
||||
_$NoteUpdateFormFromJson(json);
|
||||
}
|
||||
@@ -2156,6 +2156,22 @@ class FoldersFeatureEnabledNotifier extends Notifier<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tracks whether the notes feature is enabled on the server.
|
||||
/// When the server returns 403 for notes endpoint, this becomes false.
|
||||
final notesFeatureEnabledProvider =
|
||||
NotifierProvider<NotesFeatureEnabledNotifier, bool>(
|
||||
NotesFeatureEnabledNotifier.new,
|
||||
);
|
||||
|
||||
class NotesFeatureEnabledNotifier extends Notifier<bool> {
|
||||
@override
|
||||
bool build() => true;
|
||||
|
||||
void setEnabled(bool enabled) {
|
||||
state = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
// Folders provider
|
||||
@Riverpod(keepAlive: true)
|
||||
class Folders extends _$Folders {
|
||||
|
||||
@@ -16,6 +16,8 @@ import '../../features/auth/views/connection_issue_page.dart';
|
||||
import '../../features/auth/views/server_connection_page.dart';
|
||||
import '../../features/chat/views/chat_page.dart';
|
||||
import '../../features/navigation/views/splash_launcher_page.dart';
|
||||
import '../../features/notes/views/notes_list_page.dart';
|
||||
import '../../features/notes/views/note_editor_page.dart';
|
||||
import '../../features/profile/views/app_customization_page.dart';
|
||||
import '../../features/profile/views/profile_page.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
@@ -242,6 +244,22 @@ final goRouterProvider = Provider<GoRouter>((ref) {
|
||||
name: RouteNames.appCustomization,
|
||||
builder: (context, state) => const AppCustomizationPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: Routes.notes,
|
||||
name: RouteNames.notes,
|
||||
builder: (context, state) => const NotesListPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: Routes.noteEditor,
|
||||
name: RouteNames.noteEditor,
|
||||
builder: (context, state) {
|
||||
final noteId = state.pathParameters['id'];
|
||||
if (noteId == null || noteId.isEmpty) {
|
||||
return const NotesListPage();
|
||||
}
|
||||
return NoteEditorPage(noteId: noteId);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
final router = GoRouter(
|
||||
|
||||
@@ -2392,55 +2392,6 @@ class ApiService {
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getNotes() async {
|
||||
_traceApi('Fetching notes');
|
||||
final response = await _dio.get('/api/v1/notes/');
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
return data.cast<Map<String, dynamic>>();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> createNote({
|
||||
required String title,
|
||||
required String content,
|
||||
List<String>? tags,
|
||||
}) async {
|
||||
_traceApi('Creating note: $title');
|
||||
final response = await _dio.post(
|
||||
'/api/v1/notes/',
|
||||
data: {
|
||||
'title': title,
|
||||
'content': content,
|
||||
if (tags != null) 'tags': tags,
|
||||
},
|
||||
);
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
Future<void> updateNote(
|
||||
String id, {
|
||||
String? title,
|
||||
String? content,
|
||||
List<String>? tags,
|
||||
}) async {
|
||||
_traceApi('Updating note: $id');
|
||||
await _dio.put(
|
||||
'/api/v1/notes/$id',
|
||||
data: {
|
||||
if (title != null) 'title': title,
|
||||
if (content != null) 'content': content,
|
||||
if (tags != null) 'tags': tags,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> deleteNote(String id) async {
|
||||
_traceApi('Deleting note: $id');
|
||||
await _dio.delete('/api/v1/notes/$id');
|
||||
}
|
||||
|
||||
// Team Collaboration
|
||||
Future<List<Map<String, dynamic>>> getChannels() async {
|
||||
_traceApi('Fetching channels');
|
||||
@@ -3585,6 +3536,226 @@ class ApiService {
|
||||
|
||||
// ==================== END ADVANCED CHAT FEATURES ====================
|
||||
|
||||
// ==================== NOTES ====================
|
||||
|
||||
/// Get all notes with user information.
|
||||
/// Returns a record with (notes data, feature enabled flag).
|
||||
/// When the notes feature is disabled server-side (403), returns ([], false).
|
||||
Future<(List<Map<String, dynamic>>, bool)> getNotes() async {
|
||||
try {
|
||||
_traceApi('Fetching notes');
|
||||
final response = await _dio.get('/api/v1/notes/');
|
||||
DebugLogger.log(
|
||||
'fetch-status',
|
||||
scope: 'api/notes',
|
||||
data: {'code': response.statusCode},
|
||||
);
|
||||
DebugLogger.log('fetch-ok', scope: 'api/notes');
|
||||
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
_traceApi('Found ${data.length} notes');
|
||||
return (data.cast<Map<String, dynamic>>(), true);
|
||||
} else {
|
||||
DebugLogger.warning(
|
||||
'unexpected-type',
|
||||
scope: 'api/notes',
|
||||
data: {'type': data.runtimeType},
|
||||
);
|
||||
return (const <Map<String, dynamic>>[], true);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
// 403 indicates notes feature is disabled server-side
|
||||
if (e.response?.statusCode == 403) {
|
||||
DebugLogger.log(
|
||||
'feature-disabled',
|
||||
scope: 'api/notes',
|
||||
data: {'status': 403},
|
||||
);
|
||||
return (const <Map<String, dynamic>>[], false);
|
||||
}
|
||||
DebugLogger.error('fetch-failed', scope: 'api/notes', error: e);
|
||||
rethrow;
|
||||
} catch (e) {
|
||||
DebugLogger.error('fetch-failed', scope: 'api/notes', error: e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get paginated note list (title, id, timestamps only)
|
||||
Future<List<Map<String, dynamic>>> getNoteList({int? page}) async {
|
||||
_traceApi('Fetching note list, page: $page');
|
||||
final queryParams = <String, dynamic>{};
|
||||
if (page != null) queryParams['page'] = page;
|
||||
|
||||
final response = await _dio.get(
|
||||
'/api/v1/notes/list',
|
||||
queryParameters: queryParams.isNotEmpty ? queryParams : null,
|
||||
);
|
||||
final data = response.data;
|
||||
if (data is List) {
|
||||
return data.cast<Map<String, dynamic>>();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/// Get a single note by ID
|
||||
Future<Map<String, dynamic>> getNoteById(String id) async {
|
||||
_traceApi('Fetching note: $id');
|
||||
final response = await _dio.get('/api/v1/notes/$id');
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
/// Create a new note
|
||||
Future<Map<String, dynamic>> createNote({
|
||||
required String title,
|
||||
Map<String, dynamic>? data,
|
||||
Map<String, dynamic>? meta,
|
||||
Map<String, dynamic>? accessControl,
|
||||
}) async {
|
||||
_traceApi('Creating note: $title');
|
||||
final response = await _dio.post(
|
||||
'/api/v1/notes/create',
|
||||
data: {
|
||||
'title': title,
|
||||
if (data != null) 'data': data,
|
||||
if (meta != null) 'meta': meta,
|
||||
if (accessControl != null) 'access_control': accessControl,
|
||||
},
|
||||
);
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
/// Update an existing note
|
||||
Future<Map<String, dynamic>> updateNote(
|
||||
String id, {
|
||||
String? title,
|
||||
Map<String, dynamic>? data,
|
||||
Map<String, dynamic>? meta,
|
||||
Map<String, dynamic>? accessControl,
|
||||
}) async {
|
||||
_traceApi('Updating note: $id');
|
||||
final response = await _dio.post(
|
||||
'/api/v1/notes/$id/update',
|
||||
data: {
|
||||
if (title != null) 'title': title,
|
||||
if (data != null) 'data': data,
|
||||
if (meta != null) 'meta': meta,
|
||||
if (accessControl != null) 'access_control': accessControl,
|
||||
},
|
||||
);
|
||||
return response.data as Map<String, dynamic>;
|
||||
}
|
||||
|
||||
/// Delete a note by ID
|
||||
Future<bool> deleteNote(String id) async {
|
||||
_traceApi('Deleting note: $id');
|
||||
final response = await _dio.delete('/api/v1/notes/$id/delete');
|
||||
return response.data == true;
|
||||
}
|
||||
|
||||
/// Generate a title for note content using AI
|
||||
Future<String?> generateNoteTitle(
|
||||
String content, {
|
||||
required String modelId,
|
||||
}) async {
|
||||
_traceApi('Generating title for note content with model: $modelId');
|
||||
|
||||
final prompt =
|
||||
'''### Task:
|
||||
Generate a concise, 3-5 word title with an emoji summarizing the content in the content's primary language.
|
||||
### Guidelines:
|
||||
- The title should clearly represent the main theme or subject of the content.
|
||||
- Use emojis that enhance understanding of the topic, but avoid quotation marks or special formatting.
|
||||
- Write the title in the content's primary language.
|
||||
- Prioritize accuracy over excessive creativity; keep it clear and simple.
|
||||
- Your entire response must consist solely of the JSON object, without any introductory or concluding text.
|
||||
- The output must be a single, raw JSON object, without any markdown code fences or other encapsulating text.
|
||||
- Ensure no conversational text, affirmations, or explanations precede or follow the raw JSON output, as this will cause direct parsing failure.
|
||||
### Output:
|
||||
JSON format: { "title": "your concise title here" }
|
||||
### Examples:
|
||||
- { "title": "📉 Stock Market Trends" },
|
||||
- { "title": "🍪 Perfect Chocolate Chip Recipe" },
|
||||
- { "title": "Evolution of Music Streaming" },
|
||||
- { "title": "Remote Work Productivity Tips" },
|
||||
- { "title": "Artificial Intelligence in Healthcare" },
|
||||
- { "title": "🎮 Video Game Development Insights" }
|
||||
### Content:
|
||||
<content>
|
||||
$content
|
||||
</content>''';
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
'/api/chat/completions',
|
||||
data: {
|
||||
'model': modelId,
|
||||
'stream': false,
|
||||
'messages': [
|
||||
{'role': 'user', 'content': prompt},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
final responseText =
|
||||
response.data?['choices']?[0]?['message']?['content'] as String? ??
|
||||
'';
|
||||
|
||||
_traceApi('Title generation response: $responseText');
|
||||
|
||||
// Parse JSON from response
|
||||
final jsonStart = responseText.indexOf('{');
|
||||
final jsonEnd = responseText.lastIndexOf('}');
|
||||
|
||||
if (jsonStart != -1 && jsonEnd != -1) {
|
||||
final jsonStr = responseText.substring(jsonStart, jsonEnd + 1);
|
||||
final parsed = jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
return (parsed['title'] as String?)?.trim();
|
||||
}
|
||||
} catch (e) {
|
||||
_traceApi('Failed to generate note title: $e');
|
||||
rethrow;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Enhance note content using AI
|
||||
Future<String?> enhanceNoteContent(
|
||||
String content, {
|
||||
required String modelId,
|
||||
}) async {
|
||||
_traceApi('Enhancing note content with AI, model: $modelId');
|
||||
|
||||
const systemPrompt =
|
||||
'''Enhance existing notes using the content's primary language. Your task is to make the notes more useful and comprehensive.
|
||||
|
||||
# Output Format
|
||||
|
||||
Provide the enhanced notes in markdown format. Use markdown syntax for headings, lists, task lists ([ ]) where tasks or checklists are strongly implied, and emphasis to improve clarity and presentation. Ensure that all integrated content is accurately reflected. Return only the markdown formatted note.''';
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
'/api/chat/completions',
|
||||
data: {
|
||||
'model': modelId,
|
||||
'stream': false,
|
||||
'messages': [
|
||||
{'role': 'system', 'content': systemPrompt},
|
||||
{'role': 'user', 'content': '<notes>$content</notes>'},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
return response.data?['choices']?[0]?['message']?['content'] as String?;
|
||||
} catch (e) {
|
||||
_traceApi('Failed to enhance note content: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== END NOTES ====================
|
||||
|
||||
// Legacy streaming wrapper methods removed
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ class Routes {
|
||||
static const String authentication = '/authentication';
|
||||
static const String profile = '/profile';
|
||||
static const String appCustomization = '/profile/customization';
|
||||
static const String notes = '/notes';
|
||||
static const String noteEditor = '/notes/:id';
|
||||
}
|
||||
|
||||
/// Friendly names for GoRouter routes to support context.pushNamed.
|
||||
@@ -115,4 +117,6 @@ class RouteNames {
|
||||
static const String authentication = 'authentication';
|
||||
static const String profile = 'profile';
|
||||
static const String appCustomization = 'app-customization';
|
||||
static const String notes = 'notes';
|
||||
static const String noteEditor = 'note-editor';
|
||||
}
|
||||
|
||||
@@ -1620,6 +1620,7 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
|
||||
orElse: () => authUser,
|
||||
);
|
||||
final api = ref.watch(apiServiceProvider);
|
||||
final notesEnabled = ref.watch(notesFeatureEnabledProvider);
|
||||
|
||||
String initialFor(String name) {
|
||||
if (name.isEmpty) return 'U';
|
||||
@@ -1630,6 +1631,7 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
|
||||
final displayName = deriveUserDisplayName(user);
|
||||
final initial = initialFor(displayName);
|
||||
final avatarUrl = resolveUserAvatarUrlForUser(api, user);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(Spacing.sm, 0, Spacing.sm, Spacing.sm),
|
||||
child: Column(
|
||||
@@ -1683,6 +1685,23 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Notes icon (hidden when feature is disabled)
|
||||
if (notesEnabled)
|
||||
IconButton(
|
||||
tooltip: AppLocalizations.of(context)!.notes,
|
||||
onPressed: () {
|
||||
Navigator.of(context).maybePop();
|
||||
context.pushNamed(RouteNames.notes);
|
||||
},
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.doc_text
|
||||
: Icons.note_alt_outlined,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
size: IconSize.medium,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: AppLocalizations.of(context)!.manage,
|
||||
onPressed: () {
|
||||
|
||||
297
lib/features/notes/providers/notes_providers.dart
Normal file
297
lib/features/notes/providers/notes_providers.dart
Normal file
@@ -0,0 +1,297 @@
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:conduit/core/models/note.dart';
|
||||
import 'package:conduit/core/providers/app_providers.dart';
|
||||
|
||||
part 'notes_providers.g.dart';
|
||||
|
||||
/// Provider for the list of all notes with user information.
|
||||
@riverpod
|
||||
class NotesList extends _$NotesList {
|
||||
@override
|
||||
Future<List<Note>> build() async {
|
||||
final api = ref.watch(apiServiceProvider);
|
||||
if (api == null) return const <Note>[];
|
||||
|
||||
final (rawNotes, featureEnabled) = await api.getNotes();
|
||||
|
||||
// Update the notes feature enabled state
|
||||
ref.read(notesFeatureEnabledProvider.notifier).setEnabled(featureEnabled);
|
||||
|
||||
return rawNotes.map((json) => Note.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
/// Refresh the notes list from the server.
|
||||
Future<void> refresh() async {
|
||||
state = const AsyncValue.loading();
|
||||
final result = await AsyncValue.guard(() => build());
|
||||
if (!ref.mounted) return;
|
||||
state = result;
|
||||
}
|
||||
|
||||
/// Add a newly created note to the list.
|
||||
void addNote(Note note) {
|
||||
final current = state.value ?? [];
|
||||
state = AsyncValue.data([note, ...current]);
|
||||
}
|
||||
|
||||
/// Update an existing note in the list.
|
||||
void updateNote(Note updatedNote) {
|
||||
final current = state.value ?? [];
|
||||
final updated = current.map((n) {
|
||||
return n.id == updatedNote.id ? updatedNote : n;
|
||||
}).toList();
|
||||
state = AsyncValue.data(updated);
|
||||
}
|
||||
|
||||
/// Remove a note from the list.
|
||||
void removeNote(String noteId) {
|
||||
final current = state.value ?? [];
|
||||
final updated = current.where((n) => n.id != noteId).toList();
|
||||
state = AsyncValue.data(updated);
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for a single note by ID.
|
||||
@riverpod
|
||||
Future<Note?> noteById(Ref ref, String id) async {
|
||||
final api = ref.watch(apiServiceProvider);
|
||||
if (api == null) return null;
|
||||
|
||||
final json = await api.getNoteById(id);
|
||||
return Note.fromJson(json);
|
||||
}
|
||||
|
||||
/// Helper to group notes by time range.
|
||||
enum TimeRange {
|
||||
today,
|
||||
yesterday,
|
||||
previousSevenDays,
|
||||
previousThirtyDays,
|
||||
older,
|
||||
}
|
||||
|
||||
/// Determine which time range a timestamp belongs to.
|
||||
/// Uses `!isBefore` instead of `isAfter` to include boundary timestamps
|
||||
/// (e.g., exactly midnight) in the correct range.
|
||||
TimeRange getTimeRangeForTimestamp(DateTime timestamp) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = today.subtract(const Duration(days: 1));
|
||||
final sevenDaysAgo = today.subtract(const Duration(days: 7));
|
||||
final thirtyDaysAgo = today.subtract(const Duration(days: 30));
|
||||
|
||||
if (!timestamp.isBefore(today)) {
|
||||
return TimeRange.today;
|
||||
} else if (!timestamp.isBefore(yesterday)) {
|
||||
return TimeRange.yesterday;
|
||||
} else if (!timestamp.isBefore(sevenDaysAgo)) {
|
||||
return TimeRange.previousSevenDays;
|
||||
} else if (!timestamp.isBefore(thirtyDaysAgo)) {
|
||||
return TimeRange.previousThirtyDays;
|
||||
} else {
|
||||
return TimeRange.older;
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider that returns notes grouped by time range.
|
||||
@riverpod
|
||||
Map<TimeRange, List<Note>> notesGroupedByTime(Ref ref) {
|
||||
final notesAsync = ref.watch(notesListProvider);
|
||||
final notes = notesAsync.value ?? [];
|
||||
|
||||
final grouped = <TimeRange, List<Note>>{};
|
||||
|
||||
for (final note in notes) {
|
||||
final range = getTimeRangeForTimestamp(note.updatedDateTime);
|
||||
grouped.putIfAbsent(range, () => []).add(note);
|
||||
}
|
||||
|
||||
return grouped;
|
||||
}
|
||||
|
||||
/// Provider for notes filtered by search query.
|
||||
@riverpod
|
||||
List<Note> filteredNotes(Ref ref, String query) {
|
||||
final notesAsync = ref.watch(notesListProvider);
|
||||
final notes = notesAsync.value ?? [];
|
||||
|
||||
if (query.isEmpty) return notes;
|
||||
|
||||
final lowerQuery = query.toLowerCase();
|
||||
return notes.where((note) {
|
||||
final titleMatch = note.title.toLowerCase().contains(lowerQuery);
|
||||
final contentMatch = note.markdownContent.toLowerCase().contains(
|
||||
lowerQuery,
|
||||
);
|
||||
return titleMatch || contentMatch;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/// Provider for creating a new note.
|
||||
@Riverpod(keepAlive: true)
|
||||
class NoteCreator extends _$NoteCreator {
|
||||
@override
|
||||
AsyncValue<Note?> build() => const AsyncValue.data(null);
|
||||
|
||||
/// Create a new note and return it.
|
||||
Future<Note?> createNote({
|
||||
required String title,
|
||||
String? markdownContent,
|
||||
String? htmlContent,
|
||||
}) async {
|
||||
state = const AsyncValue.loading();
|
||||
|
||||
final api = ref.read(apiServiceProvider);
|
||||
if (api == null) {
|
||||
if (!ref.mounted) return null;
|
||||
state = AsyncValue.error(
|
||||
Exception('API service not available'),
|
||||
StackTrace.current,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
final data = <String, dynamic>{
|
||||
'content': <String, dynamic>{
|
||||
'json': null,
|
||||
'html': htmlContent ?? '',
|
||||
'md': markdownContent ?? '',
|
||||
},
|
||||
'versions': <dynamic>[],
|
||||
'files': null,
|
||||
};
|
||||
|
||||
final json = await api.createNote(
|
||||
title: title,
|
||||
data: data,
|
||||
accessControl: <String, dynamic>{},
|
||||
);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
|
||||
final note = Note.fromJson(json);
|
||||
|
||||
// Add to the notes list
|
||||
ref.read(notesListProvider.notifier).addNote(note);
|
||||
|
||||
state = AsyncValue.data(note);
|
||||
return note;
|
||||
} catch (e, st) {
|
||||
if (!ref.mounted) return null;
|
||||
state = AsyncValue.error(e, st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for updating an existing note.
|
||||
@Riverpod(keepAlive: true)
|
||||
class NoteUpdater extends _$NoteUpdater {
|
||||
@override
|
||||
AsyncValue<Note?> build() => const AsyncValue.data(null);
|
||||
|
||||
/// Update a note with new content.
|
||||
Future<Note?> updateNote(
|
||||
String id, {
|
||||
String? title,
|
||||
String? markdownContent,
|
||||
String? htmlContent,
|
||||
Object? jsonContent,
|
||||
}) async {
|
||||
state = const AsyncValue.loading();
|
||||
|
||||
final api = ref.read(apiServiceProvider);
|
||||
if (api == null) {
|
||||
if (!ref.mounted) return null;
|
||||
state = AsyncValue.error(
|
||||
Exception('API service not available'),
|
||||
StackTrace.current,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Map<String, dynamic>? data;
|
||||
if (markdownContent != null ||
|
||||
htmlContent != null ||
|
||||
jsonContent != null) {
|
||||
data = <String, dynamic>{
|
||||
'content': <String, dynamic>{
|
||||
'json': jsonContent,
|
||||
'html': htmlContent ?? '',
|
||||
'md': markdownContent ?? '',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
final json = await api.updateNote(id, title: title, data: data);
|
||||
|
||||
if (!ref.mounted) return null;
|
||||
|
||||
final note = Note.fromJson(json);
|
||||
|
||||
// Update in the notes list
|
||||
ref.read(notesListProvider.notifier).updateNote(note);
|
||||
|
||||
state = AsyncValue.data(note);
|
||||
return note;
|
||||
} catch (e, st) {
|
||||
if (!ref.mounted) return null;
|
||||
state = AsyncValue.error(e, st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for deleting a note.
|
||||
@Riverpod(keepAlive: true)
|
||||
class NoteDeleter extends _$NoteDeleter {
|
||||
@override
|
||||
AsyncValue<bool> build() => const AsyncValue.data(false);
|
||||
|
||||
/// Delete a note by ID.
|
||||
Future<bool> deleteNote(String id) async {
|
||||
state = const AsyncValue.loading();
|
||||
|
||||
final api = ref.read(apiServiceProvider);
|
||||
if (api == null) {
|
||||
if (!ref.mounted) return false;
|
||||
state = AsyncValue.error(
|
||||
Exception('API service not available'),
|
||||
StackTrace.current,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final success = await api.deleteNote(id);
|
||||
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
if (success) {
|
||||
// Remove from the notes list
|
||||
ref.read(notesListProvider.notifier).removeNote(id);
|
||||
}
|
||||
|
||||
state = AsyncValue.data(success);
|
||||
return success;
|
||||
} catch (e, st) {
|
||||
if (!ref.mounted) return false;
|
||||
state = AsyncValue.error(e, st);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for the currently active/selected note.
|
||||
@riverpod
|
||||
class ActiveNote extends _$ActiveNote {
|
||||
@override
|
||||
Note? build() => null;
|
||||
|
||||
void set(Note? note) => state = note;
|
||||
|
||||
void clear() => state = null;
|
||||
}
|
||||
1042
lib/features/notes/views/note_editor_page.dart
Normal file
1042
lib/features/notes/views/note_editor_page.dart
Normal file
File diff suppressed because it is too large
Load Diff
858
lib/features/notes/views/notes_list_page.dart
Normal file
858
lib/features/notes/views/notes_list_page.dart
Normal file
@@ -0,0 +1,858 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:conduit/l10n/app_localizations.dart';
|
||||
import '../../../core/models/note.dart';
|
||||
import '../../../core/providers/app_providers.dart';
|
||||
import '../../../core/services/navigation_service.dart';
|
||||
import '../../../core/widgets/error_boundary.dart';
|
||||
import '../../../shared/theme/theme_extensions.dart';
|
||||
import '../../../shared/utils/ui_utils.dart';
|
||||
import '../../../shared/widgets/improved_loading_states.dart';
|
||||
import '../../../shared/widgets/themed_dialogs.dart';
|
||||
import '../../../shared/widgets/middle_ellipsis_text.dart';
|
||||
import '../../../shared/utils/conversation_context_menu.dart';
|
||||
import '../providers/notes_providers.dart';
|
||||
|
||||
/// Page displaying the list of all notes with search and time grouping.
|
||||
class NotesListPage extends ConsumerStatefulWidget {
|
||||
const NotesListPage({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<NotesListPage> createState() => _NotesListPageState();
|
||||
}
|
||||
|
||||
class _NotesListPageState extends ConsumerState<NotesListPage> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final FocusNode _searchFocusNode = FocusNode(debugLabel: 'notes_search');
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
Timer? _debounce;
|
||||
String _query = '';
|
||||
|
||||
// Section expansion state
|
||||
final Map<TimeRange, bool> _expandedSections = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Default all sections to expanded
|
||||
for (final range in TimeRange.values) {
|
||||
_expandedSections[range] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_debounce?.cancel();
|
||||
_searchController.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onSearchChanged() {
|
||||
_debounce?.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 250), () {
|
||||
if (!mounted) return;
|
||||
setState(() => _query = _searchController.text.trim());
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _refreshNotes() async {
|
||||
HapticFeedback.lightImpact();
|
||||
await ref.read(notesListProvider.notifier).refresh();
|
||||
}
|
||||
|
||||
Future<void> _createNewNote() async {
|
||||
HapticFeedback.lightImpact();
|
||||
|
||||
final dateFormat = DateFormat('yyyy-MM-dd');
|
||||
final defaultTitle = dateFormat.format(DateTime.now());
|
||||
|
||||
final note = await ref
|
||||
.read(noteCreatorProvider.notifier)
|
||||
.createNote(title: defaultTitle);
|
||||
|
||||
if (note != null && mounted) {
|
||||
context.pushNamed(RouteNames.noteEditor, pathParameters: {'id': note.id});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _deleteNote(Note note) async {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
final confirmed = await ThemedDialogs.confirm(
|
||||
context,
|
||||
title: l10n.deleteNoteTitle,
|
||||
message: l10n.deleteNoteMessage(
|
||||
note.title.isEmpty ? l10n.untitled : note.title,
|
||||
),
|
||||
confirmText: l10n.delete,
|
||||
isDestructive: true,
|
||||
);
|
||||
|
||||
if (confirmed && mounted) {
|
||||
HapticFeedback.mediumImpact();
|
||||
await ref.read(noteDeleterProvider.notifier).deleteNote(note.id);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
|
||||
// Check if notes feature is enabled - redirect to chat if disabled
|
||||
final notesEnabled = ref.watch(notesFeatureEnabledProvider);
|
||||
if (!notesEnabled) {
|
||||
// Redirect back to chat on next frame
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.go('/chat');
|
||||
}
|
||||
});
|
||||
// Show empty scaffold while redirecting
|
||||
return Scaffold(backgroundColor: sidebarTheme.background);
|
||||
}
|
||||
|
||||
return ErrorBoundary(
|
||||
child: Scaffold(
|
||||
backgroundColor: sidebarTheme.background,
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
_buildSearchField(context),
|
||||
Expanded(child: _buildBody(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: _buildFAB(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final canPop = ModalRoute.of(context)?.canPop ?? false;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
canPop ? Spacing.xs : Spacing.inputPadding,
|
||||
Spacing.md,
|
||||
Spacing.inputPadding,
|
||||
Spacing.sm,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (canPop) ...[
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
UiUtils.platformIcon(
|
||||
ios: CupertinoIcons.back,
|
||||
android: Icons.arrow_back,
|
||||
),
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).maybePop(),
|
||||
tooltip: l10n.back,
|
||||
),
|
||||
const SizedBox(width: Spacing.xs),
|
||||
],
|
||||
Icon(
|
||||
Platform.isIOS ? CupertinoIcons.doc_text_fill : Icons.notes_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.7),
|
||||
size: IconSize.lg,
|
||||
),
|
||||
const SizedBox(width: Spacing.sm),
|
||||
Expanded(
|
||||
child: Text(
|
||||
l10n.notes,
|
||||
style: AppTypography.headlineSmallStyle.copyWith(
|
||||
color: sidebarTheme.foreground,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchField(BuildContext context) {
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
Spacing.inputPadding,
|
||||
Spacing.xs,
|
||||
Spacing.inputPadding,
|
||||
Spacing.sm,
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
focusNode: _searchFocusNode,
|
||||
onChanged: (_) => _onSearchChanged(),
|
||||
style: AppTypography.standard.copyWith(
|
||||
color: sidebarTheme.foreground,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: l10n.searchNotes,
|
||||
hintStyle: AppTypography.standard.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Platform.isIOS ? CupertinoIcons.search : Icons.search_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.6),
|
||||
size: IconSize.input,
|
||||
),
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
minWidth: TouchTarget.minimum,
|
||||
minHeight: TouchTarget.minimum,
|
||||
),
|
||||
suffixIcon: _query.isNotEmpty
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
setState(() => _query = '');
|
||||
_searchFocusNode.unfocus();
|
||||
},
|
||||
icon: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.clear_circled_solid
|
||||
: Icons.clear_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.6),
|
||||
size: IconSize.input,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
suffixIconConstraints: const BoxConstraints(
|
||||
minWidth: TouchTarget.minimum,
|
||||
minHeight: TouchTarget.minimum,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: sidebarTheme.accent.withValues(alpha: 0.85),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
||||
borderSide: BorderSide(
|
||||
color: sidebarTheme.border.withValues(alpha: 0.2),
|
||||
width: BorderWidth.thin,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
||||
borderSide: BorderSide(
|
||||
color: sidebarTheme.ring.withValues(alpha: 0.5),
|
||||
width: BorderWidth.regular,
|
||||
),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.md,
|
||||
vertical: Spacing.sm,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context) {
|
||||
final notesAsync = ref.watch(notesListProvider);
|
||||
|
||||
return notesAsync.when(
|
||||
data: (notes) => _buildNotesList(context, notes),
|
||||
loading: () => _buildLoading(context),
|
||||
error: (error, stack) => _buildError(context, error),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNotesList(BuildContext context, List<Note> allNotes) {
|
||||
final notes = _query.isEmpty
|
||||
? allNotes
|
||||
: ref.watch(filteredNotesProvider(_query));
|
||||
|
||||
if (notes.isEmpty) {
|
||||
return _buildEmptyState(context);
|
||||
}
|
||||
|
||||
// Group notes by time range
|
||||
final grouped = <TimeRange, List<Note>>{};
|
||||
for (final note in notes) {
|
||||
final range = getTimeRangeForTimestamp(note.updatedDateTime);
|
||||
grouped.putIfAbsent(range, () => []).add(note);
|
||||
}
|
||||
|
||||
// Build slivers
|
||||
final slivers = <Widget>[];
|
||||
|
||||
for (final range in TimeRange.values) {
|
||||
final rangeNotes = grouped[range];
|
||||
if (rangeNotes != null && rangeNotes.isNotEmpty) {
|
||||
// Section header
|
||||
slivers.add(
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: Spacing.md),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: _buildSectionHeader(context, range, rangeNotes.length),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Notes in section
|
||||
if (_expandedSections[range] ?? true) {
|
||||
slivers.add(
|
||||
const SliverToBoxAdapter(child: SizedBox(height: Spacing.xs)),
|
||||
);
|
||||
slivers.add(
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: Spacing.sm),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) =>
|
||||
_buildNoteCard(context, rangeNotes[index]),
|
||||
childCount: rangeNotes.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
slivers.add(
|
||||
const SliverToBoxAdapter(child: SizedBox(height: Spacing.md)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add bottom padding for FAB
|
||||
slivers.add(const SliverToBoxAdapter(child: SizedBox(height: 80)));
|
||||
|
||||
return _buildRefreshableScrollView(slivers);
|
||||
}
|
||||
|
||||
Widget _buildRefreshableScrollView(List<Widget> slivers) {
|
||||
if (Platform.isIOS) {
|
||||
return CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
CupertinoSliverRefreshControl(onRefresh: _refreshNotes),
|
||||
...slivers,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: _refreshNotes,
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: slivers,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(BuildContext context, TimeRange range, int count) {
|
||||
final theme = context.conduitTheme;
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final isExpanded = _expandedSections[range] ?? true;
|
||||
|
||||
String label;
|
||||
switch (range) {
|
||||
case TimeRange.today:
|
||||
label = l10n.today;
|
||||
case TimeRange.yesterday:
|
||||
label = l10n.yesterday;
|
||||
case TimeRange.previousSevenDays:
|
||||
label = l10n.previous7Days;
|
||||
case TimeRange.previousThirtyDays:
|
||||
label = l10n.previous30Days;
|
||||
case TimeRange.older:
|
||||
label = l10n.older;
|
||||
}
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
HapticFeedback.selectionClick();
|
||||
setState(() => _expandedSections[range] = !isExpanded);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.sm),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: Spacing.sm,
|
||||
horizontal: Spacing.xs,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
AnimatedRotation(
|
||||
turns: isExpanded ? 0.25 : 0,
|
||||
duration: AnimationDuration.fast,
|
||||
curve: Curves.easeOutCubic,
|
||||
child: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.chevron_right
|
||||
: Icons.chevron_right_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
size: IconSize.sm,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Spacing.xs),
|
||||
Text(
|
||||
label,
|
||||
style: AppTypography.labelStyle.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Spacing.sm),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.buttonPrimary.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.pill),
|
||||
),
|
||||
child: Text(
|
||||
'$count',
|
||||
style: AppTypography.tiny.copyWith(
|
||||
color: theme.buttonPrimary.withValues(alpha: 0.9),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNoteCard(BuildContext context, Note note) {
|
||||
final theme = context.conduitTheme;
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
final timeFormat = DateFormat.jm();
|
||||
final dateFormat = DateFormat.MMMd();
|
||||
final isToday = _isToday(note.updatedDateTime);
|
||||
final timeText = isToday
|
||||
? timeFormat.format(note.updatedDateTime)
|
||||
: dateFormat.format(note.updatedDateTime);
|
||||
|
||||
final title = note.title.isEmpty ? l10n.untitled : note.title;
|
||||
final preview = note.markdownContent.replaceAll('\n', ' ').trim();
|
||||
final hasContent = preview.isNotEmpty;
|
||||
|
||||
Color? overlayForStates(Set<WidgetState> states) {
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
return theme.buttonPrimary.withValues(alpha: Alpha.buttonPressed);
|
||||
}
|
||||
if (states.contains(WidgetState.hovered) ||
|
||||
states.contains(WidgetState.focused)) {
|
||||
return theme.buttonPrimary.withValues(alpha: Alpha.hover);
|
||||
}
|
||||
return Colors.transparent;
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: Spacing.sm),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: sidebarTheme.accent.withValues(alpha: 0.5),
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.card),
|
||||
border: Border.all(
|
||||
color: sidebarTheme.border.withValues(alpha: 0.15),
|
||||
width: BorderWidth.thin,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.04),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.02),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.card),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.card),
|
||||
overlayColor: WidgetStateProperty.resolveWith(overlayForStates),
|
||||
onTap: () {
|
||||
HapticFeedback.selectionClick();
|
||||
context.pushNamed(
|
||||
RouteNames.noteEditor,
|
||||
pathParameters: {'id': note.id},
|
||||
);
|
||||
},
|
||||
onLongPress: () => _showNoteContextMenu(context, note),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Spacing.md),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Note icon
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: sidebarTheme.accent,
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.sm),
|
||||
border: Border.all(
|
||||
color: sidebarTheme.border.withValues(alpha: 0.2),
|
||||
width: BorderWidth.thin,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.doc_text_fill
|
||||
: Icons.description_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.6),
|
||||
size: IconSize.md,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Spacing.md),
|
||||
// Content
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Title
|
||||
MiddleEllipsisText(
|
||||
title,
|
||||
style: AppTypography.bodyMediumStyle.copyWith(
|
||||
color: sidebarTheme.foreground,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
if (hasContent) ...[
|
||||
const SizedBox(height: Spacing.xxs),
|
||||
Text(
|
||||
preview,
|
||||
style: AppTypography.bodySmallStyle.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.6),
|
||||
height: 1.4,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: Spacing.sm),
|
||||
// Metadata row
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.clock
|
||||
: Icons.schedule_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.4),
|
||||
size: 12,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
timeText,
|
||||
style: AppTypography.tiny.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
if (note.user != null && note.user!.name != null) ...[
|
||||
const SizedBox(width: Spacing.sm),
|
||||
Text(
|
||||
'·',
|
||||
style: AppTypography.tiny.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.3),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Spacing.sm),
|
||||
Flexible(
|
||||
child: Text(
|
||||
note.user!.name!,
|
||||
style: AppTypography.tiny.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// More button
|
||||
Builder(
|
||||
builder: (buttonContext) => IconButton(
|
||||
icon: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.ellipsis
|
||||
: Icons.more_vert_rounded,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
size: IconSize.md,
|
||||
),
|
||||
visualDensity: VisualDensity.compact,
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: TouchTarget.badge,
|
||||
minHeight: TouchTarget.badge,
|
||||
),
|
||||
onPressed: () => _showNoteContextMenu(buttonContext, note),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _isToday(DateTime date) {
|
||||
final now = DateTime.now();
|
||||
return date.year == now.year &&
|
||||
date.month == now.month &&
|
||||
date.day == now.day;
|
||||
}
|
||||
|
||||
void _showNoteContextMenu(BuildContext context, Note note) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
showConduitContextMenu(
|
||||
context: context,
|
||||
actions: [
|
||||
ConduitContextMenuAction(
|
||||
cupertinoIcon: CupertinoIcons.pencil,
|
||||
materialIcon: Icons.edit_rounded,
|
||||
label: l10n.edit,
|
||||
onBeforeClose: () => HapticFeedback.selectionClick(),
|
||||
onSelected: () async {
|
||||
context.pushNamed(
|
||||
RouteNames.noteEditor,
|
||||
pathParameters: {'id': note.id},
|
||||
);
|
||||
},
|
||||
),
|
||||
ConduitContextMenuAction(
|
||||
cupertinoIcon: CupertinoIcons.doc_on_clipboard,
|
||||
materialIcon: Icons.copy_rounded,
|
||||
label: l10n.copy,
|
||||
onBeforeClose: () => HapticFeedback.selectionClick(),
|
||||
onSelected: () async {
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
await Clipboard.setData(ClipboardData(text: note.markdownContent));
|
||||
if (!mounted) return;
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(l10n.noteCopiedToClipboard),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ConduitContextMenuAction(
|
||||
cupertinoIcon: CupertinoIcons.delete,
|
||||
materialIcon: Icons.delete_rounded,
|
||||
label: l10n.delete,
|
||||
destructive: true,
|
||||
onBeforeClose: () => HapticFeedback.mediumImpact(),
|
||||
onSelected: () async => _deleteNote(note),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState(BuildContext context) {
|
||||
final theme = context.conduitTheme;
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final isSearchActive = _query.isNotEmpty;
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Spacing.xxl),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 72,
|
||||
height: 72,
|
||||
decoration: BoxDecoration(
|
||||
color: sidebarTheme.accent.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.lg),
|
||||
),
|
||||
child: Icon(
|
||||
isSearchActive
|
||||
? (Platform.isIOS
|
||||
? CupertinoIcons.search
|
||||
: Icons.search_off_rounded)
|
||||
: (Platform.isIOS
|
||||
? CupertinoIcons.doc_text
|
||||
: Icons.note_add_rounded),
|
||||
size: 32,
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.4),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
Text(
|
||||
isSearchActive ? l10n.noNotesFound : l10n.noNotesYet,
|
||||
style: AppTypography.bodyLargeStyle.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: Spacing.xs),
|
||||
Text(
|
||||
isSearchActive
|
||||
? l10n.tryDifferentSearch
|
||||
: l10n.createFirstNoteHint,
|
||||
style: AppTypography.bodySmallStyle.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.5),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (!isSearchActive) ...[
|
||||
const SizedBox(height: Spacing.lg),
|
||||
FilledButton.icon(
|
||||
onPressed: _createNewNote,
|
||||
icon: Icon(
|
||||
Platform.isIOS ? CupertinoIcons.add : Icons.add_rounded,
|
||||
),
|
||||
label: Text(l10n.createNote),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: theme.buttonPrimary,
|
||||
foregroundColor: theme.buttonPrimaryText,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.lg,
|
||||
vertical: Spacing.md,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.button),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoading(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Center(child: ImprovedLoadingState(message: l10n.loadingNotes));
|
||||
}
|
||||
|
||||
Widget _buildError(BuildContext context, Object error) {
|
||||
final theme = context.conduitTheme;
|
||||
final sidebarTheme = context.sidebarTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(Spacing.xxl),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
color: sidebarTheme.accent.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.lg),
|
||||
),
|
||||
child: Icon(
|
||||
Platform.isIOS
|
||||
? CupertinoIcons.exclamationmark_triangle
|
||||
: Icons.error_outline_rounded,
|
||||
size: 32,
|
||||
color: theme.error,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Spacing.md),
|
||||
Text(
|
||||
l10n.failedToLoadNotes,
|
||||
style: AppTypography.bodyMediumStyle.copyWith(
|
||||
color: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: Spacing.lg),
|
||||
OutlinedButton.icon(
|
||||
onPressed: _refreshNotes,
|
||||
icon: Icon(
|
||||
Platform.isIOS ? CupertinoIcons.refresh : Icons.refresh_rounded,
|
||||
),
|
||||
label: Text(l10n.retry),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: sidebarTheme.foreground.withValues(alpha: 0.8),
|
||||
side: BorderSide(
|
||||
color: sidebarTheme.border.withValues(alpha: 0.5),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.button),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFAB(BuildContext context) {
|
||||
final theme = context.conduitTheme;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: theme.buttonPrimary.withValues(alpha: 0.35),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
BoxShadow(
|
||||
color: theme.buttonPrimary.withValues(alpha: 0.2),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: FloatingActionButton(
|
||||
onPressed: _createNewNote,
|
||||
backgroundColor: theme.buttonPrimary,
|
||||
foregroundColor: theme.buttonPrimaryText,
|
||||
elevation: 0,
|
||||
highlightElevation: 2,
|
||||
tooltip: l10n.createNote,
|
||||
child: Icon(Platform.isIOS ? CupertinoIcons.add : Icons.add_rounded),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1586,5 +1586,205 @@
|
||||
"transportModeWsInfo": "Lower overhead, but may fail behind strict proxies/firewalls.",
|
||||
"@transportModeWsInfo": {
|
||||
"description": "Footnote text for the WebSocket-only transport mode."
|
||||
},
|
||||
"notes": "Notes",
|
||||
"@notes": {
|
||||
"description": "Navigation item and page title for notes feature."
|
||||
},
|
||||
"searchNotes": "Search notes...",
|
||||
"@searchNotes": {
|
||||
"description": "Placeholder text for notes search field."
|
||||
},
|
||||
"createNote": "Create Note",
|
||||
"@createNote": {
|
||||
"description": "Tooltip/button label for creating a new note."
|
||||
},
|
||||
"noNotesYet": "No notes yet",
|
||||
"@noNotesYet": {
|
||||
"description": "Empty state title when user has no notes."
|
||||
},
|
||||
"noNotesFound": "No notes found",
|
||||
"@noNotesFound": {
|
||||
"description": "Empty state title when search returns no results."
|
||||
},
|
||||
"createFirstNoteHint": "Tap the + button to create your first note.",
|
||||
"@createFirstNoteHint": {
|
||||
"description": "Hint text encouraging user to create their first note."
|
||||
},
|
||||
"tryDifferentSearch": "Try a different search term.",
|
||||
"@tryDifferentSearch": {
|
||||
"description": "Hint text when note search returns no results."
|
||||
},
|
||||
"loadingNotes": "Loading notes...",
|
||||
"@loadingNotes": {
|
||||
"description": "Progress message while fetching notes list."
|
||||
},
|
||||
"loadingNote": "Loading note...",
|
||||
"@loadingNote": {
|
||||
"description": "Progress message while fetching a single note."
|
||||
},
|
||||
"failedToLoadNotes": "Failed to load notes",
|
||||
"@failedToLoadNotes": {
|
||||
"description": "Error message when notes list cannot be retrieved."
|
||||
},
|
||||
"deleteNoteTitle": "Delete Note",
|
||||
"@deleteNoteTitle": {
|
||||
"description": "Dialog title for confirming note deletion."
|
||||
},
|
||||
"deleteNoteMessage": "Delete \"{title}\"? This cannot be undone.",
|
||||
"@deleteNoteMessage": {
|
||||
"description": "Confirmation message for deleting a note.",
|
||||
"placeholders": {
|
||||
"title": {
|
||||
"type": "String",
|
||||
"example": "My Note"
|
||||
}
|
||||
}
|
||||
},
|
||||
"noteTitle": "Note title",
|
||||
"@noteTitle": {
|
||||
"description": "Hint text for note title input field."
|
||||
},
|
||||
"writeNote": "Write something...",
|
||||
"@writeNote": {
|
||||
"description": "Hint text for note content input field."
|
||||
},
|
||||
"noteSaved": "Note saved",
|
||||
"@noteSaved": {
|
||||
"description": "Confirmation message when note is saved."
|
||||
},
|
||||
"saving": "Saving...",
|
||||
"@saving": {
|
||||
"description": "Status text while saving."
|
||||
},
|
||||
"saved": "Saved",
|
||||
"@saved": {
|
||||
"description": "Status text when content is saved."
|
||||
},
|
||||
"unsavedChanges": "Unsaved changes",
|
||||
"@unsavedChanges": {
|
||||
"description": "Status text when there are unsaved changes."
|
||||
},
|
||||
"noteCopiedToClipboard": "Note copied to clipboard",
|
||||
"@noteCopiedToClipboard": {
|
||||
"description": "Confirmation message when note content is copied to clipboard."
|
||||
},
|
||||
"generateTitle": "Generate Title",
|
||||
"@generateTitle": {
|
||||
"description": "Tooltip for generating a title with AI."
|
||||
},
|
||||
"generatingTitle": "Generating title...",
|
||||
"@generatingTitle": {
|
||||
"description": "Placeholder while AI generates a title."
|
||||
},
|
||||
"noContentToGenerateTitle": "Add some content first to generate a title",
|
||||
"@noContentToGenerateTitle": {
|
||||
"description": "Error when trying to generate title with empty content."
|
||||
},
|
||||
"failedToGenerateTitle": "Failed to generate title",
|
||||
"@failedToGenerateTitle": {
|
||||
"description": "Error message when title generation fails."
|
||||
},
|
||||
"noContentToEnhance": "Add some content first to enhance",
|
||||
"@noContentToEnhance": {
|
||||
"description": "Error when trying to enhance empty content."
|
||||
},
|
||||
"noteEnhanced": "Note enhanced with AI",
|
||||
"@noteEnhanced": {
|
||||
"description": "Success message after AI enhancement."
|
||||
},
|
||||
"failedToEnhanceNote": "Failed to enhance note",
|
||||
"@failedToEnhanceNote": {
|
||||
"description": "Error message when enhancement fails."
|
||||
},
|
||||
"noModelSelected": "Please select a model first",
|
||||
"@noModelSelected": {
|
||||
"description": "Error message when no AI model is selected."
|
||||
},
|
||||
"enhanceWithAI": "Enhance with AI",
|
||||
"@enhanceWithAI": {
|
||||
"description": "Tooltip for AI enhance button."
|
||||
},
|
||||
"enhanceNote": "Enhance Note",
|
||||
"@enhanceNote": {
|
||||
"description": "Menu item to enhance note content."
|
||||
},
|
||||
"startDictation": "Start dictation",
|
||||
"@startDictation": {
|
||||
"description": "Tooltip for dictation button."
|
||||
},
|
||||
"stopRecording": "Stop recording",
|
||||
"@stopRecording": {
|
||||
"description": "Tooltip for stop recording button."
|
||||
},
|
||||
"voiceInputUnavailable": "Voice input is not available",
|
||||
"@voiceInputUnavailable": {
|
||||
"description": "Error when voice input is not available."
|
||||
},
|
||||
"failedToStartDictation": "Failed to start dictation",
|
||||
"@failedToStartDictation": {
|
||||
"description": "Error when starting dictation fails."
|
||||
},
|
||||
"noteNotFound": "Note not found",
|
||||
"@noteNotFound": {
|
||||
"description": "Error message when a note cannot be found."
|
||||
},
|
||||
"untitled": "Untitled",
|
||||
"@untitled": {
|
||||
"description": "Default title for notes without a title."
|
||||
},
|
||||
"today": "Today",
|
||||
"@today": {
|
||||
"description": "Time range label for items from today."
|
||||
},
|
||||
"yesterday": "Yesterday",
|
||||
"@yesterday": {
|
||||
"description": "Time range label for items from yesterday."
|
||||
},
|
||||
"previous7Days": "Previous 7 Days",
|
||||
"@previous7Days": {
|
||||
"description": "Time range label for items from the last week."
|
||||
},
|
||||
"previous30Days": "Previous 30 Days",
|
||||
"@previous30Days": {
|
||||
"description": "Time range label for items from the last month."
|
||||
},
|
||||
"older": "Older",
|
||||
"@older": {
|
||||
"description": "Time range label for items older than 30 days."
|
||||
},
|
||||
"tapToExpand": "Tap to expand",
|
||||
"@tapToExpand": {
|
||||
"description": "Hint text shown on collapsed sections."
|
||||
},
|
||||
"byAuthor": "By {name}",
|
||||
"@byAuthor": {
|
||||
"description": "Attribution text showing the note author.",
|
||||
"placeholders": {
|
||||
"name": {
|
||||
"type": "String",
|
||||
"example": "John"
|
||||
}
|
||||
}
|
||||
},
|
||||
"wordCount": "{count} words",
|
||||
"@wordCount": {
|
||||
"description": "Status bar text showing word count.",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int",
|
||||
"example": "150"
|
||||
}
|
||||
}
|
||||
},
|
||||
"charCount": "{count} characters",
|
||||
"@charCount": {
|
||||
"description": "Status bar text showing character count.",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int",
|
||||
"example": "500"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user