Skip to content

Commit f5bdded

Browse files
gnpricechrisbobbe
authored andcommitted
StreamItem [nfc]: Unify more styles
1 parent de4cc67 commit f5bdded

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

src/streams/StreamItem.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,28 @@ export default function StreamItem(props: Props): Node {
108108
userSettingStreamNotification: getSettings(state).streamNotification,
109109
}));
110110

111+
const { backgroundColor: themeBackgroundColor, color: themeColor } = useContext(ThemeContext);
112+
const iconColor =
113+
color !== undefined
114+
? color
115+
: foregroundColorFromBackground(
116+
backgroundColor !== undefined ? backgroundColor : themeBackgroundColor,
117+
);
118+
const textColor =
119+
backgroundColor !== undefined
120+
? (foregroundColorFromBackground(backgroundColor): string)
121+
: themeColor;
122+
111123
const styles = useMemo(
112124
() => ({
113-
listItem: {
125+
wrapper: {
114126
flexDirection: 'row',
115127
alignItems: 'center',
116128
...(handleExpandCollapse
117129
? { paddingRight: 16 }
118130
: { paddingVertical: 8, paddingHorizontal: 16 }),
131+
backgroundColor,
132+
opacity: isMuted ? 0.5 : 1,
119133
},
120134
description: {
121135
opacity: 0.75,
@@ -126,9 +140,6 @@ export default function StreamItem(props: Props): Node {
126140
paddingLeft: 8,
127141
paddingRight: 8,
128142
},
129-
muted: {
130-
opacity: 0.5,
131-
},
132143
collapseIcon: {
133144
marginRight: 8,
134145
},
@@ -142,23 +153,9 @@ export default function StreamItem(props: Props): Node {
142153
paddingRight: 0,
143154
},
144155
}),
145-
[handleExpandCollapse],
156+
[backgroundColor, handleExpandCollapse, isMuted],
146157
);
147158

148-
const { backgroundColor: themeBackgroundColor, color: themeColor } = useContext(ThemeContext);
149-
150-
const wrapperStyle = [styles.listItem, { backgroundColor }, isMuted && styles.muted];
151-
const iconColor =
152-
color !== undefined
153-
? color
154-
: foregroundColorFromBackground(
155-
backgroundColor !== undefined ? backgroundColor : themeBackgroundColor,
156-
);
157-
const textColor =
158-
backgroundColor !== undefined
159-
? (foregroundColorFromBackground(backgroundColor): string)
160-
: themeColor;
161-
162159
return (
163160
<Touchable
164161
onPress={() => onPress({ stream_id: streamId, name })}
@@ -171,7 +168,7 @@ export default function StreamItem(props: Props): Node {
171168
});
172169
}}
173170
>
174-
<View style={wrapperStyle}>
171+
<View style={styles.wrapper}>
175172
{handleExpandCollapse && (
176173
<Pressable style={styles.pressable} onPress={() => handleExpandCollapse(streamId)}>
177174
{isCollapsed === false ? (

0 commit comments

Comments
 (0)