More darkmode fixes (#381)

* Update confirm modal to use theming system (close #347)

* Add dark mode styles to serverinput modal

* Fix lint
This commit is contained in:
Paul Frazee 2023-04-03 16:19:22 -05:00 committed by GitHub
parent 59e6b308c6
commit 9102af6b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 29 deletions

View file

@ -5,14 +5,14 @@ import {
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native' } from 'react-native'
import LinearGradient from 'react-native-linear-gradient'
import {Text} from '../util/text/Text' import {Text} from '../util/text/Text'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {s, colors, gradients} from 'lib/styles' import {s, colors} from 'lib/styles'
import {ErrorMessage} from '../util/error/ErrorMessage' import {ErrorMessage} from '../util/error/ErrorMessage'
import {cleanError} from 'lib/strings/errors' import {cleanError} from 'lib/strings/errors'
import {usePalette} from 'lib/hooks/usePalette'
export const snapPoints = ['50%'] export const snapPoints = [300]
export function Component({ export function Component({
title, title,
@ -23,6 +23,7 @@ export function Component({
message: string | (() => JSX.Element) message: string | (() => JSX.Element)
onPressConfirm: () => void | Promise<void> onPressConfirm: () => void | Promise<void>
}) { }) {
const pal = usePalette('default')
const store = useStores() const store = useStores()
const [isProcessing, setIsProcessing] = useState<boolean>(false) const [isProcessing, setIsProcessing] = useState<boolean>(false)
const [error, setError] = useState<string>('') const [error, setError] = useState<string>('')
@ -39,10 +40,14 @@ export function Component({
} }
} }
return ( return (
<View testID="confirmModal" style={[s.flex1, s.pl10, s.pr10]}> <View testID="confirmModal" style={[pal.view, styles.container]}>
<Text style={styles.title}>{title}</Text> <Text type="title-xl" style={[pal.text, styles.title]}>
{title}
</Text>
{typeof message === 'string' ? ( {typeof message === 'string' ? (
<Text style={styles.description}>{message}</Text> <Text type="xl" style={[pal.textLight, styles.description]}>
{message}
</Text>
) : ( ) : (
message() message()
)} )}
@ -51,19 +56,17 @@ export function Component({
<ErrorMessage message={error} /> <ErrorMessage message={error} />
</View> </View>
) : undefined} ) : undefined}
<View style={s.flex1} />
{isProcessing ? ( {isProcessing ? (
<View style={[styles.btn, s.mt10]}> <View style={[styles.btn, s.mt10]}>
<ActivityIndicator /> <ActivityIndicator />
</View> </View>
) : ( ) : (
<TouchableOpacity testID="confirmBtn" style={s.mt10} onPress={onPress}> <TouchableOpacity
<LinearGradient testID="confirmBtn"
colors={[gradients.blueLight.start, gradients.blueLight.end]} onPress={onPress}
start={{x: 0, y: 0}} style={[styles.btn]}>
end={{x: 1, y: 1}} <Text style={[s.white, s.bold, s.f18]}>Confirm</Text>
style={[styles.btn]}>
<Text style={[s.white, s.bold, s.f18]}>Confirm</Text>
</LinearGradient>
</TouchableOpacity> </TouchableOpacity>
)} )}
</View> </View>
@ -71,26 +74,28 @@ export function Component({
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: {
flex: 1,
padding: 10,
paddingBottom: 60,
},
title: { title: {
textAlign: 'center', textAlign: 'center',
fontWeight: 'bold',
fontSize: 24,
marginBottom: 12, marginBottom: 12,
}, },
description: { description: {
textAlign: 'center', textAlign: 'center',
fontSize: 17,
paddingHorizontal: 22, paddingHorizontal: 22,
color: colors.gray5,
marginBottom: 10, marginBottom: 10,
}, },
btn: { btn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
width: '100%',
borderRadius: 32, borderRadius: 32,
padding: 14, padding: 14,
backgroundColor: colors.gray1, marginTop: 22,
marginHorizontal: 44,
backgroundColor: colors.blue3,
}, },
}) })

View file

@ -8,6 +8,7 @@ import {ScrollView, TextInput} from './util'
import {Text} from '../util/text/Text' import {Text} from '../util/text/Text'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {s, colors} from 'lib/styles' import {s, colors} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette'
import {useTheme} from 'lib/ThemeContext' import {useTheme} from 'lib/ThemeContext'
import {LOCAL_DEV_SERVICE, STAGING_SERVICE, PROD_SERVICE} from 'state/index' import {LOCAL_DEV_SERVICE, STAGING_SERVICE, PROD_SERVICE} from 'state/index'
import {LOGIN_INCLUDE_DEV_SERVERS} from 'lib/build-flags' import {LOGIN_INCLUDE_DEV_SERVERS} from 'lib/build-flags'
@ -16,6 +17,7 @@ export const snapPoints = ['80%']
export function Component({onSelect}: {onSelect: (url: string) => void}) { export function Component({onSelect}: {onSelect: (url: string) => void}) {
const theme = useTheme() const theme = useTheme()
const pal = usePalette('default')
const store = useStores() const store = useStores()
const [customUrl, setCustomUrl] = useState<string>('') const [customUrl, setCustomUrl] = useState<string>('')
@ -28,8 +30,10 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) {
} }
return ( return (
<View style={s.flex1} testID="serverInputModal"> <View style={[pal.view, s.flex1]} testID="serverInputModal">
<Text style={[s.textCenter, s.bold, s.f18]}>Choose Service</Text> <Text type="2xl-bold" style={[pal.text, s.textCenter]}>
Choose Service
</Text>
<ScrollView style={styles.inner}> <ScrollView style={styles.inner}>
<View style={styles.group}> <View style={styles.group}>
{LOGIN_INCLUDE_DEV_SERVERS ? ( {LOGIN_INCLUDE_DEV_SERVERS ? (
@ -66,11 +70,11 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={styles.group}> <View style={styles.group}>
<Text style={styles.label}>Other service</Text> <Text style={[pal.text, styles.label]}>Other service</Text>
<View style={s.flexRow}> <View style={s.flexRow}>
<TextInput <TextInput
testID="customServerTextInput" testID="customServerTextInput"
style={styles.textInput} style={[pal.borderDark, pal.text, styles.textInput]}
placeholder="e.g. https://bsky.app" placeholder="e.g. https://bsky.app"
placeholderTextColor={colors.gray4} placeholderTextColor={colors.gray4}
autoCapitalize="none" autoCapitalize="none"
@ -82,11 +86,11 @@ export function Component({onSelect}: {onSelect: (url: string) => void}) {
/> />
<TouchableOpacity <TouchableOpacity
testID="customServerSelectBtn" testID="customServerSelectBtn"
style={styles.textInputBtn} style={[pal.borderDark, pal.text, styles.textInputBtn]}
onPress={() => doSelect(customUrl)}> onPress={() => doSelect(customUrl)}>
<FontAwesomeIcon <FontAwesomeIcon
icon="check" icon="check"
style={[s.black as FontAwesomeIconStyle, styles.checkIcon]} style={[pal.text as FontAwesomeIconStyle, styles.checkIcon]}
size={18} size={18}
/> />
</TouchableOpacity> </TouchableOpacity>
@ -112,18 +116,15 @@ const styles = StyleSheet.create({
textInput: { textInput: {
flex: 1, flex: 1,
borderWidth: 1, borderWidth: 1,
borderColor: colors.gray3,
borderTopLeftRadius: 6, borderTopLeftRadius: 6,
borderBottomLeftRadius: 6, borderBottomLeftRadius: 6,
paddingHorizontal: 14, paddingHorizontal: 14,
paddingVertical: 12, paddingVertical: 12,
fontSize: 16, fontSize: 16,
color: colors.black,
}, },
textInputBtn: { textInputBtn: {
borderWidth: 1, borderWidth: 1,
borderLeftWidth: 0, borderLeftWidth: 0,
borderColor: colors.gray3,
borderTopRightRadius: 6, borderTopRightRadius: 6,
borderBottomRightRadius: 6, borderBottomRightRadius: 6,
paddingHorizontal: 14, paddingHorizontal: 14,