43 lines
1.0 KiB
Rust
Raw Normal View History

2022-01-28 10:56:55 +08:00
use flowy_derive::ProtoBuf;
use serde::{Deserialize, Serialize};
#[derive(ProtoBuf, Default, Debug, Clone)]
pub struct UserPreferences {
#[pb(index = 1)]
user_id: String,
#[pb(index = 2)]
appearance_setting: AppearanceSettings,
}
#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]
pub struct AppearanceSettings {
#[pb(index = 1)]
pub theme: String,
#[pb(index = 2)]
pub language: String,
2022-02-01 12:15:11 +08:00
#[pb(index = 3)]
#[serde(default = "reset_default_value")]
pub reset_as_default: bool,
}
fn reset_default_value() -> bool {
APPEARANCE_RESET_AS_DEFAULT
2022-01-28 10:56:55 +08:00
}
2022-01-29 22:56:20 +08:00
pub const APPEARANCE_DEFAULT_THEME: &str = "light";
2022-01-28 10:56:55 +08:00
pub const APPEARANCE_DEFAULT_LANGUAGE: &str = "en";
2022-02-01 12:15:11 +08:00
pub const APPEARANCE_RESET_AS_DEFAULT: bool = true;
2022-01-28 10:56:55 +08:00
impl std::default::Default for AppearanceSettings {
fn default() -> Self {
AppearanceSettings {
theme: APPEARANCE_DEFAULT_THEME.to_owned(),
language: APPEARANCE_DEFAULT_LANGUAGE.to_owned(),
2022-02-01 12:15:11 +08:00
reset_as_default: APPEARANCE_RESET_AS_DEFAULT,
2022-01-28 10:56:55 +08:00
}
}
}