Working auth and added shared notes

This commit is contained in:
Nathan Anderson
2023-07-27 01:40:26 -06:00
parent 18aad2b3d5
commit 83393807c7
68 changed files with 2138 additions and 661 deletions
+26 -4
View File
@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:ui';
import 'package:json_annotation/json_annotation.dart';
@@ -8,27 +9,32 @@ part 'shared_note.g.dart';
@JsonSerializable()
class SharedNote {
const SharedNote({
SharedNote({
this.id,
required this.familyId,
required this.createdByUserId,
required this.content,
required this.title,
this.color,
this.createdAt,
this.updatedAt,
required this.tagIds,
this.isMarkdown = false,
this.hide = false,
});
final int? id;
final int familyId, createdByUserId;
final String content;
String content, title;
@JsonKey(fromJson: _tagIdsFromJson, toJson: _tagIdsToJson)
List<int> tagIds;
@JsonKey(fromJson: optionalColorFromJson, toJson: optionalColorToJson)
final Color? color;
Color? color;
@JsonKey(fromJson: boolFromJson, toJson: boolToJson)
final bool isMarkdown;
bool isMarkdown;
@JsonKey(fromJson: boolFromJson, toJson: boolToJson)
final bool hide;
@@ -43,4 +49,20 @@ class SharedNote {
_$SharedNoteFromJson(json);
Map<String, dynamic> toJson() => _$SharedNoteToJson(this);
factory SharedNote.copy(SharedNote note) =>
SharedNote.fromJson(note.toJson());
}
List<int> _tagIdsFromJson(String tagJson) {
final tagsMap = jsonDecode(tagJson) as List<dynamic>;
return tagsMap
.map(
(e) => int.parse(e),
)
.toList();
}
String _tagIdsToJson(List<int> tagIds) {
return jsonEncode(tagIds);
}