Working auth and added shared notes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user