Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(native-app): app update inbox UI #15091

Merged
merged 9 commits into from
Jun 10, 2024
16 changes: 6 additions & 10 deletions apps/native/app/src/screens/inbox/inbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ type ListItem =
| { id: string; type: 'skeleton' | 'empty' }
| (Document & { type: undefined })

const DEFAULT_PAGE_SIZE = 50

const { useNavigationOptions, getNavigationOptions } =
createNavigationOptionHooks(
(theme, intl, initialized) => ({
Expand Down Expand Up @@ -94,8 +96,10 @@ const PressableListItem = React.memo(
const { getOrganizationLogoUrl } = useOrganizationsStore()
const [starred, setStarred] = useState<boolean>(!!item.bookmarked)
useEffect(() => setStarred(!!item.bookmarked), [item.bookmarked])
const theme = useTheme()
return (
<PressableHighlight
highlightColor={theme.shade.shade400}
onPress={() =>
navigateTo(`/inbox/${item.id}`, {
title: item.senderName,
Expand All @@ -113,13 +117,7 @@ const PressableListItem = React.memo(
toggleAction(!item.bookmarked ? 'bookmark' : 'unbookmark', item.id)
setStarred(!item.bookmarked)
}}
icon={
<Image
source={getOrganizationLogoUrl(item.senderName, 75)}
resizeMode="contain"
style={{ width: 25, height: 25 }}
/>
}
icon={getOrganizationLogoUrl(item.senderName, 75)}
/>
</PressableHighlight>
)
Expand Down Expand Up @@ -178,7 +176,7 @@ function useInboxQuery(incomingFilters?: Filters) {
const [refetching, setRefetching] = useState(true)
const [loading, setLoading] = useState(false)
const [refetcher, setRefetcher] = useState(0)
const pageSize = 50
const pageSize = DEFAULT_PAGE_SIZE

const [getListDocument] = useListDocumentsLazyQuery({
query: ListDocumentsDocument,
Expand Down Expand Up @@ -285,14 +283,12 @@ export const InboxScreen: NavigationFunctionComponent<{
const intl = useIntl()
const scrollY = useRef(new Animated.Value(0)).current
const flatListRef = useRef<FlatList>(null)
const keyboardRef = useRef(false)
const [query, setQuery] = useState('')
const queryString = useThrottleState(query)
const theme = useTheme()
const unreadCount = useUnreadCount()
const [visible, setVisible] = useState(false)
const [refetching, setRefetching] = useState(false)
const dynamicColor = useDynamicColor()

const res = useInboxQuery({
opened,
Expand Down
3 changes: 0 additions & 3 deletions apps/native/app/src/screens/notifications/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ export const NotificationsScreen: NavigationFunctionComponent = ({
uri: `${item.sender.logoUrl}?w=64&h=64&fit=pad&fm=png`,
}
}
underlayColor={
theme.isDark ? theme.shade.shade400 : theme.color.blue100
}
unread={!item.metadata.read}
onPress={() => onNotificationPress(item)}
testID={testIDs.NOTIFICATION_CARD_BUTTON}
Expand Down
8 changes: 6 additions & 2 deletions apps/native/app/src/stores/organizations-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ export const organizationsStore = create<OrganizationsStore>(
orgs.find((o) => o.logo?.title === 'Skjaldarmerki')
c = match?.logo?.url
if (c) {
logoCache.set(forName, c)
if (!c.startsWith('https://')) {
logoCache.set(forName, `https:${c}`)
} else {
logoCache.set(forName, c)
}
}
}
const url =
c ??
'https://images.ctfassets.net/8k0h54kbe6bj/6XhCz5Ss17OVLxpXNVDxAO/d3d6716bdb9ecdc5041e6baf68b92ba6/coat_of_arms.svg'
const uri = `${url}?w=${size}&h=${size}&fit=pad&bg=white&fm=png`
const uri = `${url}?w=${size}&h=${size}&fit=pad&fm=png`
return { uri }
},
actions: {
Expand Down
5 changes: 1 addition & 4 deletions apps/native/app/src/ui/lib/card/notification-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ export function NotificationCard({
testID,
}: CardProps) {
const theme = useTheme()

return (
<Host
onPress={() => onPress(id)}
underlayColor={
underlayColor ?? theme.isDark ? theme.shade.shade400 : '#EBEBFA'
}
underlayColor={underlayColor ?? theme.shade.shade400}
unread={unread}
testID={testID}
>
Expand Down
73 changes: 36 additions & 37 deletions apps/native/app/src/ui/lib/detail/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react'
import { ImageSourcePropType } from 'react-native'
import styled from 'styled-components/native'
import { dynamicColor } from '../../utils/dynamic-color'
import { font } from '../../utils/font'
import { Skeleton } from '../skeleton/skeleton'
import { Typography } from '../typography/typography'

const Host = styled.View<{ hasBorder?: boolean }>`
padding-bottom: 16px;
padding-bottom: ${({ theme }) => theme.spacing[2]}px;
border-bottom-width: ${({ hasBorder }) => (hasBorder ? '1px' : 0)};
border-bottom-color: ${dynamicColor(
(props) => ({
Expand All @@ -16,52 +16,41 @@ const Host = styled.View<{ hasBorder?: boolean }>`
true,
)};
margin-bottom: ${({ hasBorder }) => (hasBorder ? '16px' : 0)};
margin-top: 16px;
margin-top: ${({ theme }) => theme.spacing[2]}px;
`

const Logo = styled.Image`
width: 16px;
height: 16px;
margin-right: 8px;
`

const LogoBackground = styled.View`
background-color: ${dynamicColor(
(props) => ({
dark: props.theme.color.white,
light: props.theme.color.blue100,
}),
true,
)};
height: 24px;
width: 24px;
justify-content: center;
align-items: center;
border-radius: ${({ theme }) => theme.border.radius.circle};
margin-right: ${({ theme }) => theme.spacing[1]}px;
`

const Row = styled.View`
flex-direction: row;
justify-content: space-between;
padding-bottom: 8px;
padding-bottom: ${({ theme }) => theme.spacing[1]}px;
`

const Wrapper = styled.View`
flex-direction: row;
align-items: center;
flex: 1;
padding-right: 8px;
`

const Title = styled.Text`
flex: 1;
${font({
fontWeight: '600',
fontSize: 13,
lineHeight: 17,
})}
`

const Date = styled.Text<{ unread?: boolean }>`
${font({
fontWeight: (props) => (props.unread ? '600' : '300'),
fontSize: 13,
lineHeight: 17,
})}
`

const Message = styled.Text`
padding-bottom: 8px;
${font({
fontWeight: '300',
fontSize: 16,
lineHeight: 24,
})}
padding-right: ${({ theme }) => theme.spacing[1]}px;
`

interface HeaderProps {
Expand Down Expand Up @@ -89,21 +78,31 @@ export function Header({
) : (
<>
<Wrapper>
{logo && <Logo source={logo} />}
{logo && (
<LogoBackground>
<Logo source={logo} />
</LogoBackground>
)}
{title && (
<Title numberOfLines={1} ellipsizeMode="tail">
<Typography
variant="body3"
numberOfLines={1}
ellipsizeMode="tail"
>
{title}
</Title>
</Typography>
)}
</Wrapper>
<Date>{date}</Date>
<Typography variant="body3">{date}</Typography>
</>
)}
</Row>
{message && isLoading ? (
<Skeleton active style={{ borderRadius: 4 }} height={32} />
) : message && !isLoading ? (
<Message>{message}</Message>
<Typography style={{ paddingBottom: 8, fontWeight: '600' }}>
{message}
</Typography>
) : null}
</Host>
)
Expand Down
Loading
Loading