-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: UI facelift SwitchLanguageModal & AppFeedbackModal (#654)
## Ticket corona-school/project-user#1323 Partially: corona-school/project-user#1305 ## What was done? - Updated the SwitchLanguageModal & AppFeedbackModal to use the new components - Fixed toast behavior when a modal is open _(for the `AppFeedbackModal`)_ by adding a portal for the toaster to render it on the body ## Preview <img width="1440" alt="Bildschirmfoto 2024-09-13 um 13 33 09" src="https://github.com/user-attachments/assets/7b96eee0-0925-45d7-8d01-9825141f324b"> <img width="1440" alt="Bildschirmfoto 2024-09-13 um 13 33 20" src="https://github.com/user-attachments/assets/e1a3cfd8-a5a3-4210-a4c3-73648132ef97">
- Loading branch information
Showing
8 changed files
with
108 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,40 @@ | ||
import { VStack, useTheme, Button, Modal, useBreakpointValue } from 'native-base'; | ||
import { Modal, ModalHeader, ModalTitle } from '@/components/Modal'; | ||
import { Toggle } from '@/components/Toggle'; | ||
import { switchLanguage, languageList, languageIcons } from '../I18n'; | ||
|
||
type Props = { | ||
isOpen: boolean; | ||
onCloseModal: () => any; | ||
onIsOpenChange: (value: boolean) => void; | ||
}; | ||
|
||
export const SwitchLanguageModal: React.FC<Props> = ({ isOpen, onCloseModal }) => { | ||
const { space } = useTheme(); | ||
export const SwitchLanguageModal: React.FC<Props> = ({ isOpen, onIsOpenChange }) => { | ||
const storageLanguage = localStorage.getItem('lernfair-language'); | ||
|
||
const widthButtonText = useBreakpointValue({ | ||
base: '55%', | ||
md: '35%', | ||
}); | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onCloseModal}> | ||
<Modal.Content> | ||
<VStack> | ||
<Modal.CloseButton /> | ||
<Modal.Header>Sprache wechseln / Choose language</Modal.Header> | ||
</VStack> | ||
<VStack padding={space['1']} space={space['1']}> | ||
{languageList.map((button, i) => { | ||
const Icon = languageIcons[button.short as keyof typeof languageIcons]; | ||
<Modal onOpenChange={onIsOpenChange} isOpen={isOpen}> | ||
<ModalHeader> | ||
<ModalTitle>Sprache wechseln / Choose language</ModalTitle> | ||
</ModalHeader> | ||
<div className="flex flex-col py-4 gap-y-4"> | ||
{languageList.map((button, i) => { | ||
const Icon = languageIcons[button.short as keyof typeof languageIcons]; | ||
|
||
return ( | ||
<Button | ||
isPressed={storageLanguage === button.short} | ||
variant={'outlinemiddle'} | ||
leftIcon={<Icon />} | ||
_stack={{ justifyContent: 'left', width: widthButtonText }} | ||
onPress={() => { | ||
switchLanguage(button.short); | ||
onCloseModal(); | ||
}} | ||
key={i} | ||
> | ||
{button.name} | ||
</Button> | ||
); | ||
})} | ||
</VStack> | ||
</Modal.Content> | ||
return ( | ||
<Toggle | ||
pressed={storageLanguage === button.short} | ||
variant="outline" | ||
size="lg" | ||
onPressedChange={() => { | ||
switchLanguage(button.short); | ||
onIsOpenChange(false); | ||
}} | ||
key={i} | ||
className="justify-center pl-[5%]" | ||
> | ||
<Icon className="mr-2" /> <span className="min-w-[15%] text-left">{button.name}</span> | ||
</Toggle> | ||
); | ||
})} | ||
</div> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters