-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Heesung/KEPLR-318' into develop
# Conflicts: # apps/mobile/src/stores/ui-config/index.ts
- Loading branch information
Showing
9 changed files
with
772 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
apps/mobile/src/screen/home/components/new-chain-modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import {useStyle} from '../../../../styles'; | ||
import {Platform, SafeAreaView, StatusBar, Text} from 'react-native'; | ||
import {Box} from '../../../../components/box'; | ||
import React, {FunctionComponent} from 'react'; | ||
import {Button} from '../../../../components/button'; | ||
import {IconProps} from '../../../../components/icon/types.ts'; | ||
import Svg, {Path} from 'react-native-svg'; | ||
import {registerModal} from '../../../../components/modal/v2'; | ||
import {FormattedMessage, useIntl} from 'react-intl'; | ||
import {observer} from 'mobx-react-lite'; | ||
import {useStore} from '../../../../stores'; | ||
|
||
export const NewChainModal = registerModal<{ | ||
setIsOpen: (isOpen: boolean) => void; | ||
afterConfirm: () => void; | ||
}>( | ||
observer(({afterConfirm, setIsOpen}) => { | ||
const intl = useIntl(); | ||
const style = useStyle(); | ||
|
||
const {chainStore, uiConfigStore} = useStore(); | ||
|
||
return ( | ||
<SafeAreaView> | ||
<Box | ||
alignY="center" | ||
marginTop={ | ||
Platform.OS === 'android' ? 38 + (StatusBar.currentHeight ?? 0) : 30 | ||
} | ||
marginLeft={10}> | ||
<Box paddingLeft={16}> | ||
<TopArrowIcon size={16} /> | ||
</Box> | ||
<Box | ||
width={300} | ||
maxWidth={300} | ||
paddingX={16} | ||
paddingY={20} | ||
borderRadius={6} | ||
borderColor={style.get('color-gray-500').color} | ||
borderWidth={1} | ||
backgroundColor={style.get('color-gray-600').color}> | ||
<Text style={style.flatten(['subtitle3', 'color-white'])}> | ||
<FormattedMessage | ||
id="page.main.layouts.header.new-chain.title" | ||
values={{ | ||
chains: | ||
uiConfigStore.newChainSuggestionConfig.newSuggestionChains | ||
.map(chain => { | ||
return chainStore.getChain(chain).chainName; | ||
}) | ||
.join(', '), | ||
}} | ||
/> | ||
</Text> | ||
|
||
<Text style={style.flatten(['body2', 'color-gray-200'])}> | ||
<FormattedMessage id="page.main.layouts.header.new-chain.paragraph" /> | ||
</Text> | ||
|
||
<Box alignX="right"> | ||
<Button | ||
text={intl.formatMessage({ | ||
id: 'page.main.layouts.header.new-chain.button', | ||
})} | ||
color="secondary" | ||
onPress={() => { | ||
afterConfirm(); | ||
|
||
if ( | ||
uiConfigStore.newChainSuggestionConfig.newSuggestionChains | ||
.length > 0 | ||
) { | ||
uiConfigStore.newChainSuggestionConfig.turnOffSuggestionChains( | ||
...uiConfigStore.newChainSuggestionConfig | ||
.newSuggestionChains, | ||
); | ||
} | ||
|
||
setIsOpen(false); | ||
}} | ||
/> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</SafeAreaView> | ||
); | ||
}), | ||
{align: 'top', openImmediately: true}, | ||
); | ||
|
||
const TopArrowIcon: FunctionComponent<IconProps> = ({size}) => { | ||
return ( | ||
<Svg width={size} height={size} viewBox="0 0 18 18" fill="none"> | ||
<Path d="M9 2L17 18L1 18L9 2Z" fill="#1D1D1F" stroke="#2E2E32" /> | ||
</Svg> | ||
); | ||
}; |
210 changes: 210 additions & 0 deletions
210
apps/mobile/src/screen/home/components/update-note-modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
import React, {FunctionComponent, useEffect, useState} from 'react'; | ||
import {registerCardModal} from '../../../../components/modal/card'; | ||
import {Box} from '../../../../components/box'; | ||
import {Text} from 'react-native'; | ||
import {useStyle} from '../../../../styles'; | ||
import {HorizontalSimpleScene} from '../../../../components/transition'; | ||
import {Button} from '../../../../components/button'; | ||
import {Gutter} from '../../../../components/gutter'; | ||
import {FormattedMessage} from 'react-intl'; | ||
import * as ExpoImage from 'expo-image'; | ||
import {XAxis} from '../../../../components/axis'; | ||
|
||
export type UpdateNotePageData = { | ||
title: string; | ||
image: | ||
| { | ||
default: string; | ||
light: string; | ||
aspectRatio: string; | ||
} | ||
| undefined; | ||
paragraph: string; | ||
}; | ||
|
||
export const UpdateNoteModal = registerCardModal<{ | ||
isOpen: boolean; | ||
setIsOpen: (isOpen: boolean) => void; | ||
updateNotePageData: UpdateNotePageData[]; | ||
}>(({updateNotePageData, isOpen, setIsOpen}) => { | ||
const [currentScene, setCurrentScene] = useState(0); | ||
|
||
if (updateNotePageData.length === 0) { | ||
return null; | ||
} | ||
|
||
useEffect(() => { | ||
(async () => { | ||
for (const u of updateNotePageData) { | ||
if (u.image) { | ||
await ExpoImage.Image.prefetch(u.image.default); | ||
} | ||
} | ||
})(); | ||
}, [updateNotePageData]); | ||
|
||
return ( | ||
<Box padding={12}> | ||
<HorizontalSimpleScene | ||
currentSceneKey={`${currentScene}`} | ||
scenes={updateNotePageData.map((_, index) => { | ||
return { | ||
key: `${index}`, | ||
element: UpdateNoteScene, | ||
}; | ||
})} | ||
sharedProps={{ | ||
isOpen, | ||
setIsOpen, | ||
currentScene, | ||
setCurrentScene, | ||
updateNotePageData, | ||
}} | ||
/> | ||
|
||
<Gutter size={12} /> | ||
|
||
{(() => { | ||
if (updateNotePageData.length === 1) { | ||
return ( | ||
<Button | ||
text="Close" | ||
size="large" | ||
color="secondary" | ||
onPress={() => setIsOpen(false)} | ||
/> | ||
); | ||
} else { | ||
if (currentScene === 0) { | ||
return ( | ||
<XAxis> | ||
<Button | ||
text="Skip" | ||
size="large" | ||
color="secondary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setIsOpen(false)} | ||
/> | ||
|
||
<Gutter size={12} /> | ||
|
||
<Button | ||
text="Next" | ||
size="large" | ||
color="primary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setCurrentScene(currentScene + 1)} | ||
/> | ||
</XAxis> | ||
); | ||
} | ||
if ( | ||
currentScene > 0 && | ||
currentScene < updateNotePageData.length - 1 | ||
) { | ||
return ( | ||
<XAxis> | ||
<Button | ||
text="Previous" | ||
size="large" | ||
color="secondary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setCurrentScene(currentScene - 1)} | ||
/> | ||
|
||
<Gutter size={12} /> | ||
|
||
<Button | ||
text="Next" | ||
size="large" | ||
color="primary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setCurrentScene(currentScene + 1)} | ||
/> | ||
</XAxis> | ||
); | ||
} | ||
|
||
if (currentScene === updateNotePageData.length - 1) { | ||
return ( | ||
<XAxis> | ||
<Button | ||
text="Previous" | ||
size="large" | ||
color="secondary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setCurrentScene(currentScene - 1)} | ||
/> | ||
|
||
<Gutter size={12} /> | ||
|
||
<Button | ||
text="Close" | ||
size="large" | ||
color="primary" | ||
containerStyle={{flex: 1}} | ||
onPress={() => setIsOpen(false)} | ||
/> | ||
</XAxis> | ||
); | ||
} | ||
} | ||
})()} | ||
</Box> | ||
); | ||
}); | ||
|
||
const UpdateNoteScene: FunctionComponent<{ | ||
currentScene: number; | ||
updateNotePageData: UpdateNotePageData[]; | ||
}> = ({currentScene, updateNotePageData}) => { | ||
const style = useStyle(); | ||
|
||
return ( | ||
<Box paddingX={16}> | ||
<Text style={style.flatten(['h4', 'color-text-high', 'text-center'])}> | ||
<FormattedMessage | ||
id="update-node/paragraph/noop" | ||
defaultMessage={updateNotePageData[currentScene].title} | ||
values={{br: '\n'}} | ||
/> | ||
</Text> | ||
|
||
{updateNotePageData[currentScene].image ? ( | ||
<Box> | ||
<ExpoImage.Image | ||
style={{ | ||
width: '100%', | ||
aspectRatio: updateNotePageData[currentScene].image?.aspectRatio, | ||
}} | ||
alt={updateNotePageData[currentScene].title} | ||
source={updateNotePageData[currentScene].image?.default} | ||
/> | ||
</Box> | ||
) : null} | ||
|
||
{updateNotePageData.length > 1 ? ( | ||
<React.Fragment> | ||
<Text | ||
style={style.flatten([ | ||
'body1', | ||
'color-text-middle', | ||
'text-center', | ||
])}> | ||
{currentScene + 1} / {updateNotePageData.length} | ||
</Text> | ||
|
||
<Gutter size={20} /> | ||
</React.Fragment> | ||
) : null} | ||
|
||
<Text style={style.flatten(['body2', 'color-text-middle'])}> | ||
<FormattedMessage | ||
id="update-node/paragraph/noop" | ||
defaultMessage={updateNotePageData[currentScene].paragraph} | ||
values={{br: '\n'}} | ||
/> | ||
</Text> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.