use heromodels_core::BaseModelData; use heromodels_derive::model; use rhai::{CustomType, TypeBuilder}; use serde::{Deserialize, Serialize}; /// Represents the visual theme for a circle. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, CustomType, Default)] pub struct ThemeData { pub primary_color: String, pub background_color: String, pub background_pattern: String, pub logo_symbol: String, pub logo_url: String, pub nav_dashboard_visible: bool, pub nav_timeline_visible: bool, } /// Represents an event in a calendar #[model] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, CustomType, Default)] pub struct Circle { /// Base model data pub base_data: BaseModelData, #[index] pub title: String, pub ws_url: String, /// Public key for this circle pub public_key: String, /// Optional description of the circle pub description: Option, /// List of related circles pub circles: Vec, /// List of members in the circle (their public keys) pub members: Vec, /// Logo URL or symbol for the circle pub logo: Option, /// Theme settings for the circle (colors, styling, etc.) pub theme: ThemeData, } impl Circle { /// Creates a new circle pub fn new() -> Self { Self { base_data: BaseModelData::new(), title: String::new(), ws_url: String::new(), public_key: String::new(), description: None, circles: Vec::new(), logo: None, members: Vec::new(), theme: ThemeData::default(), } } /// Sets the title for the circle pub fn title(mut self, title: impl ToString) -> Self { self.title = title.to_string(); self } /// Sets the ws_url for the circle pub fn ws_url(mut self, ws_url: impl ToString) -> Self { self.ws_url = ws_url.to_string(); self } /// Sets the public key for the circle pub fn public_key(mut self, public_key: impl ToString) -> Self { self.public_key = public_key.to_string(); self } /// Sets the description for the circle pub fn description(mut self, description: impl ToString) -> Self { self.description = Some(description.to_string()); self } /// Sets the logo for the circle pub fn logo(mut self, logo: impl ToString) -> Self { self.logo = Some(logo.to_string()); self } /// Sets the entire theme for the circle pub fn theme(mut self, theme: ThemeData) -> Self { self.theme = theme; self } /// Adds a related circle pub fn add_circle(mut self, circle: String) -> Self { // Prevent duplicate circles if !self.circles.iter().any(|a| *a == circle) { self.circles.push(circle); } self } /// Adds a member to the circle pub fn add_member(mut self, member: String) -> Self { // Prevent duplicate members if !self.members.iter().any(|a| *a == member) { self.members.push(member); } self } /// Saves the circle (placeholder for actual save implementation) pub fn save(self) -> Self { // TODO: Implement actual save logic to database println!("Saving circle: {}", self.title); self } } /// Creates a new circle builder pub fn new_circle() -> Circle { Circle::new() }