Skip to content

Commit cd69d7c

Browse files
committed
Fix SettingsScreen to not include PlaygroundScreen in Picker
1 parent 5c3076a commit cd69d7c

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

demo/src/screens/SettingsScreen.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@ import _ from 'lodash';
22
import React, {Component} from 'react';
33
import AsyncStorage from '@react-native-community/async-storage';
44
import {StyleSheet, I18nManager} from 'react-native';
5-
import {Colors, View, Text, Picker, Toast, Switch} from 'react-native-ui-lib'; //eslint-disable-line
5+
import {Colors, View, Text, Picker, Incubator, Switch} from 'react-native-ui-lib'; //eslint-disable-line
66
import {navigationData} from './MenuStructure';
77

88
const none = {label: '[None]', value: ''};
9-
const playgroundScreen = {label: 'Playground', value: 'unicorn.PlaygroundScreen'};
109

1110
class SettingsScreen extends Component {
1211
constructor(props) {
1312
super(props);
1413

1514
const data = props.navigationData || navigationData;
16-
const playground = props.playground || playgroundScreen;
15+
const playground = props.playground;
16+
17+
const screens = [
18+
none,
19+
..._.flow(_.values,
20+
screens => _.map(screens, 'screens'),
21+
_.flatten,
22+
screens => _.map(screens, screen => ({label: screen.title, value: screen.screen})))(data)
23+
];
24+
25+
if (playground) {
26+
screens.splice(1, 0, playground);
27+
}
1728

1829
this.state = {
1930
showRefreshMessage: false,
20-
screens: [
21-
none,
22-
playground,
23-
..._.flow(_.values,
24-
screens => _.map(screens, 'screens'),
25-
_.flatten,
26-
screens => _.map(screens, screen => ({label: screen.title, value: screen.screen})))(data)
27-
]
31+
screens
2832
};
2933
}
3034

@@ -107,7 +111,10 @@ class SettingsScreen extends Component {
107111
<Text text30 grey10>
108112
Settings
109113
</Text>
110-
<Toast visible={showRefreshMessage} position="bottom" message="Refresh the app!"/>
114+
<Incubator.Toast
115+
visible={showRefreshMessage}
116+
message={`Default screen set to: ${defaultScreen?.label}. Please refresh the app.`}
117+
/>
111118
</View>
112119
);
113120
}

0 commit comments

Comments
 (0)