fn read_config(
        style_key: &str,
        base_key: &str,
        config: &ThemeConfig,
        styles: &mut HashMap<String, Style>,
    ) {
        if style_key.is_empty() {
            return;
        }

        if !styles.contains_key(style_key) {
            styles.insert(style_key.to_string(), Style::new());
        }

        // start from topmost base
        if let Some(style) = config.styles.get(base_key) {
            if !style.base.is_empty() && style.base != *style_key {
                Theme::read_config(style_key, &style.base, config, styles);
            }
        }

        if let Some(style_config) = config.styles.get(base_key) {
            if let Some(style) = styles.get_mut(style_key) {
                // reads the properties
                for (property_key, property_value) in &style_config.properties {
                    style.properties.insert(
                        property_key.clone(),
                        Theme::read_value(property_value, &config.resources),
                    );
                }

                // reads the states
                for state in &style_config.states {
                    let mut new_state = ThemeState::new(state.key.clone());

                    for (property_key, property_value) in &state.properties {
                        new_state.properties.insert(
                            property_key.clone(),
                            Theme::read_value(property_value, &config.resources),
                        );
                    }

                    // a state with the same name on a lower base style or the indented style overrides the state of a higher base
                    if let Some(pos) = style.states.iter().position(|s| s.key == new_state.key) {
                        style.states.remove(pos);
                        style.states.insert(pos, new_state)
                    } else {
                        style.states.push(new_state);
                    }
                }
            }
        }
    }
// reads the given config and copy it's data in the given styles map
reads the given config and copy it's data in the given styles map
reads the given config and copy it ' s data in the given styles map
fn read_config(
        style_key: &str,
        base_key: &str,
        config: &ThemeConfig,
        styles: &mut HashMap<String, Style>,
    ) {
        if style_key.is_empty() {
            return;
        }
        if !styles.contains_key(style_key) {
            styles.insert(style_key.to_string(), Style::new());
        }
        // start from topmost base
        if let Some(style) = config.styles.get(base_key) {
            if !style.base.is_empty() && style.base != *style_key {
                Theme::read_config(style_key, &style.base, config, styles);
            }
        }
        if let Some(style_config) = config.styles.get(base_key) {
            if let Some(style) = styles.get_mut(style_key) {
                // reads the properties
                for (property_key, property_value) in &style_config.properties {
                    style.properties.insert(
                        property_key.clone(),
                        Theme::read_value(property_value, &config.resources),
                    );
                }
                // reads the states
                for state in &style_config.states {
                    let mut new_state = ThemeState::new(state.key.clone());
                    for (property_key, property_value) in &state.properties {
                        new_state.properties.insert(
                            property_key.clone(),
                            Theme::read_value(property_value, &config.resources),
                        );
                    }
                    // a state with the same name on a lower base style or the indented style overrides the state of a higher base
                    if let Some(pos) = style.states.iter().position(|s| s.key == new_state.key) {
                        style.states.remove(pos);
                        style.states.insert(pos, new_state)
                    } else {
                        style.states.push(new_state);
                    }
                }
            }
        }
    }
fn read_config ( style_key : & str , base_key : & str , config : & ThemeConfig , styles : & mut HashMap < String , Style > , ) { if style_key . is_empty ( ) { return ; } if ! styles . contains_key ( style_key ) { styles . insert ( style_key . to_string ( ) , Style :: new ( ) ) ; } // start from topmost base if let Some ( style ) = config . styles . get ( base_key ) { if ! style . base . is_empty ( ) && style . base != * style_key { Theme :: read_config ( style_key , & style . base , config , styles ) ; } } if let Some ( style_config ) = config . styles . get ( base_key ) { if let Some ( style ) = styles . get_mut ( style_key ) { // reads the properties for ( property_key , property_value ) in & style_config . properties { style . properties . insert ( property_key . clone ( ) , Theme :: read_value ( property_value , & config . resources ) , ) ; } // reads the states for state in & style_config . states { let mut new_state = ThemeState :: new ( state . key . clone ( ) ) ; for ( property_key , property_value ) in & state . properties { new_state . properties . insert ( property_key . clone ( ) , Theme :: read_value ( property_value , & config . resources ) , ) ; } // a state with the same name on a lower base style or the indented style overrides the state of a higher base if let Some ( pos ) = style . states . iter ( ) . position ( | s | s . key == new_state . key ) { style . states . remove ( pos ) ; style . states . insert ( pos , new_state ) } else { style . states . push ( new_state ) ; } } } } }
reads the given config and copy it's data in the given styles map
reads the given config and copy it ' s data in the given styles map
style_key
&str
base_key
&str
config
&ThemeConfig
styles
&mut HashMap<String, Style>