ratatui_toolkit/diff_file_tree/constructors/
with_theme.rs

1//! Builder method for setting the theme.
2
3use crate::diff_file_tree::DiffFileTree;
4use crate::services::theme::AppTheme;
5
6impl DiffFileTree {
7    /// Sets the application theme for styling.
8    ///
9    /// This method applies the theme colors to the file tree widget,
10    /// including selection colors, borders, and text colors.
11    ///
12    /// # Arguments
13    ///
14    /// * `theme` - The application theme to use
15    ///
16    /// # Returns
17    ///
18    /// Self for method chaining
19    ///
20    /// # Example
21    ///
22    /// ```rust
23    /// use ratatui_toolkit::diff_file_tree::DiffFileTree;
24    /// use ratatui_toolkit::services::theme::AppTheme;
25    ///
26    /// let theme = AppTheme::default();
27    /// let tree = DiffFileTree::new().with_theme(&theme);
28    /// ```
29    #[must_use]
30    pub fn with_theme(mut self, theme: &AppTheme) -> Self {
31        self.theme = theme.clone();
32        self
33    }
34
35    /// Applies a theme to the existing widget (non-consuming).
36    ///
37    /// # Arguments
38    ///
39    /// * `theme` - The application theme to apply
40    pub fn apply_theme(&mut self, theme: &AppTheme) {
41        self.theme = theme.clone();
42    }
43}