feat(privacy): add personalized ads toggle in settings
- Add PrivacySettings schema with can_sell field (default: false) - Move privacy toggle to GeneralSettingsScreen with clear labeling - Update l10n for zh/en/zh_hant with user-friendly copy - Clean up redundant PrivacyNotificationSettingsScreen - Update profile-protocol.md to reflect new privacy schema - Fix basedpyright warnings in user.py
This commit is contained in:
@@ -46,7 +46,10 @@ class ProfileApi {
|
||||
'timezone': settings.preferences.timezone,
|
||||
'country': settings.preferences.country,
|
||||
},
|
||||
'privacy': settings.privacy,
|
||||
'privacy': {
|
||||
'can_sell': settings.privacy.canSell,
|
||||
'profile_visibility': settings.privacy.profileVisibility,
|
||||
},
|
||||
'notification': {
|
||||
'allow_notifications': settings.notification.allowNotifications,
|
||||
'allow_vibration': settings.notification.allowVibration,
|
||||
@@ -115,6 +118,17 @@ class ProfileApi {
|
||||
)
|
||||
: const PreferenceSettings();
|
||||
|
||||
final privacyRaw = settingsRaw is Map<String, dynamic>
|
||||
? settingsRaw['privacy']
|
||||
: null;
|
||||
final privacy = privacyRaw is Map<String, dynamic>
|
||||
? PrivacySettings(
|
||||
canSell: (privacyRaw['can_sell'] as bool?) ?? false,
|
||||
profileVisibility:
|
||||
(privacyRaw['profile_visibility'] as String?) ?? 'public',
|
||||
)
|
||||
: const PrivacySettings();
|
||||
|
||||
final notificationRaw = settingsRaw is Map<String, dynamic>
|
||||
? settingsRaw['notification']
|
||||
: null;
|
||||
@@ -150,10 +164,7 @@ class ProfileApi {
|
||||
avatarPath: json['avatar_path'] as String?,
|
||||
avatarUrl: json['avatar_url'] as String?,
|
||||
preferences: preferences,
|
||||
privacy: settingsRaw is Map<String, dynamic>
|
||||
? (settingsRaw['privacy'] as Map<String, dynamic>? ??
|
||||
const <String, dynamic>{})
|
||||
: const <String, dynamic>{},
|
||||
privacy: privacy,
|
||||
notification: notification,
|
||||
divinationTutorial: divinationTutorial,
|
||||
);
|
||||
|
||||
@@ -84,6 +84,23 @@ class DivinationTutorialSettings {
|
||||
}
|
||||
}
|
||||
|
||||
class PrivacySettings {
|
||||
const PrivacySettings({
|
||||
this.canSell = false,
|
||||
this.profileVisibility = 'public',
|
||||
});
|
||||
|
||||
final bool canSell;
|
||||
final String profileVisibility;
|
||||
|
||||
PrivacySettings copyWith({bool? canSell, String? profileVisibility}) {
|
||||
return PrivacySettings(
|
||||
canSell: canSell ?? this.canSell,
|
||||
profileVisibility: profileVisibility ?? this.profileVisibility,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileSettingsV1 {
|
||||
const ProfileSettingsV1({
|
||||
this.version = 1,
|
||||
@@ -92,7 +109,7 @@ class ProfileSettingsV1 {
|
||||
this.avatarPath,
|
||||
this.avatarUrl,
|
||||
this.preferences = const PreferenceSettings(),
|
||||
this.privacy = const <String, Object?>{},
|
||||
this.privacy = const PrivacySettings(),
|
||||
this.notification = const NotificationSettings(),
|
||||
this.divinationTutorial = const DivinationTutorialSettings(),
|
||||
});
|
||||
@@ -103,7 +120,7 @@ class ProfileSettingsV1 {
|
||||
final String? avatarPath;
|
||||
final String? avatarUrl;
|
||||
final PreferenceSettings preferences;
|
||||
final Map<String, Object?> privacy;
|
||||
final PrivacySettings privacy;
|
||||
final NotificationSettings notification;
|
||||
final DivinationTutorialSettings divinationTutorial;
|
||||
|
||||
@@ -114,7 +131,7 @@ class ProfileSettingsV1 {
|
||||
String? avatarPath,
|
||||
String? avatarUrl,
|
||||
PreferenceSettings? preferences,
|
||||
Map<String, Object?>? privacy,
|
||||
PrivacySettings? privacy,
|
||||
NotificationSettings? notification,
|
||||
DivinationTutorialSettings? divinationTutorial,
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user