From 3a6024fc8282f81845df3643c1a3c7ec38746c71 Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Thu, 22 Apr 2021 18:57:17 -0400
Subject: added mute/unmute

---
 src/components/messages/ChannelPreview.tsx | 41 ++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 10 deletions(-)

(limited to 'src/components/messages/ChannelPreview.tsx')

diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx
index 6b166b55..f2662b6a 100644
--- a/src/components/messages/ChannelPreview.tsx
+++ b/src/components/messages/ChannelPreview.tsx
@@ -41,6 +41,10 @@ const ChannelPreview: React.FC<
   const member = getMember(channel, state);
   const online = isOnline(member?.user?.last_active);
   const unread = channel.state.unreadCount > 0;
+  const isMuted = channel.muteStatus().muted;
+  const mutedImage = isMuted
+    ? require('../../assets/images/unmute.png')
+    : require('../../assets/images/mute.png');
 
   return (
     <Swipeable
@@ -49,15 +53,20 @@ const ChannelPreview: React.FC<
       renderRightActions={() => (
         <View style={styles.swipeableContainer}>
           <RectButton
-            style={styles.rightSwipeableButton}
+            style={styles.muteButton}
             onPress={() => {
-              channel.delete();
+              channel.mute();
+              console.log(channel.muteStatus());
             }}>
-            <Trash
-              width={normalize(25)}
-              height={normalize(25)}
-              color={'white'}
-            />
+            <Image source={mutedImage} style={styles.icon} />
+            <Text style={styles.actionText}>{isMuted ? 'Unmute' : 'Mute'}</Text>
+          </RectButton>
+          <RectButton
+            style={styles.deleteButton}
+            onPress={() => {
+              channel.hide();
+            }}>
+            <Trash style={styles.icon} color={'white'} />
             <Text style={styles.actionText}>Delete</Text>
           </RectButton>
         </View>
@@ -156,13 +165,21 @@ const styles = StyleSheet.create({
   swipeableContainer: {
     alignItems: 'center',
     justifyContent: 'center',
-    backgroundColor: '#C42634',
+    flexDirection: 'row',
   },
-  rightSwipeableButton: {
+  muteButton: {
     width: 72,
-    height: 62,
+    height: '100%',
     justifyContent: 'center',
     alignItems: 'center',
+    backgroundColor: '#C4C4C4',
+  },
+  deleteButton: {
+    width: 72,
+    height: '100%',
+    justifyContent: 'center',
+    alignItems: 'center',
+    backgroundColor: '#C42634',
   },
   actionText: {
     color: 'white',
@@ -172,6 +189,10 @@ const styles = StyleSheet.create({
     paddingHorizontal: '5%',
     marginTop: '5%',
   },
+  icon: {
+    width: normalize(25),
+    height: normalize(25),
+  },
 });
 
 export default ChannelPreview;
-- 
cgit v1.2.3-70-g09d2

