Skip to content

Commit

Permalink
Merge branch 'Heesung/KEPLR-318' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/mobile/src/stores/ui-config/index.ts
  • Loading branch information
Thunnini committed Jul 12, 2024
2 parents 9e03eda + 4224ce0 commit f38bf45
Show file tree
Hide file tree
Showing 9 changed files with 772 additions and 8 deletions.
2 changes: 2 additions & 0 deletions apps/mobile/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ module.exports = {
'KEPLR_EXT_TOKEN_FACTORY_BASE_URL',
'KEPLR_EXT_TOKEN_FACTORY_URI',
'KEPLR_EXT_TX_HISTORY_BASE_URL',
'KEPLR_EXT_CONFIG_SERVER',
'WC_PROJECT_ID',
'SKIP_API_KEY',
],
},
],
Expand Down
5 changes: 5 additions & 0 deletions apps/mobile/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@
"page.main.components.token-found-modal.add-token-on-injective-and-evmos": "Add tokens on Injective and Evmos",
"page.main.components.token-found-modal.add-chains": "Add Chains",
"page.main.components.token-item.copy-address.copied": "Copied",

"page.main.layouts.header.new-chain.title": "✨ {chains} Now Integrated!",
"page.main.layouts.header.new-chain.paragraph": "To show the chains and their assets on this account, visit \"Manage Chain Visibility\".",
"page.main.layouts.header.new-chain.button": "Got it!",

"page.main.components.error-modal-title": "Error Message",
"page.main.components.secret-error-modal-button": "Set my Viewing Key",
"page.main.components.staking-chain-modal.title": "Available Assets",
Expand Down
5 changes: 5 additions & 0 deletions apps/mobile/src/languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@
"page.main.components.token-found-modal.add-token-on-injective-and-evmos": "인젝티브와 이브모스의 토큰 추가하기",
"page.main.components.token-found-modal.add-chains": "체인 추가",
"page.main.components.token-item.copy-address.copied": "복사됨",

"page.main.layouts.header.new-chain.title": "{chains} 체인이 추가되었습니다!",
"page.main.layouts.header.new-chain.paragraph": "\"체인 표시\"에서 신규 체인을 활성화하면 이 계정에서 사용할 수 있습니다.",
"page.main.layouts.header.new-chain.button": "좋아요!",

"page.main.components.error-modal-title": "앗! 문제가 생겼어요.",
"page.main.components.secret-error-modal-button": "뷰잉키 설정하러 가기",
"page.main.components.staking-chain-modal.title": "사용 가능한 자산",
Expand Down
98 changes: 98 additions & 0 deletions apps/mobile/src/screen/home/components/new-chain-modal/index.tsx
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 apps/mobile/src/screen/home/components/update-note-modal/index.tsx
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>
);
};
Loading

0 comments on commit f38bf45

Please sign in to comment.