39d460db51
* [APP-1303] Redesign/refactor post language select (#8884) * Nightly source-language update * Nightly source-language update * [APP-1303] Redesign/refactor post language select * update: stylesheets.create to use the latest structure * update styles to modern structure * update: dialog breakpoints on web and delete depricated language modals * remove unused post languages settings dialog * restructure Post languages dialog * place the Dialog.Close inside the Dialog.ScrollableInner * add: language search * update search and language variables for clarity * fix: memoize language state lists * chore: add comments * update proper colors to the background * add back older error boundary * add: tweaks to the mobile and web responsiveness * add tweaks to center the container * update labels * update button and border * added translation updates * Update: text input to reuse search input * remove unused file * update: web breakpoints * run eslint and prettier --------- Co-authored-by: Elijah Seed-Arita <elijaharita@gmail.com> Co-authored-by: Anastasiya Uraleva <anastasiya@Anastasiyas-MacBook-Pro.local> Co-authored-by: Anastasiya Uraleva <anastasiya@Mac.localdomain> * rm old file * sort out styles, add FlatListFooter component * rm cancel button in favor of search input X * get dialog height working on iOS * delete `DropdownButton` * hide scroll indicators on android * ios scroll indicator insets * get footer sorta working on android * change button color on press * rm empty file --------- Co-authored-by: Anastasiya Uraleva <anastasiyauraleva@gmail.com> Co-authored-by: Elijah Seed-Arita <elijaharita@gmail.com> Co-authored-by: Anastasiya Uraleva <anastasiya@Anastasiyas-MacBook-Pro.local> Co-authored-by: Anastasiya Uraleva <anastasiya@Mac.localdomain>
117 lines
3.3 KiB
TypeScript
117 lines
3.3 KiB
TypeScript
import {StyleSheet, TouchableWithoutFeedback, View} from 'react-native'
|
|
import Animated, {FadeIn, FadeOut} from 'react-native-reanimated'
|
|
import {RemoveScrollBar} from 'react-remove-scroll-bar'
|
|
|
|
import {usePalette} from '#/lib/hooks/usePalette'
|
|
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
|
import {type Modal as ModalIface} from '#/state/modals'
|
|
import {useModalControls, useModals} from '#/state/modals'
|
|
import * as CreateOrEditListModal from './CreateOrEditList'
|
|
import * as DeleteAccountModal from './DeleteAccount'
|
|
import * as InviteCodesModal from './InviteCodes'
|
|
import * as ContentLanguagesSettingsModal from './lang-settings/ContentLanguagesSettings'
|
|
import * as UserAddRemoveLists from './UserAddRemoveLists'
|
|
|
|
export function ModalsContainer() {
|
|
const {isModalActive, activeModals} = useModals()
|
|
|
|
if (!isModalActive) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<RemoveScrollBar />
|
|
{activeModals.map((modal, i) => (
|
|
<Modal key={`modal-${i}`} modal={modal} />
|
|
))}
|
|
</>
|
|
)
|
|
}
|
|
|
|
function Modal({modal}: {modal: ModalIface}) {
|
|
const {isModalActive} = useModals()
|
|
const {closeModal} = useModalControls()
|
|
const pal = usePalette('default')
|
|
const {isMobile} = useWebMediaQueries()
|
|
|
|
if (!isModalActive) {
|
|
return null
|
|
}
|
|
|
|
const onPressMask = () => {
|
|
closeModal()
|
|
}
|
|
const onInnerPress = () => {
|
|
// TODO: can we use prevent default?
|
|
// do nothing, we just want to stop it from bubbling
|
|
}
|
|
|
|
let element
|
|
if (modal.name === 'create-or-edit-list') {
|
|
element = <CreateOrEditListModal.Component {...modal} />
|
|
} else if (modal.name === 'user-add-remove-lists') {
|
|
element = <UserAddRemoveLists.Component {...modal} />
|
|
} else if (modal.name === 'delete-account') {
|
|
element = <DeleteAccountModal.Component />
|
|
} else if (modal.name === 'invite-codes') {
|
|
element = <InviteCodesModal.Component />
|
|
} else if (modal.name === 'content-languages-settings') {
|
|
element = <ContentLanguagesSettingsModal.Component />
|
|
} else {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-descriptors
|
|
<TouchableWithoutFeedback onPress={onPressMask}>
|
|
<Animated.View
|
|
style={styles.mask}
|
|
entering={FadeIn.duration(150)}
|
|
exiting={FadeOut}>
|
|
{/* eslint-disable-next-line react-native-a11y/has-valid-accessibility-descriptors */}
|
|
<TouchableWithoutFeedback onPress={onInnerPress}>
|
|
<View
|
|
style={[
|
|
styles.container,
|
|
isMobile && styles.containerMobile,
|
|
pal.view,
|
|
pal.border,
|
|
]}>
|
|
{element}
|
|
</View>
|
|
</TouchableWithoutFeedback>
|
|
</Animated.View>
|
|
</TouchableWithoutFeedback>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
mask: {
|
|
// @ts-ignore
|
|
position: 'fixed',
|
|
top: 0,
|
|
left: 0,
|
|
width: '100%',
|
|
height: '100%',
|
|
backgroundColor: '#000c',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
},
|
|
container: {
|
|
width: 600,
|
|
// @ts-ignore web only
|
|
maxWidth: '100vw',
|
|
// @ts-ignore web only
|
|
maxHeight: '90vh',
|
|
paddingVertical: 20,
|
|
paddingHorizontal: 24,
|
|
borderRadius: 8,
|
|
borderWidth: 1,
|
|
},
|
|
containerMobile: {
|
|
borderRadius: 0,
|
|
paddingHorizontal: 0,
|
|
},
|
|
})
|