mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Disable walking when an inputfield is focused (#234)
* feat(phone) Disable walking when an input is focused * refactor(phone) renamed var & replaced copy paste code Instead of copying the code it now uses a custom hook * refactor(phone/input): removed useMemo from hook * style(phone/input): changed indentation to spaces & added de-structured import
This commit is contained in:
1 parent
0e1d7f40b5
commit
870aeda3c3
16 files changed
+88
-13
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import React, { useState } from 'react';
|
||||
import Modal from '../../../../ui/components/Modal';
|
||||
import { Button, List, ListItem, TextField, makeStyles } from '@material-ui/core';
|
||||
import { Button, List, ListItem, makeStyles } from '@material-ui/core';
|
||||
import { useBankModal } from '../../hooks/useBankModal';
|
||||
import { BankEvents } from '../../../../../../typings/bank';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Avatar as MuiAvatar, Box, Button, Paper, TextField } from '@material-ui/core';
|
||||
import { Avatar as MuiAvatar, Box, Button, Paper } from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory, useParams } from 'react-router-dom';
|
||||
@@ -9,6 +9,7 @@ import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { ContactEvents } from '../../../../../../typings/contact';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
interface ContactInfoRouteParams {
|
||||
mode: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
|
||||
import { Box, IconButton, Paper } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
@@ -8,6 +8,7 @@ import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { InputBase } from '../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { makeStyles, Button, TextField, Box } from '@material-ui/core';
|
||||
import { makeStyles, Button, Box } from '@material-ui/core';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
|
||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||
@@ -9,6 +9,7 @@ import { useHistory, useLocation } from 'react-router-dom';
|
||||
import qs from 'qs';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { deleteQueryFromLocation } from '../../../../common/utils/deleteQueryFromLocation';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React, { FormEvent, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Paper, Box, makeStyles, TextField, Button } from '@material-ui/core';
|
||||
import { Paper, Box, makeStyles, Button } from '@material-ui/core';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
import ImageIcon from '@material-ui/icons/Image';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
interface IProps {
|
||||
onAddImageClick(): void;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, Button, TextField } from '@material-ui/core';
|
||||
import { Box, Button } from '@material-ui/core';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
@@ -9,6 +9,7 @@ import { Contact } from '../../../../../../typings/contact';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
import { PHONE_NUMBER_REGEX } from '../../../../../../typings/phone';
|
||||
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const Nui = useNuiRequest();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
Button,
|
||||
TextField,
|
||||
Slide,
|
||||
Paper,
|
||||
Typography,
|
||||
@@ -16,6 +15,7 @@ import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||
import { NotesEvents } from '../../../../../typings/notes';
|
||||
import { TextField } from '../../../ui/components/Input';
|
||||
|
||||
export const NoteModal = () => {
|
||||
const Nui = useNuiRequest();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import DialogForm from '../../../ui/components/DialogForm';
|
||||
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
import { TextField } from '../../../ui/components/Input';
|
||||
|
||||
export default function WallpaperModal() {
|
||||
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import TweetList from './tweet/TweetList';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import SearchButton from './buttons/SearchButton';
|
||||
import { useFilteredTweets } from '../hooks/useFilteredTweets';
|
||||
import { TwitterEvents } from '../../../../../typings/twitter';
|
||||
import { TextField } from '../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { memo, useCallback, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
textField: {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React, { memo, useEffect, useCallback, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import { getNewLineCount } from '../../utils/message';
|
||||
import { TextField } from '../../../../ui/components/Input';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
textField: {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import MUITextField from '@material-ui/core/TextField';
|
||||
import MUIInputBase from '@material-ui/core/InputBase';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { PhoneEvents } from '../../../../typings/phone';
|
||||
|
||||
const useToggleFocus = () => {
|
||||
const Nui = useNuiRequest();
|
||||
return useCallback(
|
||||
(keepGameFocus: boolean) => {
|
||||
Nui.send(PhoneEvents.TOGGLE_KEYS, {
|
||||
keepGameFocus,
|
||||
});
|
||||
},
|
||||
[Nui],
|
||||
);
|
||||
};
|
||||
|
||||
export const TextField = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUITextField
|
||||
{...props}
|
||||
onFocus={(e) => {
|
||||
toggleKeys(false);
|
||||
if (props.onFocus) {
|
||||
props.onFocus(e);
|
||||
}
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
toggleKeys(true);
|
||||
if (props.onBlur) {
|
||||
props.onBlur(e);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const InputBase = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUIInputBase
|
||||
{...props}
|
||||
onFocus={(e) => {
|
||||
toggleKeys(false);
|
||||
if (props.onFocus) {
|
||||
props.onFocus(e);
|
||||
}
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
toggleKeys(true);
|
||||
if (props.onBlur) {
|
||||
props.onBlur(e);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { TextField } from './Input';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
formContainer: {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { emphasize, InputBase, makeStyles, Paper } from '@material-ui/core';
|
||||
import { emphasize, makeStyles, Paper } from '@material-ui/core';
|
||||
import SearchIcon from '@material-ui/icons/Search';
|
||||
import { InputBase } from './Input';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
bg: {
|
||||
|
||||
@@ -180,6 +180,14 @@ on(`__cfx_nui:${PhoneEvents.CLOSE_PHONE}`, async (data: any, cb: Function) => {
|
||||
cb();
|
||||
}); // Called for when the phone is closed via the UI.
|
||||
|
||||
RegisterNuiCallbackType(PhoneEvents.TOGGLE_KEYS);
|
||||
on(`__cfx_nui:${PhoneEvents.TOGGLE_KEYS}`, async (data: any, cb: Function) => {
|
||||
if (isPhoneOpen) {
|
||||
SetNuiFocusKeepInput(data.keepGameFocus);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
||||
// setTick(async () => {
|
||||
// while (config.SwimDestroy) {
|
||||
// await Delay(config.RunRate * 1000);
|
||||
|
||||
@@ -20,6 +20,7 @@ export enum PhoneEvents {
|
||||
SET_TIME = 'npwd:setGameTime',
|
||||
SEND_CREDENTIALS = 'npwd:sendCredentials',
|
||||
ON_INIT = 'npwd:onInit',
|
||||
TOGGLE_KEYS = 'npwd:toggleAllControls',
|
||||
}
|
||||
|
||||
// Used to standardize the server response
|
||||
|
||||
Reference in new issue
Block a user