@livelike/react-native
Version:
LiveLike React Native package
43 lines • 1.18 kB
JavaScript
import React, { useCallback } from 'react';
import { Image, StyleSheet, TouchableOpacity } from 'react-native';
import { useStyles, useTheme } from '../../hooks';
import { LLThemeType } from '../../types';
export function LLThemeSwitch(_ref) {
let {
switchIcon,
styles: stylesProp
} = _ref;
const {
themeAssets,
setThemeType,
themeType
} = useTheme();
const themeSwitchStyles = useStyles({
componentStylesFn: getChatHeaderStyles,
stylesProp
});
const toggleTheme = useCallback(() => {
const newTheme = themeType === LLThemeType.DARK ? LLThemeType.LIGHT : LLThemeType.DARK;
setThemeType(newTheme);
}, [themeType, setThemeType]);
return /*#__PURE__*/React.createElement(TouchableOpacity, {
style: themeSwitchStyles.imageContainer,
onPress: toggleTheme
}, /*#__PURE__*/React.createElement(Image, {
style: themeSwitchStyles.image,
source: switchIcon || themeAssets.themeSwitch
}));
}
const getChatHeaderStyles = _ref2 => {
let {
theme
} = _ref2;
return StyleSheet.create({
imageContainer: {},
image: {
width: 24,
height: 24
}
});
};
//# sourceMappingURL=LLThemeSwitch.js.map