mattermost-mobile/app/utils/theme.js
Matheus Cardoso 73518da91e Make keyboard dark on dark themes (iOS only) (#3102)
* Support keyboardAppearance theme parameter

* Change approach of keyboardAppearance to auto-detect

* Fix style

* Update snapshots

* Add unit test for getKeyboardAppearanceFromTheme

* Update snapshot

* Fix failing test
2019-08-23 13:18:05 -04:00

53 lines
1.5 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {StyleSheet} from 'react-native';
import {Navigation} from 'react-native-navigation';
import tinyColor from 'tinycolor2';
import * as ThemeUtils from 'mattermost-redux/utils/theme_utils';
export function makeStyleSheetFromTheme(getStyleFromTheme) {
return ThemeUtils.makeStyleFromTheme((theme) => {
return StyleSheet.create(getStyleFromTheme(theme));
});
}
export const changeOpacity = ThemeUtils.changeOpacity;
export const blendColors = ThemeUtils.blendColors;
export function concatStyles(...styles) {
return [].concat(styles);
}
export function setNavigatorStyles(componentId, theme) {
Navigation.mergeOptions(componentId, {
topBar: {
title: {
color: theme.sidebarHeaderTextColor,
},
background: {
color: theme.sidebarHeaderBg,
},
leftButtonColor: theme.sidebarHeaderTextColor,
rightButtonColor: theme.sidebarHeaderTextColor,
backButton: {
color: theme.sidebarHeaderTextColor,
},
},
layout: {
backgroundColor: theme.centerChannelBg,
},
});
}
export function isThemeSwitchingEnabled(state) {
const {config} = state.entities.general;
return config.EnableThemeSelection === 'true';
}
export function getKeyboardAppearanceFromTheme(theme) {
return tinyColor(theme.centerChannelBg).isLight() ? 'light' : 'dark';
}