Skip to content

Commit

Permalink
feat: 🎸 Added current language name to auth screen
Browse files Browse the repository at this point in the history
✅ Closes: #367, #332
  • Loading branch information
viktorlarsson committed May 11, 2021
1 parent 1351faf commit 9f15a30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 10 additions & 2 deletions packages/app/components/auth.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { StackNavigationProp } from '@react-navigation/stack'
import { RootStackParamList } from './navigation.component'
import { SafeAreaView } from '../ui/safeAreaView.component'
import { KeyboardAvoidingView } from '../ui/keyboardAvoidingView.component'
import { LanguageService } from '../services/languageService'
import { languages } from './setLanguage.component'

const randomWord = () => {
const words = translate('auth.words')
Expand All @@ -36,14 +38,20 @@ interface AuthProps {
export const Auth: React.FC<AuthProps> = ({ navigation }) => {
const styles = useStyleSheet(themeStyles)

const currentLanguage = LanguageService.getLanguageCode()
const currentLanguageName = languages.find(
(language) => language.langCode === currentLanguage
)?.languageLocalName

return (
<KeyboardAvoidingView>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<SafeAreaView>
<SafeAreaViewContainer>
<TopNavigation
alignment="center"
accessoryRight={() => (
alignment="start"
subtitle={currentLanguageName}
accessoryLeft={() => (
<TopNavigationAction
accessibilityLabel={translate('auth.a11y_change_language', {
defaultValue: 'Tryck här för att välja språk',
Expand Down
8 changes: 4 additions & 4 deletions packages/app/components/setLanguage.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ interface Language {
active: boolean
}

const languages: Language[] = [
export const languages: Language[] = [
{
langCode: 'sv',
languageName: 'Swedish',
languageLocalName: 'svenska',
languageLocalName: 'Svenska',
active: true,
},
{
langCode: 'en',
languageName: 'English',
languageLocalName: 'english',
languageLocalName: 'English',
active: true,
},
{
langCode: 'pl',
languageName: 'Polish',
languageLocalName: 'polski',
languageLocalName: 'Polski',
active: true,
},
{
Expand Down

0 comments on commit 9f15a30

Please sign in to comment.