Skip to content

Commit 54b0865

Browse files
authored
Merge pull request #2189 from StoDevX/credits-custom-icon
Credits icon reflects custom icon
2 parents 7496ef6 + ce33d77 commit 54b0865

File tree

3 files changed

+65
-11
lines changed

3 files changed

+65
-11
lines changed

images/icon-images.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
// @flow
22

33
export const icons = {
4-
oldMain: require('./about/IconTrans.png'),
5-
windmill: require('../ios/AllAboutOlaf/windmill-icon/windmill.png'),
4+
oldMain: require('./about/IconTrans.png'),
5+
windmill: require('../ios/AllAboutOlaf/windmill-icon/windmill.png'),
6+
}
7+
8+
export const defaultIcon = icons.oldMain
9+
10+
// eslint-disable camelcase
11+
export const iosToNamedIconsMap: {[key: string]: $Keys<typeof icons>} = {
12+
icon_type_windmill: 'windmill',
13+
default: 'oldMain',
14+
}
15+
// eslint-enable camelcase
16+
17+
export function lookup(iosIconName: $Keys<typeof iosToNamedIconsMap>): number {
18+
const iconName = iosToNamedIconsMap[iosIconName]
19+
if (!iconName) {
20+
return defaultIcon
21+
}
22+
23+
const icon = icons[iconName]
24+
if (!icon) {
25+
return defaultIcon
26+
}
27+
28+
return icon
629
}

source/views/components/logo.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// @flow
2+
3+
import * as React from 'react'
4+
import * as Icons from '@hawkrives/react-native-alternate-icons'
5+
import glamorous from 'glamorous-native'
6+
7+
import {lookup as getAppIcon} from '../../../images/icon-images'
8+
9+
const LogoImage = glamorous.image({
10+
width: 100,
11+
height: 100,
12+
alignSelf: 'center',
13+
})
14+
15+
type Props = {
16+
style?: StyleSheet,
17+
}
18+
19+
type State = {
20+
icon: number,
21+
}
22+
23+
export class AppLogo extends React.Component<Props, State> {
24+
state = {
25+
icon: getAppIcon('default'),
26+
}
27+
28+
async componentWillMount() {
29+
const name = await Icons.getIconName()
30+
console.warn(name)
31+
this.setState(() => ({icon: getAppIcon(name)}))
32+
}
33+
34+
render() {
35+
console.warn(this.state.icon)
36+
return <LogoImage source={this.state.icon} style={this.props.style} />
37+
}
38+
}

source/views/settings/credits.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@ import {data as credits} from '../../../docs/credits.json'
55
import glamorous from 'glamorous-native'
66
import {Platform} from 'react-native'
77
import {iOSUIKit, material} from 'react-native-typography'
8-
9-
const image = require('../../../images/about/IconTrans.png')
8+
import {AppLogo} from '../components/logo'
109

1110
const Container = glamorous.scrollView({
1211
backgroundColor: c.white,
1312
paddingHorizontal: 5,
1413
paddingVertical: 10,
1514
})
1615

17-
const Logo = glamorous.image({
18-
width: 100,
19-
height: 100,
20-
alignSelf: 'center',
21-
})
22-
2316
const Title = glamorous.text({
2417
textAlign: 'center',
2518
marginTop: 10,
@@ -59,7 +52,7 @@ const formatPeopleList = arr => arr.map(w => w.replace(' ', ' ')).join(' • ')
5952
export default function CreditsView() {
6053
return (
6154
<Container contentInsetAdjustmentBehavior="automatic">
62-
<Logo source={image} />
55+
<AppLogo />
6356

6457
<Title>{credits.name}</Title>
6558
<About>{credits.content}</About>

0 commit comments

Comments
 (0)