import 'dart:ui';

import 'package:json_annotation/json_annotation.dart';

import '../global/utils.dart';

part 'shared_note.g.dart';

@JsonSerializable()
class SharedNote {
  const SharedNote({
    this.id,
    required this.familyId,
    required this.createdByUserId,
    required this.content,
    this.color,
    this.createdAt,
    this.updatedAt,
    this.isMarkdown = false,
    this.hide = false,
  });

  final int? id;
  final int familyId, createdByUserId;
  final String content;

  @JsonKey(fromJson: optionalColorFromJson, toJson: optionalColorToJson)
  final Color? color;

  @JsonKey(fromJson: boolFromJson, toJson: boolToJson)
  final bool isMarkdown;

  @JsonKey(fromJson: boolFromJson, toJson: boolToJson)
  final bool hide;

  @JsonKey(fromJson: dateFromJson, toJson: dateToJson)
  final DateTime? createdAt;

  @JsonKey(fromJson: dateFromJson, toJson: dateToJson)
  final DateTime? updatedAt;

  factory SharedNote.fromJson(Map<String, dynamic> json) =>
      _$SharedNoteFromJson(json);

  Map<String, dynamic> toJson() => _$SharedNoteToJson(this);
}