import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; part 'userdata.g.dart'; @JsonSerializable() class UserData { UserData({ required this.userId, required this.username, required this.displayName, required this.subscriptionPlan, required this.isDemoUser, }); factory UserData.fromJson(Map json) => _$UserDataFromJson(json); final int userId; @JsonKey(defaultValue: false) bool isDemoUser = false; // -- USER PROFILE -- String username; String displayName; String? avatarSvg; String? avatarJson; @JsonKey(defaultValue: 0) int avatarCounter = 0; // --- SUBSCRIPTION DTA --- @JsonKey(defaultValue: 'Preview') String subscriptionPlan; DateTime? lastImageSend; int? todaysImageCounter; // --- SETTINGS --- @JsonKey(defaultValue: ThemeMode.system) ThemeMode themeMode = ThemeMode.system; int? defaultShowTime; @JsonKey(defaultValue: true) bool useHighQuality = true; @JsonKey(defaultValue: true) bool showFeedbackShortcut = true; List? preSelectedEmojies; Map>? autoDownloadOptions; @JsonKey(defaultValue: false) bool storeMediaFilesInGallery = false; List? lastUsedEditorEmojis; String? lastPlanBallance; String? additionalUserInvites; List? tutorialDisplayed; int? myBestFriendContactId; DateTime? signalLastSignedPreKeyUpdated; // -- Custom DATA -- @JsonKey(defaultValue: 100_000) int currentPreKeyIndexStart = 100_000; @JsonKey(defaultValue: 100_000) int currentSignedPreKeyIndexStart = 100_000; List? lastChangeLogHash; @JsonKey(defaultValue: false) bool hideChangeLog = false; // --- BACKUP --- DateTime? nextTimeToShowBackupNotice; BackupServer? backupServer; TwonlySafeBackup? twonlySafeBackup; Map toJson() => _$UserDataToJson(this); } enum LastBackupUploadState { none, pending, failed, success } @JsonSerializable() class TwonlySafeBackup { TwonlySafeBackup({ required this.backupId, required this.encryptionKey, }); factory TwonlySafeBackup.fromJson(Map json) => _$TwonlySafeBackupFromJson(json); int lastBackupSize = 0; LastBackupUploadState backupUploadState = LastBackupUploadState.none; DateTime? lastBackupDone; List backupId; List encryptionKey; Map toJson() => _$TwonlySafeBackupToJson(this); } @JsonSerializable() class BackupServer { BackupServer({ required this.serverUrl, required this.retentionDays, required this.maxBackupBytes, }); factory BackupServer.fromJson(Map json) => _$BackupServerFromJson(json); String serverUrl; int retentionDays; int maxBackupBytes; Map toJson() => _$BackupServerToJson(this); }