From 1e5330931d96a54d3407fe7ac9d71003bb2346e9 Mon Sep 17 00:00:00 2001 From: Aryan Goharzad Date: Wed, 1 Feb 2023 14:11:29 -0500 Subject: [PATCH] Adds dark mode to the dropdown (#131) * Adds dark mode to the bottom sheet * Make background button lighter (like before) * lint --- src/App.native.tsx | 16 ++--- src/view/com/util/forms/DropdownButton.tsx | 80 +++++++++++++++++----- 2 files changed, 70 insertions(+), 26 deletions(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index f00e3cad1c..39988c5aed 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -61,17 +61,17 @@ const App = observer(() => { return ( - - - - + + + + - - - - + + + + ) }) diff --git a/src/view/com/util/forms/DropdownButton.tsx b/src/view/com/util/forms/DropdownButton.tsx index 63aecc4798..6165c191d1 100644 --- a/src/view/com/util/forms/DropdownButton.tsx +++ b/src/view/com/util/forms/DropdownButton.tsx @@ -18,6 +18,8 @@ import {toShareUrl} from '../../../../lib/strings' import {useStores} from '../../../../state' import {ReportPostModal, ConfirmModal} from '../../../../state/models/shell-ui' import {TABS_ENABLED} from '../../../../build-flags' +import {usePalette} from '../../../lib/hooks/usePalette' +import {useTheme} from '../../../lib/ThemeContext' const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10} @@ -181,24 +183,14 @@ function createDropdownMenu( const onOuterPress = () => sibling.destroy() const sibling = new RootSiblings( ( - <> - - - - - {items.map((item, index) => ( - onPressItem(index)}> - {item.icon && ( - - )} - {item.label} - - ))} - - + ), ) return sibling @@ -242,3 +234,55 @@ const styles = StyleSheet.create({ fontSize: 18, }, }) +type DropDownItemProps = { + onOuterPress: () => void + x: number + y: number + width: number + items: DropdownItem[] + onPressItem: (index: number) => void +} + +const DropdownItems = ({ + onOuterPress, + x, + y, + width, + items, + onPressItem, +}: DropDownItemProps): React.ReactNode => { + const pal = usePalette('default') + const theme = useTheme() + const dropDownBackgroundColor = + theme.colorScheme === 'dark' ? pal.btn : pal.view + + return ( + <> + + + + + {items.map((item, index) => ( + onPressItem(index)}> + {item.icon && ( + + )} + {item.label} + + ))} + + + ) +}