From 6a4b5618aa079086d0db038c552eb2ea3a6816f6 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Sat, 1 Jan 2022 21:55:32 +0100 Subject: [PATCH] Resolve track pop-up spacing --- src/components/Button.tsx | 10 ++++--- src/components/Modal.tsx | 13 +++++----- src/components/Typography.ts | 1 + src/components/WrappableButtonRow.tsx | 13 ++++++++++ .../Music/stacks/components/TrackListView.tsx | 13 +++++----- src/screens/modals/TrackPopupMenu.tsx | 26 +++++++------------ 6 files changed, 42 insertions(+), 34 deletions(-) create mode 100644 src/components/WrappableButtonRow.tsx diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 0ac543c..39dd6c2 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useState } from 'react'; import { SvgProps } from 'react-native-svg'; import { - PressableProps, ViewProps, + PressableProps, ViewProps, View, } from 'react-native'; import { THEME_COLOR } from 'CONSTANTS'; import styled, { css } from 'styled-components/native'; @@ -13,7 +13,6 @@ interface ButtonProps extends PressableProps { style?: ViewProps['style']; } - const BaseButton = styled.Pressable` padding: 16px; border-radius: 8px; @@ -32,7 +31,7 @@ const ButtonText = styled.Text<{ active?: boolean }>` `} `; -export default function Button(props: ButtonProps) { +const Button = React.forwardRef(function Button(props, ref) { const { icon: Icon, title, ...rest } = props; const defaultStyles = useDefaultStyles(); const [isPressed, setPressed] = useState(false); @@ -42,6 +41,7 @@ export default function Button(props: ButtonProps) { return ( {title} ); -} \ No newline at end of file +}); + +export default Button; \ No newline at end of file diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index ef646ba..51dfcde 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -16,8 +16,9 @@ const Background = styled(Pressable)` const Container = styled(Pressable)>` margin: auto 20px; padding: 4px; - border-radius: 8px; - overflow: hidden; + border-radius: 12px; + flex: 0 0 auto; + background: salmon; ${props => props.fullSize && css` flex: 1; @@ -35,11 +36,9 @@ const Modal: React.FC = ({ children, fullSize = true }) => { return ( - - - {children} - - + + {children} + ); }; diff --git a/src/components/Typography.ts b/src/components/Typography.ts index 68f94a1..416c2e7 100644 --- a/src/components/Typography.ts +++ b/src/components/Typography.ts @@ -10,4 +10,5 @@ export const Header = styled(Text)` export const SubHeader = styled(Text)` font-size: 24px; margin: 12px 0; + font-weight: 500; `; \ No newline at end of file diff --git a/src/components/WrappableButtonRow.tsx b/src/components/WrappableButtonRow.tsx new file mode 100644 index 0000000..d5d17de --- /dev/null +++ b/src/components/WrappableButtonRow.tsx @@ -0,0 +1,13 @@ +import styled from 'styled-components/native'; +import Button from './Button'; + +export const WrappableButtonRow = styled.View` + flex: 0 0 auto; + flex-direction: row; + flex-wrap: wrap; + margin: 6px -2px; +`; + +export const WrappableButton = styled(Button)` + margin: 2px; +`; \ No newline at end of file diff --git a/src/screens/Music/stacks/components/TrackListView.tsx b/src/screens/Music/stacks/components/TrackListView.tsx index 814f97c..6b5d2ee 100644 --- a/src/screens/Music/stacks/components/TrackListView.tsx +++ b/src/screens/Music/stacks/components/TrackListView.tsx @@ -9,12 +9,12 @@ import { THEME_COLOR } from 'CONSTANTS'; import TouchableHandler from 'components/TouchableHandler'; import useCurrentTrack from 'utility/useCurrentTrack'; import TrackPlayer from 'react-native-track-player'; -import Button from 'components/Button'; import Play from 'assets/play.svg'; import Shuffle from 'assets/shuffle.svg'; import useDefaultStyles from 'components/Colors'; import usePlayTracks from 'utility/usePlayTracks'; import { EntityId } from '@reduxjs/toolkit'; +import { WrappableButtonRow, WrappableButton } from 'components/WrappableButtonRow'; const Screen = Dimensions.get('screen'); @@ -26,7 +26,7 @@ const styles = StyleSheet.create({ artist: { fontSize: 24, opacity: 0.5, - marginBottom: 24 + marginBottom: 12 }, index: { width: 20, @@ -109,10 +109,11 @@ const TrackListView: React.FC = ({ {title} {artist} -