Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move types to dedicated file #168

Merged
merged 8 commits into from
Mar 19, 2024
7 changes: 1 addition & 6 deletions client/src/components/Common/ChatMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import React, { useContext } from "react";
import { View, StyleSheet, Text, Image, Dimensions } from "react-native";
import { useSettings } from "../../contexts/SettingsContext";

interface MessageProps {
messageContent: string;
// timestamp: Date, (This will be added later inside the message object passed in)
author: string;
}
import { MessageProps } from "../../utils/types";

const Message: React.FC<MessageProps> = ({ messageContent, author }) => {
const settings = useSettings();
Expand Down
5 changes: 1 addition & 4 deletions client/src/components/Common/CustomButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React from 'react'
import { View, StyleSheet, Text, TouchableOpacity, Image, Dimensions } from 'react-native'

interface ChatSendButtonProps {
onPress?: () => void,
}
import { ChatSendButtonProps } from '../../utils/types';

export const ChatSendButton: React.FC<ChatSendButtonProps> = ({ onPress }) => {
return (
Expand Down
8 changes: 1 addition & 7 deletions client/src/components/Common/CustomInputs.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React from 'react'
import { TextInput, View, StyleSheet, Dimensions, Platform } from 'react-native'

interface ChatInputProps {
value?: string,
onChangeText?: (text: string) => void
}


import { ChatInputProps } from '../../types/CommonComponentProps';

export const WelcomeEmailInput: React.FC<ChatInputProps> = ({ value, onChangeText }) => {
return (
Expand Down
5 changes: 1 addition & 4 deletions client/src/components/Common/LogInButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { router } from "expo-router";
import React from "react";
import { useFonts } from "expo-font";
import { StyleSheet, Text, TouchableOpacity, Dimensions } from "react-native";
import { LogInButtonProps } from "../../utils/types";

// Interface for props function onPress
interface LogInButtonProps {
onPress?: () => void;
}

const LogInButton: React.FC<LogInButtonProps> = ({ onPress }) => {

Expand Down
5 changes: 1 addition & 4 deletions client/src/components/Common/MessageChannel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import React from 'react'
import Message from './ChatMessage'
import { FlatList, StyleSheet, View } from 'react-native'
import { MessageType } from '../../utils/types';
import { MessageChannelProps } from '../../utils/types';

interface MessageChannelProps {
messages: MessageType[],
}

const MessageChannel: React.FC<MessageChannelProps> = ({ messages }) => {
const reverseMessages = [...messages].reverse()
Expand Down
7 changes: 1 addition & 6 deletions client/src/components/Common/NearbyHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

import { View, Text, StyleSheet, Dimensions, Image } from 'react-native'
import React from 'react'

interface CounterProps {
count: number;
}
import { CounterProps } from '../../utils/types'

export const NearbyHeader: React.FC<CounterProps> = ({ count }) => {
return (
Expand Down Expand Up @@ -35,8 +32,6 @@ export const NearbyHeader: React.FC<CounterProps> = ({ count }) => {
)
}



const styles = StyleSheet.create({
nearbyContainer: {
paddingTop: Dimensions.get('window').height * 0.01,
Expand Down
5 changes: 1 addition & 4 deletions client/src/components/Common/SafeAreaWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from "react";
import { useSettings } from "../../contexts/SettingsContext";
import { SafeAreaView, Platform, StyleSheet, StatusBar } from "react-native";

interface SafeAreaWrapperProps {
children: React.ReactNode;
}
import { SafeAreaWrapperProps } from "../../utils/types";

const SafeAreaWrapper: React.FC<SafeAreaWrapperProps> = ({ children }) => {
const settings = useSettings();
Expand Down
8 changes: 1 addition & 7 deletions client/src/components/Common/SignUpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { router } from "expo-router";
import React from "react";
import { useFonts } from "expo-font";
import { StyleSheet, Text, TouchableOpacity, Dimensions } from "react-native";

// Interface for props function onPress
interface SignUpButtonProps {
onPress?: () => void;
}
import { SignUpButtonProps } from "../../utils/types";

const SignUpButton: React.FC<SignUpButtonProps> = ({ onPress }) => {

Expand All @@ -27,8 +23,6 @@ const SignUpButton: React.FC<SignUpButtonProps> = ({ onPress }) => {
};

const styles = StyleSheet.create({


button: {
backgroundColor: "#5dbea3",
width: Dimensions.get("window").width * 0.5,
Expand Down
39 changes: 38 additions & 1 deletion client/src/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
import React from "react";
aaditkamat marked this conversation as resolved.
Show resolved Hide resolved

export type MessageType = {
aaditkamat marked this conversation as resolved.
Show resolved Hide resolved
messageContent: string;
author: string;
msgID: string;
};
};

export type MessageProps = {
messageContent: string;
// timestamp: Date, (This will be added later inside the message object passed in)
author: string;
}

export type ChatSendButtonProps = {
onPress?: () => void,
}

export type ChatInputProps = {
value?: string,
onChangeText?: (text: string) => void
}

export type LogInButtonProps = {
onPress?: () => void;
}

export type MessageChannelProps = {
messages: MessageType[],
}

export type CounterProps = {
count: number;
}

export type SafeAreaWrapperProps = {
children: React.ReactNode;
}

export type SignUpButtonProps = {
onPress?: () => void;
}