-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI redesign part 4 #883
base: UI-redesign-part3
Are you sure you want to change the base?
UI redesign part 4 #883
Changes from 21 commits
4ab610b
b02a778
12d5e7f
ce751ae
7462668
ba58ce9
ec52509
96528b5
fff2d49
d0f26b0
690aa7b
7fdfa69
55eb0f5
d355c71
b790895
c1d81bb
d3c078e
edc2b33
e79ea23
33c142e
7ee0f08
86333c9
dc67ec7
0b44911
2d6d313
0598baa
ed21fc6
9b049fd
dfa571b
1604e49
85ed15c
5013d84
842f5fa
4c6d4d5
da2baa6
f3b4bcb
d6ebad8
3fe8b5f
ac36054
e2aa938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2018 - 2024 The Alephium Authors | ||
This file is part of the alephium project. | ||
The library is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
The library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with the library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { ReactNode } from 'react' | ||
import { StyleProp, ViewStyle } from 'react-native' | ||
import styled from 'styled-components/native' | ||
|
||
interface RoundedCardProps { | ||
children: ReactNode | ||
style?: StyleProp<ViewStyle> | ||
} | ||
|
||
const RoundedCard = ({ children, style }: RoundedCardProps) => ( | ||
<RoundedCardContainer style={style}>{children}</RoundedCardContainer> | ||
) | ||
|
||
export default RoundedCard | ||
|
||
const RoundedCardContainer = styled.View` | ||
border-radius: 38px; | ||
overflow: hidden; | ||
background-color: ${({ theme }) => theme.bg.primary}; | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,10 @@ along with the library. If not, see <http://www.gnu.org/licenses/>. | |
*/ | ||
|
||
import { BottomTabBarProps } from '@react-navigation/bottom-tabs' | ||
import { Canvas, LinearGradient, Rect, vec } from '@shopify/react-native-skia' | ||
import { colord } from 'colord' | ||
import { LinearGradient } from 'expo-linear-gradient' | ||
import { useState } from 'react' | ||
import { LayoutChangeEvent, StyleProp, useWindowDimensions, View, ViewStyle } from 'react-native' | ||
import { LayoutChangeEvent, Platform, StyleProp, View, ViewStyle } from 'react-native' | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context' | ||
import styled, { css, useTheme } from 'styled-components/native' | ||
|
||
|
@@ -30,13 +30,14 @@ interface FooterMenuProps extends BottomTabBarProps { | |
style?: StyleProp<ViewStyle> | ||
} | ||
|
||
const isIos = Platform.OS === 'ios' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we have this in other places too. Let's extract it to a util somewhere or just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
const FooterMenu = ({ state, descriptors, navigation, style }: FooterMenuProps) => { | ||
const insets = useSafeAreaInsets() | ||
const { width: screenWidth } = useWindowDimensions() | ||
const theme = useTheme() | ||
const [footerHeight, setFooterHeight] = useState(120) | ||
|
||
const gradientHeight = footerHeight + 30 | ||
const gradientHeight = footerHeight + 50 | ||
|
||
const footerContent = ( | ||
<> | ||
|
@@ -54,25 +55,26 @@ const FooterMenu = ({ state, descriptors, navigation, style }: FooterMenuProps) | |
) | ||
|
||
const handleFooterLayout = (e: LayoutChangeEvent) => { | ||
setFooterHeight(e.nativeEvent.layout.height + insets.bottom) | ||
setFooterHeight(e.nativeEvent.layout.height) | ||
} | ||
|
||
return ( | ||
<View style={style} onLayout={handleFooterLayout}> | ||
<FooterGradientCanvas pointerEvents="none" height={gradientHeight}> | ||
<Rect x={0} y={0} width={screenWidth} height={gradientHeight}> | ||
<LinearGradient | ||
start={vec(0, gradientHeight / 1.9)} | ||
end={vec(0, 0)} | ||
colors={ | ||
theme.name === 'dark' | ||
? [theme.bg.back2, colord(theme.bg.back2).alpha(0).toHex()] | ||
: [theme.bg.highlight, colord(theme.bg.highlight).alpha(0).toHex()] | ||
} | ||
/> | ||
</Rect> | ||
</FooterGradientCanvas> | ||
<FooterMenuContent style={{ paddingBottom: insets.bottom }}>{footerContent}</FooterMenuContent> | ||
<FooterGradient | ||
start={{ x: 0.5, y: 1 }} | ||
end={{ x: 0.5, y: 0 }} | ||
locations={[0.45, 1]} | ||
colors={ | ||
theme.name === 'dark' | ||
? [theme.bg.back2, colord(theme.bg.back2).alpha(0).toHex()] | ||
: [theme.bg.highlight, colord(theme.bg.highlight).alpha(0).toHex()] | ||
} | ||
style={{ height: gradientHeight }} | ||
pointerEvents="none" | ||
/> | ||
<FooterMenuContent style={{ paddingBottom: isIos ? insets.bottom : insets.bottom + 18 }}> | ||
{footerContent} | ||
</FooterMenuContent> | ||
</View> | ||
) | ||
} | ||
|
@@ -97,10 +99,10 @@ const FooterMenuContent = styled.View` | |
${footerMenuStyles} | ||
` | ||
|
||
const FooterGradientCanvas = styled(Canvas)<{ height: number }>` | ||
// Bottom value is to avoid glitch on Android | ||
const FooterGradient = styled(LinearGradient)` | ||
position: absolute; | ||
bottom: 0; | ||
bottom: -1px; | ||
left: 0; | ||
right: 0; | ||
height: ${({ height }) => height}px; | ||
` |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,7 +16,11 @@ You should have received a copy of the GNU Lesser General Public License | |||||||||||||||||||||||
along with the library. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import { colord } from 'colord' | ||||||||||||||||||||||||
import { getStringAsync } from 'expo-clipboard' | ||||||||||||||||||||||||
import { LinearGradient } from 'expo-linear-gradient' | ||||||||||||||||||||||||
import { ReactNode, RefObject, useEffect, useRef, useState } from 'react' | ||||||||||||||||||||||||
import { useTranslation } from 'react-i18next' | ||||||||||||||||||||||||
import { | ||||||||||||||||||||||||
NativeSyntheticEvent, | ||||||||||||||||||||||||
StyleProp, | ||||||||||||||||||||||||
|
@@ -31,6 +35,7 @@ import styled, { css, useTheme } from 'styled-components/native' | |||||||||||||||||||||||
|
||||||||||||||||||||||||
import { fastSpringConfiguration } from '~/animations/reanimated/reanimatedAnimations' | ||||||||||||||||||||||||
import AppText from '~/components/AppText' | ||||||||||||||||||||||||
import Button from '~/components/buttons/Button' | ||||||||||||||||||||||||
import Row from '~/components/Row' | ||||||||||||||||||||||||
import { BORDER_RADIUS } from '~/style/globalStyle' | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -44,6 +49,7 @@ export interface InputProps<T extends InputValue> extends Omit<TextInputProps, ' | |||||||||||||||||||||||
resetDisabledColor?: boolean | ||||||||||||||||||||||||
RightContent?: ReactNode | ||||||||||||||||||||||||
renderValue?: RenderValueFunc<T> | ||||||||||||||||||||||||
showPasteButton?: boolean | ||||||||||||||||||||||||
error?: string | ||||||||||||||||||||||||
style?: StyleProp<ViewStyle> | ||||||||||||||||||||||||
layout?: AnimatedProps<ViewProps>['layout'] | ||||||||||||||||||||||||
|
@@ -60,13 +66,16 @@ const Input = <T extends InputValue>({ | |||||||||||||||||||||||
resetDisabledColor, | ||||||||||||||||||||||||
RightContent, | ||||||||||||||||||||||||
renderValue, | ||||||||||||||||||||||||
showPasteButton, | ||||||||||||||||||||||||
error, | ||||||||||||||||||||||||
layout, | ||||||||||||||||||||||||
inputRef, | ||||||||||||||||||||||||
...props | ||||||||||||||||||||||||
}: InputProps<T>) => { | ||||||||||||||||||||||||
const { t } = useTranslation() | ||||||||||||||||||||||||
const theme = useTheme() | ||||||||||||||||||||||||
const [isActive, setIsActive] = useState(false) | ||||||||||||||||||||||||
const [copiedText, setCopiedText] = useState('') | ||||||||||||||||||||||||
const localInputRef = useRef<TextInput>(null) | ||||||||||||||||||||||||
const usedInputRef = inputRef || localInputRef | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -81,6 +90,15 @@ const Input = <T extends InputValue>({ | |||||||||||||||||||||||
fontSize: withSpring(!isActive ? 15 : 11, fastSpringConfiguration) | ||||||||||||||||||||||||
})) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||
const fetchCopiedText = async () => { | ||||||||||||||||||||||||
const text = await getStringAsync() | ||||||||||||||||||||||||
setCopiedText(text) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
fetchCopiedText() | ||||||||||||||||||||||||
}) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dependency array is missing. Also, I started preferring this pattern, WDYT?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also like it better I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to the pattern you proposed |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||
if (renderedValue) { | ||||||||||||||||||||||||
setIsActive(true) | ||||||||||||||||||||||||
|
@@ -97,6 +115,10 @@ const Input = <T extends InputValue>({ | |||||||||||||||||||||||
onBlur && onBlur(e) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing dependency array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code has been removed |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
const handlePasteButtonPress = () => { | ||||||||||||||||||||||||
usedInputRef.current?.setNativeProps({ text: copiedText }) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||
<Row | ||||||||||||||||||||||||
onPress={onPress} | ||||||||||||||||||||||||
|
@@ -129,6 +151,19 @@ const Input = <T extends InputValue>({ | |||||||||||||||||||||||
hide={showCustomValueRendering} | ||||||||||||||||||||||||
{...props} | ||||||||||||||||||||||||
/> | ||||||||||||||||||||||||
{copiedText && showPasteButton && ( | ||||||||||||||||||||||||
<PasteButtonContainer> | ||||||||||||||||||||||||
<PasteButtonContainerBackground | ||||||||||||||||||||||||
colors={[colord(theme.bg.highlight).alpha(0.1).toHex(), theme.bg.highlight]} | ||||||||||||||||||||||||
start={{ x: 0, y: 0.5 }} | ||||||||||||||||||||||||
end={{ x: 1, y: 0.5 }} | ||||||||||||||||||||||||
locations={[0, 0.2]} | ||||||||||||||||||||||||
/> | ||||||||||||||||||||||||
<Button compact onPress={handlePasteButtonPress}> | ||||||||||||||||||||||||
<AppText>{t('Paste')}</AppText> | ||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||
</PasteButtonContainer> | ||||||||||||||||||||||||
)} | ||||||||||||||||||||||||
</InputContainer> | ||||||||||||||||||||||||
{RightContent} | ||||||||||||||||||||||||
{error && ( | ||||||||||||||||||||||||
|
@@ -205,3 +240,20 @@ const Error = styled(AppText)` | |||||||||||||||||||||||
font-size: 11px; | ||||||||||||||||||||||||
` | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const PasteButtonContainer = styled.View` | ||||||||||||||||||||||||
position: absolute; | ||||||||||||||||||||||||
right: 0; | ||||||||||||||||||||||||
top: 0; | ||||||||||||||||||||||||
bottom: 0; | ||||||||||||||||||||||||
align-items: center; | ||||||||||||||||||||||||
justify-content: center; | ||||||||||||||||||||||||
` | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const PasteButtonContainerBackground = styled(LinearGradient)` | ||||||||||||||||||||||||
position: absolute; | ||||||||||||||||||||||||
right: 0; | ||||||||||||||||||||||||
left: 0; | ||||||||||||||||||||||||
top: 0; | ||||||||||||||||||||||||
bottom: 0; | ||||||||||||||||||||||||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern we've used so far is
RoundedCardStyled
for this sort of componentsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done