completed and tested the keycommand

This commit is contained in:
Reinaldo Neto 2022-08-01 22:43:27 -03:00
parent d00dd897cf
commit b195b3ea07
1 changed files with 7 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Dimensions, Linking, unstable_batchedUpdates } from 'react-native'; import { Dimensions, Linking, unstable_batchedUpdates } from 'react-native';
import { AppearanceProvider } from 'react-native-appearance'; import { AppearanceProvider } from 'react-native-appearance';
import { KeyCommandsEmitter } from 'react-native-keycommands'; import { KeyCommandsEmitter } from 'react-native-keycommands';
@ -104,10 +104,7 @@ const Root = () => {
} }
}); });
}, 5000); }, 5000);
Dimensions.addEventListener('change', val => { Dimensions.addEventListener('change', onDimensionsChange);
onDimensionsChange(val);
console.log('🚀 ~ file: index.tsx ~ line 109 ~ Dimensions.addEventListener ~ val', val);
});
return () => { return () => {
clearTimeout(listenerTimeout.current); clearTimeout(listenerTimeout.current);
@ -157,12 +154,6 @@ const Root = () => {
// Dimensions update fires twice // Dimensions update fires twice
const onDimensionsChange = debounce(({ window: { width, height, scale, fontScale } }: { window: IDimensions }) => { const onDimensionsChange = debounce(({ window: { width, height, scale, fontScale } }: { window: IDimensions }) => {
console.log('🚀 ~ file: index.tsx ~ line 160 ~ onDimensionsChange ~ { width, height, scale, fontScale }', {
width,
height,
scale,
fontScale
});
setDimensions({ setDimensions({
width, width,
height, height,
@ -195,23 +186,21 @@ const Root = () => {
}); });
}; };
const initTablet = () => { const initTablet = useCallback(() => {
setMasterDetail(width); setMasterDetail(widthWindow);
onKeyCommands.current = KeyCommandsEmitter.addListener('onKeyCommand', (command: ICommand) => { onKeyCommands.current = KeyCommandsEmitter.addListener('onKeyCommand', (command: ICommand) => {
EventEmitter.emit(KEY_COMMAND, { event: command }); EventEmitter.emit(KEY_COMMAND, { event: command });
}); });
}; }, []);
const initCrashReport = () => { const initCrashReport = useCallback(() => {
getAllowCrashReport().then(allowCrashReport => { getAllowCrashReport().then(allowCrashReport => {
toggleCrashErrorsReport(allowCrashReport); toggleCrashErrorsReport(allowCrashReport);
}); });
getAllowAnalyticsEvents().then(allowAnalyticsEvents => { getAllowAnalyticsEvents().then(allowAnalyticsEvents => {
toggleAnalyticsEventsReport(allowAnalyticsEvents); toggleAnalyticsEventsReport(allowAnalyticsEvents);
}); });
}; }, []);
console.count('🤯 App/index');
return ( return (
<SafeAreaProvider initialMetrics={initialWindowMetrics} style={{ backgroundColor: themes[theme].backgroundColor }}> <SafeAreaProvider initialMetrics={initialWindowMetrics} style={{ backgroundColor: themes[theme].backgroundColor }}>