Skip to content

Commit

Permalink
Merge pull request #87 from digitalfabrik/LUN-67-remove-empty-elements
Browse files Browse the repository at this point in the history
LUN-67: Remove empty elements
  • Loading branch information
ztefanie authored Jun 8, 2021
2 parents ef42c7e + 32a2cac commit c736e5e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/screens/ExercisesScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import { View, Text, LogBox, TouchableOpacity, FlatList, Pressable, StyleSheet } from 'react-native'
import { Home, Arrow, BackButton, BackArrowPressed, HomeButtonPressed } from '../../assets/images'
import Title from '../components/Title'
import { EXERCISES, ExerciseType } from '../constants/data'
import { ExerciseKeys, EXERCISES, ExerciseType } from '../constants/data'
import { RouteProp, useFocusEffect } from '@react-navigation/native'
import { COLORS } from '../constants/colors'
import { widthPercentageToDP as wp } from 'react-native-responsive-screen'
Expand Down Expand Up @@ -162,7 +162,10 @@ const ExercisesScreen = ({ route, navigation }: ExercisesScreenPropsType): JSX.E
</Title>
)

const Item = ({ item }: { item: ExerciseType }): JSX.Element => {
const Item = ({ item }: { item: ExerciseType }): JSX.Element | null => {
if (item.key === ExerciseKeys.learnArticles || item.key === ExerciseKeys.singleChoice) {
return null
}
const selected = item.key.toString() === selectedKey
const itemStyle = selected ? styles.clickedContainer : styles.container
const itemTitleStyle = selected ? styles.clickedItemTitle : styles.title2
Expand Down
6 changes: 5 additions & 1 deletion src/screens/ProfessionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ const ProfessionScreen = ({ navigation }: ProfessionScreenPropsType): JSX.Elemen
</>
)

const Item = ({ item }: { item: ProfessionType }): JSX.Element => {
const Item = ({ item }: { item: ProfessionType }): JSX.Element | null => {
const itemTextStyle = item.id === selectedId ? styles.clickedItemDescription : styles.description

if (item.total_training_sets === 0) {
return null
}

return (
<MenuItem
selected={item.id === selectedId}
Expand Down
5 changes: 4 additions & 1 deletion src/screens/ProfessionSubcategoryScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ const ProfessionSubcategoryScreen = ({ route, navigation }: ProfessionSubcategor
</Title>
)

const Item = ({ item }: { item: ProfessionSubcategoryType }): JSX.Element => {
const Item = ({ item }: { item: ProfessionSubcategoryType }): JSX.Element | null => {
if (item.total_documents === 0) {
return null
}
const selected = item.id === selectedId
const descriptionStyle = selected ? styles.clickedItemDescription : styles.description

Expand Down

0 comments on commit c736e5e

Please sign in to comment.