Skip to content

Commit

Permalink
add support for keyboards
Browse files Browse the repository at this point in the history
reset time when the user opens or closes the keyboard
  • Loading branch information
hassan-alnator authored Apr 14, 2021
1 parent 9c81f21 commit b1d23f8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/IdleTracker.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createElement, useState, useEffect, useRef } from "react";
import { View, PanResponder } from "react-native";
import { View, PanResponder, Keyboard } from "react-native";
import { Alert } from './Alert';

export const IdleTracker = props => {
Expand All @@ -11,11 +11,25 @@ export const IdleTracker = props => {
)

useEffect(() => {
//resetInactivityTimeout();


const keyboardDidShowListener = Keyboard.addListener(
'keyboardDidShow',
() => {
resetInactivityTimeout()
}
);
const keyboardDidHideListener = Keyboard.addListener(
'keyboardDidHide',
() => {
resetInactivityTimeout()
}
);

return () => {
clearTimeout(timerId.current);
clearTimeout(warningTimerid.current);
keyboardDidHideListener.remove();
keyboardDidShowListener.remove();
};

}, []);
Expand Down

0 comments on commit b1d23f8

Please sign in to comment.