Skip to content

Commit 03ca5b9

Browse files
committed
[Mobile] Change read item design, stop muting views
1 parent 04b337b commit 03ca5b9

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

packages/components/src/components/cards/BaseCard.shared.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AppViewMode,
23
cheapestPlanWithNotifications,
34
Column,
45
ColumnSubscription,
@@ -100,7 +101,13 @@ export const sizes = {
100101
export const renderCardActions =
101102
Platform.OS === 'web' || constants.DISABLE_SWIPEABLE_CARDS
102103

103-
export interface BaseCardProps {
104+
export interface AdditionalCardProps {
105+
appViewMode: AppViewMode
106+
columnId: string
107+
height: number
108+
}
109+
110+
export interface BaseCardProps extends AdditionalCardProps {
104111
action?: {
105112
avatar: {
106113
imageURL: string
@@ -118,7 +125,6 @@ export interface BaseCardProps {
118125
repoId?: number | string | undefined
119126
text?: string
120127
}
121-
height: number
122128
icon: {
123129
name: GitHubIcon
124130
color?: keyof ThemeColors
@@ -192,7 +198,7 @@ function getPrivateBannerCardProps(
192198
props: Pick<BaseCardProps, 'avatar' | 'date'> & {
193199
iconColor: BaseCardProps['icon']['color']
194200
},
195-
): Omit<BaseCardProps, 'height'> {
201+
): Omit<BaseCardProps, keyof AdditionalCardProps> {
196202
const highlightFeature: keyof Plan['featureFlags'] =
197203
'enablePrivateRepositories'
198204

@@ -247,7 +253,7 @@ function _getCardPropsForItem(
247253
plan: UserPlan | null | undefined
248254
repoIsKnown: boolean
249255
},
250-
): Omit<BaseCardProps, 'height'> {
256+
): Omit<BaseCardProps, keyof AdditionalCardProps> {
251257
switch (type) {
252258
case 'activity': {
253259
const event = item as EnhancedGitHubEvent
@@ -928,7 +934,7 @@ function _getCardPropsForItem(
928934

929935
const reasonMetadata = getNotificationReasonMetadata(notification.reason)
930936

931-
const defaultProps: Omit<BaseCardProps, 'height'> = {
937+
const defaultProps: Omit<BaseCardProps, keyof AdditionalCardProps> = {
932938
action: undefined,
933939
avatar: {
934940
imageURL:
@@ -1160,7 +1166,8 @@ export function getCardPropsForItem(
11601166
plan: UserPlan | null | undefined
11611167
repoIsKnown: boolean
11621168
},
1163-
): BaseCardProps {
1169+
): Omit<BaseCardProps, keyof AdditionalCardProps> &
1170+
Pick<AdditionalCardProps, 'height'> {
11641171
const props = _memoizedGetCardPropsForItem(
11651172
type,
11661173
columnId,
@@ -1173,7 +1180,7 @@ export function getCardPropsForItem(
11731180
}
11741181

11751182
export function getCardSizeForProps(
1176-
props: Omit<BaseCardProps, 'height'>,
1183+
props: Omit<BaseCardProps, keyof AdditionalCardProps>,
11771184
): number {
11781185
if (!props) return 0
11791186

packages/components/src/components/cards/BaseCard.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getDateSmallText, getFullDateText, Theme } from '@devhub/core'
2-
import React, { Fragment, useContext } from 'react'
2+
import React, { Fragment } from 'react'
33
import { PixelRatio, ScrollView, StyleSheet, Text, View } from 'react-native'
44
import { useDispatch } from 'react-redux'
55

@@ -17,7 +17,6 @@ import {
1717
import { stripEmojis } from '../../utils/helpers/github/emojis'
1818
import { vibrateHapticFeedback } from '../../utils/helpers/shared'
1919
import { KeyboardKeyIsPressed } from '../AppKeyboardShortcuts'
20-
import { CurrentColumnContext } from '../columns/Column'
2120
import { getCardBackgroundThemeColor } from '../columns/ColumnRenderer'
2221
import { Avatar } from '../common/Avatar'
2322
import { IntervalRefresh } from '../common/IntervalRefresh'
@@ -193,10 +192,13 @@ const styles = StyleSheet.create({
193192
export const BaseCard = React.memo((props: BaseCardProps) => {
194193
const {
195194
action,
195+
appViewMode,
196+
height,
197+
196198
avatar,
199+
columnId,
197200
date,
198201
githubApp,
199-
height,
200202
icon,
201203
isRead,
202204
isSaved,
@@ -223,14 +225,15 @@ export const BaseCard = React.memo((props: BaseCardProps) => {
223225
link,
224226
)
225227

228+
const isMuted = appViewMode === 'single-column' ? false : isRead
229+
226230
const backgroundThemeColor = (theme: Theme) =>
227231
getCardBackgroundThemeColor({
228232
isDark: theme.isDark,
229-
isMuted: isRead,
233+
isMuted,
230234
})
231235

232236
const dispatch = useDispatch()
233-
const columnId = useContext(CurrentColumnContext)
234237

235238
const textIsOnlyIssueNumber =
236239
text && text.text && text.text.match(/^#([0-9]+)$/)
@@ -308,7 +311,7 @@ export const BaseCard = React.memo((props: BaseCardProps) => {
308311
<ThemedText
309312
color={'foregroundColor'}
310313
numberOfLines={1}
311-
style={[styles.title, { fontWeight: isRead ? '300' : '500' }]}
314+
style={[styles.title, { fontWeight: isMuted ? '300' : '500' }]}
312315
>
313316
{title}
314317
</ThemedText>
@@ -353,7 +356,7 @@ export const BaseCard = React.memo((props: BaseCardProps) => {
353356
numberOfLines={1}
354357
style={[
355358
styles.subtitle,
356-
{ fontWeight: isRead ? '300' : '400' },
359+
{ fontWeight: isMuted ? '300' : '400' },
357360
]}
358361
>
359362
{subtitle}
@@ -692,7 +695,7 @@ export const BaseCard = React.memo((props: BaseCardProps) => {
692695
<Spacer flex={1} />
693696
</View>
694697

695-
<CardItemSeparator muted={isRead} />
698+
<CardItemSeparator muted={isMuted} />
696699
</View>
697700
)
698701
})

packages/components/src/components/cards/CardWithLink.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useCallback, useMemo, useRef } from 'react'
33
import { StyleSheet, TouchableHighlightProps, View } from 'react-native'
44
import { useDispatch } from 'react-redux'
55

6+
import { useAppViewMode } from '../../hooks/use-app-view-mode'
67
import { useDynamicRef } from '../../hooks/use-dynamic-ref'
78
import { useHover } from '../../hooks/use-hover'
89
import { useIsItemFocused } from '../../hooks/use-is-item-focused'
@@ -25,6 +26,7 @@ import {
2526
import { ThemedView } from '../themed/ThemedView'
2627
import { BaseCard } from './BaseCard'
2728
import { getCardPropsForItem } from './BaseCard.shared'
29+
import { CardLeftBorder } from './partials/CardLeftBorder'
2830
import { CardSavedIndicator } from './partials/CardSavedIndicator'
2931

3032
export interface CardWithLinkProps {
@@ -53,6 +55,7 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
5355

5456
const dispatch = useDispatch()
5557
const plan = useReduxState(selectors.currentUserPlanSelector)
58+
const { appViewMode } = useAppViewMode()
5659

5760
const item = useItem(nodeIdOrId)
5861

@@ -73,10 +76,12 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
7376
<BaseCard
7477
key={`${type}-base-card-${getItemNodeIdOrId(item)!}`}
7578
{..._cardProps}
79+
appViewMode={appViewMode}
80+
columnId={columnId}
7681
/>
7782
),
7883
}
79-
}, [columnId, item, ownerIsKnown, plan, repoIsKnown])
84+
}, [appViewMode, columnId, item, ownerIsKnown, plan, repoIsKnown])
8085

8186
const isReadRef = useDynamicRef(!!(cardProps && cardProps.isRead))
8287

@@ -108,7 +113,8 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
108113
theme[
109114
getCardBackgroundThemeColor({
110115
isDark: theme.isDark,
111-
isMuted: isReadRef.current,
116+
isMuted:
117+
appViewMode === 'single-column' ? false : isReadRef.current,
112118
isHovered: isHoveredRef.current,
113119
})
114120
],
@@ -126,7 +132,7 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
126132
},
127133
})
128134
}
129-
}, [])
135+
}, [appViewMode])
130136

131137
const handleFocusChange = useCallback(
132138
(value, disableDomFocus?: boolean) => {
@@ -180,7 +186,7 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
180186
backgroundThemeColor={theme =>
181187
getCardBackgroundThemeColor({
182188
isDark: theme.isDark,
183-
isMuted: cardProps.isRead,
189+
isMuted: appViewMode === 'single-column' ? false : cardProps.isRead,
184190
// isHovered: !Platform.supportsTouch && isFocusedRef.current,
185191
})
186192
}
@@ -239,13 +245,13 @@ export const CardWithLink = React.memo((props: CardWithLinkProps) => {
239245

240246
{CardComponent}
241247

242-
{/* {appViewMode === 'single-column' && (
248+
{appViewMode === 'single-column' && (
243249
<CardLeftBorder
244250
style={{
245251
opacity: !!(cardProps && !cardProps.isRead) ? 1 : 0,
246252
}}
247253
/>
248-
)} */}
254+
)}
249255

250256
{!!isSaved && <CardSavedIndicator />}
251257
</Link>

0 commit comments

Comments
 (0)