forked from Ivasoft/mattermost-mobile
* Freeze unfocused tabs * Fix syntax_highlight when multiple code blocks present in the same post * Move @components/channel_list to @screens/home/channels_list/categories_list * Update app/screens/channel/channel.tsx Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com> * Add support for Freeze on Android * Fix render on tablets Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
26 lines
749 B
TypeScript
26 lines
749 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {useEffect, useState} from 'react';
|
|
import {DeviceEventEmitter} from 'react-native';
|
|
|
|
import {Events} from '@constants';
|
|
|
|
const useFreeze = () => {
|
|
const [freeze, setFreeze] = useState(false);
|
|
const [backgroundColor, setBackgroundColor] = useState('#000');
|
|
|
|
useEffect(() => {
|
|
const freezeListener = DeviceEventEmitter.addListener(Events.FREEZE_SCREEN, (shouldFreeze: boolean, color = '#000') => {
|
|
setFreeze(shouldFreeze);
|
|
setBackgroundColor(color);
|
|
});
|
|
|
|
return () => freezeListener.remove();
|
|
});
|
|
|
|
return {freeze, backgroundColor};
|
|
};
|
|
|
|
export default useFreeze;
|