Function stateToTheme