Skip to content

Commit

Permalink
improve login page and added contextual message to signup
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalkishor1991 committed Mar 18, 2024
1 parent 463eadd commit 7fa1110
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 25 deletions.
47 changes: 47 additions & 0 deletions components/GoogleButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { TouchableOpacity, Text, StyleSheet, View } from 'react-native';
import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/FontAwesome';

const GoogleButton = ({ buttonType, onPress }) => {
const buttonText = buttonType === 'signin' ? 'Sign In with Google' : 'Sign Up with Google';

return (
<TouchableOpacity style={styles.button} onPress={onPress}>
<View style={styles.iconAndText}>
<Icon name="google" size={20} color="#FFFFFF" style={styles.icon} />
<Text style={styles.buttonText}>{buttonText}</Text>
</View>
</TouchableOpacity>
);
};

GoogleButton.propTypes = {
buttonType: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired
};

const styles = StyleSheet.create({
button: {
backgroundColor: '#4285F4',
paddingVertical: 12,
paddingHorizontal: 16,
borderRadius: 4,
alignItems: 'center',
justifyContent: 'center'
},
buttonText: {
color: '#FFFFFF',
fontSize: 16,
fontWeight: 'bold'
},
iconAndText: {
flexDirection: 'row',
alignItems: 'center'
},
icon: {
marginRight: 10
}
});

export default GoogleButton;
4 changes: 2 additions & 2 deletions components/GridActionButton.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ const GridActionButtonAndroid = ({ navigation, setPickImageLoading }) => {
{
icon: (
<Image
style={{ height: 30, width: 30 }}
style={{ height: 20, width: 20 }}
// eslint-disable-next-line no-undef
source={require('../assets/images/icon.png')}></Image>
),
text1: t('Create using'),
text2: t(' AI'),
text2: t('HueHive AI'),
onPress: async () => {
logEvent('chat_session_action_button');
navigation.navigate('ChatSession');
Expand Down
1 change: 0 additions & 1 deletion components/GridActionButton.ios.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { NativeModules } from 'react-native';
import Color from 'pigment/full';
import RNColorThief from 'react-native-color-thief';
import { notifyMessage } from '../libs/Helpers';
Expand Down
9 changes: 6 additions & 3 deletions screens/ChatSessionScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import {
import React, { useState, useEffect, useRef } from 'react';
import { material } from 'react-native-typography';
import { logEvent } from '../libs/Helpers';
import { useTranslation } from 'react-i18next';
import { createChatSession, followUpChatSession, getChatSession } from '../network/chat_session';
import ChatCard from '../components/ChatCard';
import LoginScreen from './LoginScreen';
import useUserData from '../Hooks/getUserData';

const ChatSessionScreen = (props) => {
const { navigation } = props;
const { t } = useTranslation();
const [messages, setMessages] = useState([]);
const [inputText, setInputText] = useState('');
const scrollViewRef = useRef();
Expand Down Expand Up @@ -79,7 +77,12 @@ const ChatSessionScreen = (props) => {
}

if (!userData) {
return <LoginScreen {...props} reloadScreen={getUserData}></LoginScreen>;
return (
<LoginScreen
{...props}
signupMessage="Please sign in or sign up to use HueHive AI"
reloadScreen={getUserData}></LoginScreen>
);
}

return (
Expand Down
27 changes: 8 additions & 19 deletions screens/LoginScreen.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react';
import {
ScrollView,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
Image,
Dimensions
} from 'react-native';
import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, Image } from 'react-native';
import { View } from 'react-native-animatable';
import CromaButton from '../components/CromaButton';
import { material } from 'react-native-typography';
Expand All @@ -21,8 +13,9 @@ import {
removeUserSession
} from '../libs/EncryptedStoreage';
import Notification from '../components/Notification';
import GoogleButton from '../components/GoogleButton';

import { GoogleSignin, GoogleSigninButton } from '@react-native-google-signin/google-signin';
import { GoogleSignin } from '@react-native-google-signin/google-signin';

const LOGIN = 'LOGIN';
const SIGN_UP = 'SIGN_UP';
Expand Down Expand Up @@ -236,7 +229,9 @@ function LoginScreen(props) {
{props.reloadScreen === undefined && (
<Text style={styles.title}>{t('Welcome to HueHive (Croma),')}</Text>
)}
<Text style={styles.intro}>{t('Please Singin/Signup to continue...')}</Text>
<Text style={styles.intro}>
{props.signupMessage || t('Please Singin/Signup to continue...')}
</Text>
{error && <Notification message={error} onPress={() => setError(undefined)}></Notification>}
{screenType === SIGN_UP && (
<>
Expand Down Expand Up @@ -293,14 +288,8 @@ function LoginScreen(props) {
onPress={onSubmit}>
{t(LOGIN_AND_SIGNUP_TEXT[screenType].buttonText)}
</CromaButton>

<GoogleSigninButton
style={{
width: Dimensions.get('window').width * (95 / 100),
height: 60
}}
size={GoogleSigninButton.Size.Wide}
color={GoogleSigninButton.Color.Dark}
<GoogleButton
buttonType={screenType == 'LOGIN' ? 'signin' : 'signup'}
onPress={googleSignIn}
/>
</View>
Expand Down

0 comments on commit 7fa1110

Please sign in to comment.