From 65b07ca5feeb9c8386d21a35c1c46cecf5426186 Mon Sep 17 00:00:00 2001 From: Alekbarova Aizhan <77638520+lunars97@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:20:53 +0100 Subject: [PATCH] 1233: Implement lists as actual list (#2521) * 1233: Implement lists as actual list * 1233: ts error * 1233: linting error is resolved * 1233: additional changes to accessibility * 1233: improved accessibility on native and web * 1233: Removed some unnessary props and renamed the file * 1233: implemented suggestion related to prop * 1233: added pluralization and implemented suggestions * 1233: added translation and implemented suggestions --- native/src/components/Categories.tsx | 26 +++++++++++++------- native/src/components/CategoryListItem.tsx | 23 ++++++++++------- native/src/components/LayoutedScrollView.tsx | 3 +++ native/src/components/List.tsx | 9 ++++++- native/src/components/SearchListItem.tsx | 4 ++- native/src/components/base/TextButton.tsx | 7 +++++- native/src/routes/SearchModal.tsx | 1 + translations/translations.json | 14 +++++++++++ 8 files changed, 66 insertions(+), 21 deletions(-) diff --git a/native/src/components/Categories.tsx b/native/src/components/Categories.tsx index 8ece483017..aac176ba5e 100644 --- a/native/src/components/Categories.tsx +++ b/native/src/components/Categories.tsx @@ -10,6 +10,7 @@ import TileModel from '../models/TileModel' import testID from '../testing/testID' import { LanguageResourceCacheStateType, PageResourceCacheStateType } from '../utils/DataContainer' import CategoryListItem from './CategoryListItem' +import List from './List' import OrganizationContentInfo from './OrganizationContentInfo' import Page from './Page' import Tiles from './Tiles' @@ -80,16 +81,23 @@ const Categories = ({ language={language} path={category.path} AfterContent={category.organization && } - Footer={children.map(it => ( - ( + + )} + // Fixes VirtualizedLists nesting error + scrollEnabled={false} /> - ))} + } /> ) } diff --git a/native/src/components/CategoryListItem.tsx b/native/src/components/CategoryListItem.tsx index 137e84562b..4910db9da7 100644 --- a/native/src/components/CategoryListItem.tsx +++ b/native/src/components/CategoryListItem.tsx @@ -7,6 +7,7 @@ import { contentDirection, isContentDirectionReversalRequired } from '../constan import dimensions from '../constants/dimensions' import { LanguageResourceCacheStateType } from '../utils/DataContainer' import { getCachedThumbnail } from './Categories' +import List from './List' import SimpleImage from './SimpleImage' import SubCategoryListItem from './SubCategoryListItem' import Pressable from './base/Pressable' @@ -82,15 +83,19 @@ const CategoryListItem = ({ - {subCategories.map(subCategory => ( - - ))} + ( + + )} + scrollEnabled={false} + /> ) diff --git a/native/src/components/LayoutedScrollView.tsx b/native/src/components/LayoutedScrollView.tsx index 1bbbbe8216..22c102b5f1 100644 --- a/native/src/components/LayoutedScrollView.tsx +++ b/native/src/components/LayoutedScrollView.tsx @@ -15,6 +15,9 @@ const LayoutedScrollView = (props: LayoutedScrollViewProps): ReactElement => { = { items: Array - noItemsMessage: ReactElement | string + noItemsMessage?: ReactElement | string renderItem: (props: { item: T; index: number }) => ReactElement Header?: ReactElement Footer?: ReactElement + scrollEnabled?: boolean + accessibilityLabel?: string refresh?: () => void onEndReached?: () => void } @@ -26,7 +28,9 @@ const List = ({ Header, Footer, refresh, + accessibilityLabel, onEndReached, + scrollEnabled, }: ListProps): ReactElement => ( ({ paddingHorizontal: 10, }} onEndReachedThreshold={1} + scrollEnabled={scrollEnabled} + accessibilityRole='list' + accessibilityLabel={accessibilityLabel} /> ) diff --git a/native/src/components/SearchListItem.tsx b/native/src/components/SearchListItem.tsx index baf48ce1ee..3d7fc0043d 100644 --- a/native/src/components/SearchListItem.tsx +++ b/native/src/components/SearchListItem.tsx @@ -1,4 +1,5 @@ import React, { memo, ReactElement } from 'react' +import { useTranslation } from 'react-i18next' import Highlighter from 'react-native-highlight-words' import styled, { useTheme } from 'styled-components/native' @@ -58,6 +59,7 @@ const SearchListItem = ({ onItemPress, query, }: SearchListItemProps): ReactElement => { + const { t } = useTranslation('search') const theme = useTheme() const { title, thumbnail } = category const excerpt = getExcerpt(contentWithoutHtml, { query, maxChars: SEARCH_PREVIEW_MAX_CHARS }) @@ -86,7 +88,7 @@ const SearchListItem = ({ /> ) return ( - onItemPress(category)}> + onItemPress(category)} accessibilityHint={t('itemHint')}> diff --git a/native/src/components/base/TextButton.tsx b/native/src/components/base/TextButton.tsx index 36cf9ecdc9..fbe202ad93 100644 --- a/native/src/components/base/TextButton.tsx +++ b/native/src/components/base/TextButton.tsx @@ -30,7 +30,12 @@ type TextButtonProps = { } const TextButton = ({ text, onPress, disabled = false, type = 'primary', style }: TextButtonProps): ReactElement => ( - + {text} ) diff --git a/native/src/routes/SearchModal.tsx b/native/src/routes/SearchModal.tsx index 3319a8a1e0..a76f285a21 100644 --- a/native/src/routes/SearchModal.tsx +++ b/native/src/routes/SearchModal.tsx @@ -114,6 +114,7 @@ const SearchModal = ({ diff --git a/translations/translations.json b/translations/translations.json index 4926d26a9c..2905f0bb08 100644 --- a/translations/translations.json +++ b/translations/translations.json @@ -8412,6 +8412,13 @@ "de": { "nothingFound": "Es wurden leider keine passenden Ergebnisse gefunden.", "searchPlaceholder": "Suche", + "itemHint": "Suchergebnis öffnen", + "searchResultsCount_zero": "0 Suchergebnisse", + "searchResultsCount_one": "1 Suchergebnis", + "searchResultsCount_two": "2 Suchergebnisse", + "searchResultsCount_few": "{{count}} Suchergebnisse", + "searchResultsCount_many": "{{count}} Suchergebnisse", + "searchResultsCount_other": "{{count}} Suchergebnisse", "pageTitle": "Suche", "delete": "Eingabe löschen" }, @@ -8454,6 +8461,13 @@ "en": { "nothingFound": "Sorry, we could not find any matching results.", "searchPlaceholder": "Search", + "itemHint": "View search result", + "searchResultsCount_zero": "0 search results", + "searchResultsCount_one": "1 search result", + "searchResultsCount_two": "2 search results", + "searchResultsCount_few": "{{count}} search results", + "searchResultsCount_many": "{{count}} search results", + "searchResultsCount_other": "{{count}} search results", "pageTitle": "Search", "delete": "Delete input" },