mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 09:09:29 +01:00
* basic i18n poc * translate home, filters, tabs support dot notation in backend for namespaces * i18n context menu, artist filters, list controls also nothings here fix backend not caching fallback * i18n queue, artist view, search/results * i18n settings and server view * Added translation using Weblate (Norwegian Bokmål) * Translated using Weblate (Norwegian Bokmål) Currently translated at 100.0% (6 of 6 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/nb_NO/ * Update translation files Updated by "Cleanup translation files" hook in Weblate. Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/ * Update translation files Updated by "Cleanup translation files" hook in Weblate. Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/ * Update translation files Updated by "Cleanup translation files" hook in Weblate. Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/ * fix url escaping * added some mostly naive text overflow fixes rewrote filter context menu as a slide in because the old one apparently can't handle dynamic width * Added translation using Weblate (French) * Translated using Weblate (French) Currently translated at 17.4% (11 of 63 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * Translated using Weblate (French) Currently translated at 19.0% (12 of 63 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * Translated using Weblate (French) Currently translated at 40.0% (26 of 65 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * add weblate and some pretty badges to readme * fix link * Translated using Weblate (French) Currently translated at 50.7% (33 of 65 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * Translated using Weblate (English) Currently translated at 100.0% (65 of 65 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/en/ * Translated using Weblate (French) Currently translated at 90.7% (59 of 65 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * i18n now playing context type fix overscroll on new filter menu fix getting default namespace from the i18n backend * Translated using Weblate (French) Currently translated at 96.9% (63 of 65 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * Translated using Weblate (French) Currently translated at 100.0% (66 of 66 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/fr/ * Translated using Weblate (Japanese) (#98) Currently translated at 7.5% (5 of 66 strings) Translation: Subtracks/subtracks Translate-URL: https://hosted.weblate.org/projects/subtracks/subtracks/ja/ Co-authored-by: Austin Riedhammer <austinried@functionkey.xyz> * little note to remind me why that's there * update licenses Co-authored-by: Allan Nordhøy <epost@anotheragency.no> Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Clyhtsuriva <aimeric@adjutor.xyz>
130 lines
3.4 KiB
TypeScript
130 lines
3.4 KiB
TypeScript
import colors from '@app/styles/colors'
|
|
import font from '@app/styles/font'
|
|
import React from 'react'
|
|
import { Text, StyleSheet, View } from 'react-native'
|
|
import { MenuOption, Menu, MenuTrigger, MenuOptions, renderers } from 'react-native-popup-menu'
|
|
import PressableOpacity from './PressableOpacity'
|
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
|
import { ScrollView } from 'react-native-gesture-handler'
|
|
|
|
const { SlideInMenu } = renderers
|
|
|
|
export type OptionData = {
|
|
value: string
|
|
text: string
|
|
}
|
|
|
|
const Option = React.memo<{
|
|
text: string
|
|
value: string
|
|
selected?: boolean
|
|
}>(({ text, value, selected }) => (
|
|
<MenuOption style={styles.option} value={value}>
|
|
{selected ? (
|
|
<Icon name="checkbox-marked-circle" size={32} color={colors.accent} style={styles.icon} />
|
|
) : (
|
|
<Icon name="checkbox-blank-circle-outline" size={32} color={colors.text.secondary} style={styles.icon} />
|
|
)}
|
|
<Text style={styles.optionText} numberOfLines={1} adjustsFontSizeToFit={true} minimumFontScale={0.6}>
|
|
{text}
|
|
</Text>
|
|
</MenuOption>
|
|
))
|
|
|
|
const FilterButton = React.memo<{
|
|
value?: string
|
|
data: OptionData[]
|
|
onSelect?: (selection: string) => void
|
|
title: string
|
|
}>(({ value, data, onSelect, title }) => {
|
|
return (
|
|
<Menu onSelect={onSelect} renderer={SlideInMenu}>
|
|
<MenuTrigger
|
|
customStyles={{
|
|
triggerOuterWrapper: styles.filterOuterWrapper,
|
|
triggerWrapper: styles.filterWrapper,
|
|
triggerTouchable: { style: styles.filter },
|
|
TriggerTouchableComponent: PressableOpacity,
|
|
}}>
|
|
<Icon name="filter-variant" color="white" size={30} />
|
|
</MenuTrigger>
|
|
<MenuOptions
|
|
customStyles={{
|
|
optionsWrapper: styles.optionsWrapper,
|
|
optionsContainer: styles.optionsContainer,
|
|
}}>
|
|
<ScrollView style={styles.optionsScroll} overScrollMode="never">
|
|
<View style={styles.header}>
|
|
<Text style={styles.headerText} numberOfLines={2} ellipsizeMode="clip">
|
|
{title}
|
|
</Text>
|
|
</View>
|
|
{data.map(o => (
|
|
<Option key={o.value} text={o.text} value={o.value} selected={o.value === value} />
|
|
))}
|
|
</ScrollView>
|
|
</MenuOptions>
|
|
</Menu>
|
|
)
|
|
})
|
|
|
|
const styles = StyleSheet.create({
|
|
filterOuterWrapper: {
|
|
position: 'absolute',
|
|
bottom: 20,
|
|
right: 20,
|
|
},
|
|
filterWrapper: {},
|
|
filter: {
|
|
borderRadius: 32,
|
|
width: 50,
|
|
height: 50,
|
|
elevation: 5,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: colors.accent,
|
|
},
|
|
optionsScroll: {
|
|
maxHeight: 260,
|
|
},
|
|
optionsWrapper: {
|
|
overflow: 'hidden',
|
|
},
|
|
optionsContainer: {
|
|
backgroundColor: 'rgba(45, 45, 45, 0.95)',
|
|
},
|
|
header: {
|
|
paddingHorizontal: 20,
|
|
// paddingVertical: 10,
|
|
marginTop: 16,
|
|
marginBottom: 6,
|
|
},
|
|
headerText: {
|
|
fontFamily: font.bold,
|
|
fontSize: 20,
|
|
color: colors.text.primary,
|
|
},
|
|
option: {
|
|
paddingVertical: 8,
|
|
paddingHorizontal: 20,
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'flex-start',
|
|
},
|
|
optionText: {
|
|
fontFamily: font.semiBold,
|
|
fontSize: 16,
|
|
color: colors.text.primary,
|
|
},
|
|
icon: {
|
|
marginRight: 14,
|
|
width: 32,
|
|
height: 32,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
// backgroundColor: 'red',
|
|
},
|
|
})
|
|
|
|
export default FilterButton
|