2022-12-08 14:21:11 +08:00
|
|
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
2022-01-28 10:56:55 +08:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-09-28 11:44:44 +08:00
|
|
|
use std::collections::HashMap;
|
2022-01-28 10:56:55 +08:00
|
|
|
|
|
|
|
#[derive(ProtoBuf, Default, Debug, Clone)]
|
2022-07-19 14:40:56 +08:00
|
|
|
pub struct UserPreferencesPB {
|
2022-01-28 10:56:55 +08:00
|
|
|
#[pb(index = 1)]
|
|
|
|
user_id: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
2022-07-19 14:40:56 +08:00
|
|
|
appearance_setting: AppearanceSettingsPB,
|
2022-01-28 10:56:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]
|
2022-07-19 14:40:56 +08:00
|
|
|
pub struct AppearanceSettingsPB {
|
2022-01-28 10:56:55 +08:00
|
|
|
#[pb(index = 1)]
|
|
|
|
pub theme: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
2022-12-08 14:21:11 +08:00
|
|
|
#[serde(default)]
|
|
|
|
pub theme_mode: ThemeModePB,
|
2022-11-16 14:40:30 +08:00
|
|
|
|
|
|
|
#[pb(index = 3)]
|
2022-12-08 14:21:11 +08:00
|
|
|
pub font: String,
|
2022-11-16 14:40:30 +08:00
|
|
|
|
|
|
|
#[pb(index = 4)]
|
2022-12-08 14:21:11 +08:00
|
|
|
pub monospace_font: String,
|
|
|
|
|
|
|
|
#[pb(index = 5)]
|
2022-02-05 10:27:43 +08:00
|
|
|
#[serde(default)]
|
2022-07-19 14:40:56 +08:00
|
|
|
pub locale: LocaleSettingsPB,
|
2022-02-01 12:15:11 +08:00
|
|
|
|
2022-12-08 14:21:11 +08:00
|
|
|
#[pb(index = 6)]
|
2022-06-27 20:53:47 +08:00
|
|
|
#[serde(default = "DEFAULT_RESET_VALUE")]
|
2022-09-28 11:44:44 +08:00
|
|
|
pub reset_to_default: bool,
|
|
|
|
|
2022-12-08 14:21:11 +08:00
|
|
|
#[pb(index = 7)]
|
2022-09-28 11:44:44 +08:00
|
|
|
#[serde(default)]
|
|
|
|
pub setting_key_value: HashMap<String, String>,
|
2022-02-01 12:15:11 +08:00
|
|
|
}
|
|
|
|
|
2022-06-27 20:53:47 +08:00
|
|
|
const DEFAULT_RESET_VALUE: fn() -> bool = || APPEARANCE_RESET_AS_DEFAULT;
|
|
|
|
|
2022-12-08 14:21:11 +08:00
|
|
|
#[derive(ProtoBuf_Enum, Serialize, Deserialize, Clone, Debug)]
|
|
|
|
pub enum ThemeModePB {
|
|
|
|
Light = 0,
|
|
|
|
Dark = 1,
|
|
|
|
System = 2,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::default::Default for ThemeModePB {
|
|
|
|
fn default() -> Self {
|
|
|
|
ThemeModePB::System
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-04 15:45:06 -05:00
|
|
|
#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]
|
2022-07-19 14:40:56 +08:00
|
|
|
pub struct LocaleSettingsPB {
|
2022-02-04 15:45:06 -05:00
|
|
|
#[pb(index = 1)]
|
|
|
|
pub language_code: String,
|
|
|
|
|
|
|
|
#[pb(index = 2)]
|
|
|
|
pub country_code: String,
|
|
|
|
}
|
|
|
|
|
2022-07-19 14:40:56 +08:00
|
|
|
impl std::default::Default for LocaleSettingsPB {
|
2022-02-04 15:45:06 -05:00
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
language_code: "en".to_owned(),
|
|
|
|
country_code: "".to_owned(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 22:56:20 +08:00
|
|
|
pub const APPEARANCE_DEFAULT_THEME: &str = "light";
|
2022-11-16 14:40:30 +08:00
|
|
|
pub const APPEARANCE_DEFAULT_FONT: &str = "Poppins";
|
|
|
|
pub const APPEARANCE_DEFAULT_MONOSPACE_FONT: &str = "SF Mono";
|
2022-06-27 20:53:47 +08:00
|
|
|
const APPEARANCE_RESET_AS_DEFAULT: bool = true;
|
2022-01-28 10:56:55 +08:00
|
|
|
|
2022-07-19 14:40:56 +08:00
|
|
|
impl std::default::Default for AppearanceSettingsPB {
|
2022-01-28 10:56:55 +08:00
|
|
|
fn default() -> Self {
|
2022-07-19 14:40:56 +08:00
|
|
|
AppearanceSettingsPB {
|
2022-01-28 10:56:55 +08:00
|
|
|
theme: APPEARANCE_DEFAULT_THEME.to_owned(),
|
2022-12-08 14:21:11 +08:00
|
|
|
theme_mode: ThemeModePB::default(),
|
2022-11-16 14:40:30 +08:00
|
|
|
font: APPEARANCE_DEFAULT_FONT.to_owned(),
|
|
|
|
monospace_font: APPEARANCE_DEFAULT_MONOSPACE_FONT.to_owned(),
|
2022-07-19 14:40:56 +08:00
|
|
|
locale: LocaleSettingsPB::default(),
|
2022-09-28 11:44:44 +08:00
|
|
|
reset_to_default: APPEARANCE_RESET_AS_DEFAULT,
|
|
|
|
setting_key_value: HashMap::default(),
|
2022-01-28 10:56:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|