diff --git a/native/components/color-selector-button.react.js b/native/components/color-selector-button.react.js index b0dde476b..38bc92f15 100644 --- a/native/components/color-selector-button.react.js +++ b/native/components/color-selector-button.react.js @@ -1,58 +1,58 @@ // @flow import * as React from 'react'; import { StyleSheet, TouchableOpacity, View } from 'react-native'; import tinycolor from 'tinycolor2'; import type { SetState } from 'lib/types/hook-types'; type ColorSelectorButtonProps = { +color: string, +pendingColor: string, +setPendingColor: SetState, }; function ColorSelectorButton(props: ColorSelectorButtonProps): React.Node { const { color, pendingColor, setPendingColor } = props; const colorSplotchStyle = React.useMemo(() => { return [styles.button, { backgroundColor: `#${color}` }]; }, [color]); const onPendingColorSelected = React.useCallback(() => { setPendingColor(color); }, [setPendingColor, color]); const isSelected = tinycolor.equals(pendingColor, color); return ( ); } const styles = StyleSheet.create({ button: { borderRadius: 20, height: 40, margin: 10, width: 40, }, outerRing: { borderRadius: 40, height: 60, margin: 5, width: 60, }, outerRingSelected: { backgroundColor: '#404040', - borderRadius: 40, + borderRadius: 30, height: 60, margin: 5, width: 60, }, }); export default ColorSelectorButton; diff --git a/native/components/color-selector.react.js b/native/components/color-selector.react.js index ffc0390d1..83f2d6d8a 100644 --- a/native/components/color-selector.react.js +++ b/native/components/color-selector.react.js @@ -1,87 +1,104 @@ // @flow import * as React from 'react'; -import { Button, Text, View, StyleSheet } from 'react-native'; +import { Text, TouchableOpacity, View, StyleSheet } from 'react-native'; import tinycolor from 'tinycolor2'; import { selectedThreadColors } from 'lib/shared/thread-utils'; import ColorSelectorButton from './color-selector-button.react'; type ColorSelectorProps = { +currentColor: string, + +windowWidth: number, +onColorSelected: (hex: string) => void, }; function ColorSelector(props: ColorSelectorProps): React.Node { const { currentColor, onColorSelected } = props; const [pendingColor, setPendingColor] = React.useState(currentColor); const colorSelectorButtons = React.useMemo( () => selectedThreadColors.map(color => ( )), [pendingColor], ); + const firstRow = React.useMemo( + () => colorSelectorButtons.slice(0, colorSelectorButtons.length / 2), + [colorSelectorButtons], + ); + + const secondRow = React.useMemo( + () => colorSelectorButtons.slice(colorSelectorButtons.length / 2), + [colorSelectorButtons], + ); + const saveButtonDisabled = tinycolor.equals(currentColor, pendingColor); const saveButtonStyle = React.useMemo( () => [ styles.saveButton, - { backgroundColor: saveButtonDisabled ? '#404040' : `#${pendingColor}` }, + { + backgroundColor: saveButtonDisabled ? '#404040' : `#${pendingColor}`, + width: 0.75 * props.windowWidth, + }, ], - [saveButtonDisabled, pendingColor], + [saveButtonDisabled, pendingColor, props.windowWidth], ); const onColorSplotchSaved = React.useCallback(() => { onColorSelected(`#${pendingColor}`); }, [onColorSelected, pendingColor]); return ( Select thread color - {colorSelectorButtons} + {firstRow} + {secondRow} -