Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/components/views/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function () {
const dispatch = useDispatch();

// state
const { message, type, autoHide } = useSelector(getToast);
const { message, type, autoHide, keyboardIsOpen } = useSelector(getToast);
const [opacity] = useState(new Animated.Value(0));

// UI
Expand All @@ -41,7 +41,7 @@ export default function () {
<Animated.View
style={{
position: 'absolute',
bottom: Platform.OS === 'android' ? 0 : 4,
bottom: keyboardIsOpen === false ? (Platform.OS === 'android' ? 0 : 4) : (Platform.OS === 'android' ? 328 : 332),
opacity,
width: '100%',
minHeight: 48,
Expand Down
36 changes: 18 additions & 18 deletions common/store/ui/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ export const HIDE_TOAST = 'HIDE_TOAST';
export const BUSY = 'BUSY';

export const showToast =
(message: string, type: ToastType = 'success', autoHide: boolean = true) =>
(dispatch: AppDispatch) => {
dispatch({
type: SHOW_TOAST,
payload: { message: message.replace('Error: ', ''), type, autoHide },
});
};
(message: string, type: ToastType = 'success', autoHide: boolean = true, keyboardIsOpen: boolean = false) =>
(dispatch: AppDispatch) => {
dispatch({
type: SHOW_TOAST,
payload: { message: message.replace('Error: ', ''), type, autoHide, keyboardIsOpen },
});
};

export const hideToast = () => (dispatch: AppDispatch) => {
dispatch({ type: HIDE_TOAST });
};

export const awaitWithFeedback =
<T>(promise: Promise<T>) =>
async (dispatch: AppDispatch) => {
dispatch({ type: BUSY, payload: true });
try {
const result = await promise;
dispatch({ type: BUSY, payload: false });
return result;
} catch (error) {
dispatch({ type: BUSY, payload: false });
throw error;
}
};
async (dispatch: AppDispatch) => {
dispatch({ type: BUSY, payload: true });
try {
const result = await promise;
dispatch({ type: BUSY, payload: false });
return result;
} catch (error) {
dispatch({ type: BUSY, payload: false });
throw error;
}
};
1 change: 1 addition & 0 deletions common/store/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ToastState {
message?: string;
type?: ToastType;
autoHide?: boolean;
keyboardIsOpen?: boolean;
}

export interface UIState {
Expand Down
28 changes: 28 additions & 0 deletions common/utils/keyboardListener.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component } from 'react';
import { Keyboard } from 'react-native';

export var keyboardStatus = "0";

export class KeyboardListener extends Component {

componentWillMount() {
Keyboard.addListener('keyboardDidShow', (e) => {
keyboardStatus = "1";
//alert(e.endCoordinates.height);
});
Keyboard.addListener('keyboardDidHide', () => {
keyboardStatus = "0";
})
}

componentWillUnmount() {
Keyboard.removeAllListeners;
}

render() {
return false;
}
}

export default KeyboardListener;