This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { View, StyleSheet, Text } from 'react-native'; | |
| import moment from 'moment'; | |
| import { gql } from '@apollo/client'; | |
| import * as Types from '../../graphql/generated'; | |
| export const TIME_FORMAT = 'HH:mm'; | |
| export const MessageItemFragment = gql` | |
| fragment MessageItem on Message { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from 'react'; | |
| import UUID from 'uuid-random'; | |
| import { useMessagesQuery, MessageSubscription as MessageSubscriptionType, useSendMessageMutation, MessageSendInput, SendMessageMutation, MessagesQuery } from '../generated'; | |
| import { MessageSubscription, GetMessagesQuery } from '../queries/Messages'; | |
| export const useMessages = ({ sender_id }: { sender_id: string }) => { | |
| const [isStopFetchMore, setStopFetchMore] = React.useState(false); | |
| const { data, fetchMore: fetchMoreMessages, loading, subscribeToMore, ...other } = useMessagesQuery({ | |
| fetchPolicy: 'cache-and-network', | |
| variables: { offset: 0 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { View } from 'react-native'; | |
| import { AuthNavProps } from '../navigation/types/AuthStackParams'; | |
| import { Input } from '../components/Input'; | |
| import { Button } from '../components/Button'; | |
| import { AuthContext } from '../contexts/AuthContext'; | |
| export const LoginScreen = ({}: AuthNavProps<'Login'>) => { | |
| const [name, setName] = React.useState(''); | |
| const { login } = React.useContext(AuthContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { gql } from '@apollo/client'; | |
| import { MessageItemFragment } from '../../components/Items/MessageItem'; | |
| export const GetMessagesQuery = gql` | |
| query Messages($offset: Int!) { | |
| messages(offset: $offset, limit: 20) { | |
| ...MessageItem | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { View } from 'react-native'; | |
| import { gql } from '@apollo/client'; | |
| export const MessageItemFragment = gql` | |
| fragment MessageItem on Message { | |
| _id | |
| sender_id | |
| senderName | |
| text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from "react"; | |
| import { ViewStyle, StyleSheet, TextInputProps, View, TextInput } from "react-native"; | |
| interface InputProps extends TextInputProps { | |
| noWrapper?: boolean; | |
| containerStyle?: ViewStyle; | |
| } | |
| export const Input = (props: InputProps) => { | |
| const { noWrapper, containerStyle, ...other } = props; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from 'react'; | |
| import { AppLoading } from 'expo'; | |
| import { ApolloProvider } from '@apollo/client'; | |
| import { client } from './graphql/client'; | |
| import { Routes } from './navigation/Routes'; | |
| import { AuthProvider, getUserFromStorage } from './contexts/AuthContext'; | |
| const App = ({ skipLoadingScreen }: { skipLoadingScreen: boolean }) => { | |
| const [isLoadingComplete, setLoadingComplete] = React.useState(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { NavigationContainer } from '@react-navigation/native'; | |
| import { AuthContext, getUserFromStorage } from '../contexts/AuthContext'; | |
| import { MainStackScreens } from './MainStack'; | |
| import { AuthStackScreens } from './AuthStack'; | |
| export const Routes: React.FC = () => { | |
| const [loading, setLoading] = React.useState(true); | |
| const { setUser, user } = React.useContext(AuthContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { AsyncStorage } from 'react-native'; | |
| import UUID from 'uuid-random'; | |
| import { useApolloClient } from '@apollo/client'; | |
| type User = { | |
| _id: string; | |
| name: string; | |
| } |