From 05daad941e1d9aed6d31f56d007c202556a1b207 Mon Sep 17 00:00:00 2001 From: Kamal Joshi Date: Wed, 20 Mar 2024 23:05:50 +0530 Subject: [PATCH] add action button into chat list screen --- screens/ChatSessionHistoriesScreen.js | 77 ++++++++++++++++++--------- screens/PaletteLibraryScreen.js | 3 +- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/screens/ChatSessionHistoriesScreen.js b/screens/ChatSessionHistoriesScreen.js index 4d35ac6e..e4cf275a 100644 --- a/screens/ChatSessionHistoriesScreen.js +++ b/screens/ChatSessionHistoriesScreen.js @@ -12,6 +12,8 @@ import { logEvent } from '../libs/Helpers'; import { getChatSessions } from '../network/chat_session'; import { useNavigation } from '@react-navigation/native'; import moment from 'moment'; +import ActionButton from 'react-native-action-button'; +import Colors from '../constants/Colors'; const ChatSessionHistoriesScreen = () => { logEvent('chat_session_histories_screen'); @@ -30,36 +32,53 @@ const ChatSessionHistoriesScreen = () => { fetchChatSessions(); }, []); - return ( - - {loading ? ( - - ) : ( - <> - {chatSessions.map((session, index) => ( - navigation.navigate('ChatSession', { messages: session.messages })} - key={index} - style={styles.card}> - - - - {session.messages.length > 0 ? session.messages[0].message : 'Untitled'} - - - - {moment(session.updated_at).format('MMMM D, YYYY')} + <> + + {loading ? ( + + ) : ( + <> + {chatSessions.length === 0 && ( + + No chat sessions yet. Start a new one by clicking the + button. + + )} + {chatSessions.map((session, index) => ( + navigation.navigate('ChatSession', { messages: session.messages })} + key={index} + style={styles.card}> + + + + {session.messages.length > 0 ? session.messages[0].message : 'Untitled'} - {session.messages.length} messages + + + {moment(session.updated_at).format('MMMM D, YYYY')} + + {session.messages.length} messages + - - - ))} - - )} - + + ))} + + )} + + { + logEvent('add_chat_session_fab'); + navigation.navigate('ChatSession'); + }} + style={styles.actionButton} + /> + ); }; @@ -121,6 +140,12 @@ const styles = StyleSheet.create({ ...material.body1, fontSize: 16, color: '#888' + }, + actionButton: {}, + noChatSessionMessage: { + ...material.headline, + textAlign: 'center', + marginTop: 100 } }); diff --git a/screens/PaletteLibraryScreen.js b/screens/PaletteLibraryScreen.js index 0c63cc75..333bd7e5 100644 --- a/screens/PaletteLibraryScreen.js +++ b/screens/PaletteLibraryScreen.js @@ -22,8 +22,7 @@ export default function PaletteLibraryScreen({ navigation }) { logEvent('hm_matrial_palettes'); setCommonPalettes(palettes); navigation.navigate('CommonPalettes'); - }} - > + }}> {palettes.name}