Skip to content

Commit

Permalink
feat: Conversation action sheet (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsivin committed Apr 7, 2023
1 parent b5a5699 commit f55f770
Show file tree
Hide file tree
Showing 31 changed files with 790 additions and 388 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Expand Up @@ -140,8 +140,8 @@ android {
applicationId "com.chatwoot.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5137
versionName "1.8.20"
versionCode 5140
versionName "1.8.23"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

multiDexEnabled true
Expand Down
8 changes: 4 additions & 4 deletions ios/Chatwoot.xcodeproj/project.pbxproj
Expand Up @@ -567,7 +567,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Chatwoot/Chatwoot.entitlements;
CURRENT_PROJECT_VERSION = 269;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = L7YLMN4634;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Chatwoot/Info.plist;
Expand All @@ -580,7 +580,7 @@
"$(SDKROOT)/usr/lib/swift",
"$(inherited)",
);
MARKETING_VERSION = 1.8.20;
MARKETING_VERSION = 1.8.23;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -605,7 +605,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Chatwoot/Chatwoot.entitlements;
CURRENT_PROJECT_VERSION = 269;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = L7YLMN4634;
INFOPLIST_FILE = Chatwoot/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Chatwoot;
Expand All @@ -617,7 +617,7 @@
"$(SDKROOT)/usr/lib/swift",
"$(inherited)",
);
MARKETING_VERSION = 1.8.20;
MARKETING_VERSION = 1.8.23;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@chatwoot/mobile-app",
"version": "1.8.20",
"version": "1.8.23",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Expand Up @@ -48,7 +48,7 @@ const Chatwoot = () => {
return (
<GestureHandlerRootView style={styles.container}>
<React.Fragment>
<StatusBar barStyle="dark-content" />
<StatusBar barStyle="dark-content" backgroundColor="white" />
<IconRegistry icons={EvaIconsPack} />
<ApplicationProvider {...eva} theme={theme}>
<Provider store={store}>
Expand Down
8 changes: 6 additions & 2 deletions src/components/BottomSheet/BottomSheet.js
Expand Up @@ -12,6 +12,7 @@ const BottomSheetModal = ({
children,
headerTitle,
closeFilter,
showHeader,
initialSnapPoints,
bottomSheetModalRef,
onDismiss,
Expand All @@ -27,7 +28,7 @@ const BottomSheetModal = ({
pressBehavior={'close'}
opacity={0.6}
disappearsOnIndex={-1}
appearsOnIndex={1}
appearsOnIndex={0}
/>
),
[],
Expand All @@ -46,7 +47,9 @@ const BottomSheetModal = ({
android_keyboardInputMode="adjustResize"
enablePanDownToClose
onDismiss={onDismiss}>
<BottomSheetModalHeader title={headerTitle} closeModal={closeFilter} colors={colors} />
{showHeader && (
<BottomSheetModalHeader title={headerTitle} closeModal={closeFilter} colors={colors} />
)}
<BottomSheetScrollView>{children}</BottomSheetScrollView>
</BottomSheetModalLibrary>
);
Expand All @@ -55,6 +58,7 @@ const BottomSheetModal = ({
BottomSheetModal.propTypes = {
children: PropTypes.element.isRequired,
bottomSheetModalRef: PropTypes.object.isRequired,
showHeader: PropTypes.bool,
onDismiss: PropTypes.func,
initialSnapPoints: PropTypes.array,
closeFilter: PropTypes.func,
Expand Down
9 changes: 6 additions & 3 deletions src/components/BottomSheet/BottomSheetHeader.js
Expand Up @@ -7,11 +7,14 @@ import { Text, Icon, Pressable } from 'components';
import { StyleSheet } from 'react-native';

const createStyles = theme => {
const { spacing, borderRadius } = theme;
const { spacing, colors, borderRadius } = theme;
return StyleSheet.create({
headerContainer: {
paddingVertical: spacing.small,
paddingBottom: spacing.small,
paddingTop: spacing.micro,
paddingHorizontal: spacing.small,
borderBottomColor: colors.border,
borderBottomWidth: 0.4,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
Expand Down Expand Up @@ -40,7 +43,7 @@ const BottomSheetModalHeader = ({ title, closeModal, colors }) => {

return (
<View style={styles.headerContainer}>
<Text lg bold color={colors.textDark} style={styles.headerTitle}>
<Text md bold color={colors.textDark} style={styles.headerTitle}>
{title}
</Text>
<Pressable
Expand Down
143 changes: 74 additions & 69 deletions src/components/ConversationActionItem.js
@@ -1,100 +1,105 @@
import React from 'react';
import { TouchableOpacity, View } from 'react-native';
import React, { useMemo } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTheme } from '@react-navigation/native';
import PropTypes from 'prop-types';
import { Divider, Icon, withStyles } from '@ui-kitten/components';
import { Text, Icon, Pressable, UserAvatar } from 'components';
import i18n from 'i18n';

import CustomText from './Text';
import UserAvatar from './UserAvatar';

const styles = theme => ({
section: {
justifyContent: 'space-between',
alignItems: 'center',
flexDirection: 'row',
padding: 16,
height: 54,
},
sectionTitleView: {
flex: 8,
},
sectionText: {
fontSize: theme['font-size-small'],
fontWeight: theme['font-medium'],
paddingLeft: 8,
},
sectionActionView: {
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'flex-end',
flex: 4,
},
sectionDivider: {
backgroundColor: theme['item-border-color'],
marginHorizontal: 18,
},
});
const createStyles = theme => {
const { spacing, borderRadius } = theme;
return StyleSheet.create({
bottomSheetItem: {
flexDirection: 'row',
paddingVertical: spacing.half,
paddingHorizontal: spacing.small,
borderBottomWidth: 0.4,
height: 48,
borderRadius: borderRadius.small,
alignItems: 'center',
justifyContent: 'space-between',
},
sectionTitleView: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
},
sectionTitle: {
marginLeft: spacing.smaller,
marginRight: spacing.half,
},
sectionActiveTitle: {
marginLeft: spacing.micro,
marginRight: spacing.smaller,
},
sectionActionView: {
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'flex-end',
flex: 4,
},
});
};

const propTypes = {
eva: PropTypes.shape({
style: PropTypes.object,
theme: PropTypes.object,
}).isRequired,
name: PropTypes.string,
thumbnail: PropTypes.string,
iconName: PropTypes.string,
text: PropTypes.string,
checked: PropTypes.bool,
iconSize: PropTypes.string,
itemType: PropTypes.string,
onPressItem: PropTypes.func,
availabilityStatus: PropTypes.string,
colors: PropTypes.object,
};

const ConversationActionItem = ({
text,
checked,
iconSize,
iconName,
itemType,
name,
thumbnail,
onPressItem,
availabilityStatus,
eva: { style, theme },
colors,
}) => {
const isActive = availabilityStatus === 'online' ? true : false;
const theme = useTheme();
const styles = useMemo(() => createStyles(theme), [theme]);

const shouldShowUserAvatar = itemType === 'assignee' && name !== i18n.t('AGENT.TITLE');

return (
<React.Fragment>
<TouchableOpacity style={style.section} onPress={() => onPressItem({ itemType })}>
<View style={style.sectionTitleView}>
<CustomText style={style.sectionText}>{text}</CustomText>
<Pressable
key={text}
style={[
{
borderBottomColor: colors.borderLight,
},
styles.bottomSheetItem,
]}
onPress={() => {
onPressItem({ itemType });
}}>
<View style={styles.sectionTitleView}>
<Icon icon={iconName} color={colors.textDark} size={16} />
<Text sm medium color={colors.textDark} style={styles.sectionTitle}>
{text}
</Text>
</View>
<View style={style.sectionActionView}>
{itemType === 'assignee' && thumbnail !== '' && (
<UserAvatar
thumbnail={thumbnail}
userName={name}
defaultBGColor={theme['color-primary-default']}
isActive={isActive}
size={28}
fontSize={theme['font-size-extra-small']}
availabilityStatus={availabilityStatus}
/>
<View style={styles.sectionActionView}>
{shouldShowUserAvatar && (
<UserAvatar thumbnail={thumbnail} userName={name} size={18} fontSize={8} />
)}
<CustomText style={style.sectionText}>{name}</CustomText>
{(itemType === 'assignee' || itemType === 'team') && (
<Icon
name="arrow-ios-forward-outline"
fill={theme['color-primary-default']}
width={26}
height={26}
/>
<Text sm medium color={colors.textLight} style={styles.sectionActiveTitle}>
{name}
</Text>
{(itemType === 'assignee' || itemType === 'team' || itemType === 'snooze') && (
<Icon icon="arrow-chevron-right-outline" color={colors.text} size={16} />
)}
</View>
</TouchableOpacity>
<Divider style={style.sectionDivider} />
</Pressable>
</React.Fragment>
);
};

ConversationActionItem.propTypes = propTypes;

export default withStyles(ConversationActionItem, styles);
export default ConversationActionItem;

0 comments on commit f55f770

Please sign in to comment.