UNPKG

@qte/react-native-gifted-chat

Version:

Performant fork of react-native-gifted-chat with FlashList support

56 lines 1.53 kB
import * as React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import dayjs from 'dayjs'; import Color from './Color'; import { TIME_FORMAT } from './Constant'; import { useChatContext } from './GiftedChatContext'; const { containerStyle } = StyleSheet.create({ containerStyle: { marginLeft: 10, marginRight: 10, marginBottom: 5, }, }); const { textStyle } = StyleSheet.create({ textStyle: { fontSize: 10, textAlign: 'right', }, }); const styles = { left: StyleSheet.create({ container: { ...containerStyle, }, text: { color: Color.timeTextColor, ...textStyle, }, }), right: StyleSheet.create({ container: { ...containerStyle, }, text: { color: Color.white, ...textStyle, }, }), }; export function Time({ position = 'left', containerStyle, currentMessage, timeFormat = TIME_FORMAT, timeTextStyle, }) { const { getLocale } = useChatContext(); if (currentMessage == null) return null; return (<View style={[ styles[position].container, containerStyle && containerStyle[position], ]}> <Text style={[ styles[position].text, timeTextStyle && timeTextStyle[position], ]}> {dayjs(currentMessage.createdAt).locale(getLocale()).format(timeFormat)} </Text> </View>); } //# sourceMappingURL=Time.js.map