Skip to content

Infra/expo app fixes #1166

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

Merged
merged 16 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module.exports = {
get CheckboxScreen() {
return require('./screens/componentScreens/CheckboxScreen').default;
},
get ChipScreen() {
return require('./screens/componentScreens/ChipScreen').default;
},
get ConnectionStatusBarScreen() {
return require('./screens/componentScreens/ConnectionStatusBarScreen').default;
},
Expand Down Expand Up @@ -206,6 +209,10 @@ module.exports = {
get ProgressBarScreen() {
return require('./screens/componentScreens/ProgressBarScreen').default;
},
// Incubator
get IncubatorTextFieldScreen() {
return require('./screens/incubatorScreens/IncubatorTextFieldScreen').default;
},
// realExamples
get AppleMusic() {
return require('./screens/realExamples/AppleMusic').default;
Expand Down
Empty file removed expoDemo/.expo/README.md
Empty file.
10 changes: 0 additions & 10 deletions expoDemo/.expo/packager-info.json

This file was deleted.

9 changes: 0 additions & 9 deletions expoDemo/.expo/settings.json

This file was deleted.

5 changes: 5 additions & 0 deletions expoDemo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ buck-out/

# Bundle artifact
*.jsbundle

# Expo
.expo
__generated__
web-build
1 change: 1 addition & 0 deletions expoDemo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import _ from 'lodash';
import {screens} from 'unicorn-demo-app';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import './src/assets';
import MainScreen from './MainScreen';

const Stack = createStackNavigator();
Expand Down
142 changes: 94 additions & 48 deletions expoDemo/MainScreen.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,105 @@
import React from 'react';
import {ScrollView, TextInput} from 'react-native';
import {Colors, View, Text, TouchableOpacity} from 'react-native-ui-lib';
import React, {useCallback} from 'react';
import {SectionList, StyleSheet} from 'react-native';
import {Colors, View, Text, TouchableOpacity, Spacings, Image, Assets, Incubator} from 'react-native-ui-lib';
import {menuStructure} from 'unicorn-demo-app';
import _ from 'lodash';
import fuzzysearch from 'fuzzysearch';

const {TextField} = Incubator;

const sections = _.map(menuStructure, (section, key) => {
return {
key,
data: section.screens
};
});

export default function MainScreen({navigation}) {
const [searchText, setSearchText] = React.useState('');

const includedInSearch = (text = '') => {
return fuzzysearch(searchText.toLowerCase(), text.toLowerCase());
};

const onItemPress = useCallback(({customValue: screenId}) => {
// convert "unicorn.components.ActionBarScreen" -> "ActionBar"
navigation.navigate(screenId);
});

const renderSectionHeader = useCallback(({section}) => {
if (!_.find(section.data, screen => includedInSearch(screen.title))) {
return null;
}

return (
<View paddingV-s1 paddingH-s5 bg-primary>
<Text text90BO uppercase grey70>
{section.key}
</Text>
</View>
);
},
[searchText]);

const renderItem = useCallback(({item}) => {
if (!includedInSearch(item.title)) {
return null;
}

if (!item.title) {
return <View height={Spacings.s2} bg-grey70/>;
}

const screenId = _.chain(item.screen).split('.').last().replace('Screen', '').value();

return (
<TouchableOpacity
activeOpacity={1}
key={item.title}
style={styles.sectionItem}
activeBackgroundColor={Colors.violet80}
customValue={screenId}
onPress={onItemPress}
>
<Text grey10 text70M>
{item.title}
</Text>
</TouchableOpacity>
);
},
[searchText]);

return (
<View>
<TextInput
style={{padding: 10, marginBottom:0, fontSize: 18}}
placeholder= 'Search for your component...'
onChangeText={text => setSearchText(text)}
value={searchText}
<View flex bg-white>
<SectionList
ListHeaderComponent={
<TextField
migrate
placeholder="Search component name"
onChangeText={text => setSearchText(text)}
value={searchText}
preset={null}
text70
fieldStyle={styles.fieldStyle}
leadingAccessory={<Image source={Assets.icons.search} marginH-s2/>}
/>
}
sections={sections}
renderSectionHeader={renderSectionHeader}
renderItem={renderItem}
/>
<ScrollView>
<View bg-white>
{_.map(menuStructure, section => {
return (
<View key={section.title}>
<Text text50 marginL-s5 marginV-s3>
{section.title}
</Text>
{_.map(section.screens, screen => {
return (
<TouchableOpacity
activeOpacity={1}
bg-blue40
paddingH-s5
paddingV-s4
key={screen.title}
activeBackgroundColor={Colors.blue20}
style={{borderBottomWidth: 1, borderColor: Colors.white}}
onPress={() => {
// convert "unicorn.components.ActionBarScreen" -> "ActionBar"
const screenId = _.chain(screen.screen)
.split('.')
.last()
.replace('Screen', '')
.value();
navigation.navigate(screenId);
}}
>
<Text white text70M>
{screen.title}
</Text>
</TouchableOpacity>
);
}).filter(item => item.key.toLowerCase().indexOf(searchText.toLowerCase()) !== -1)}
</View>
);
})}
</View>
</ScrollView>
</View>
);
}

const styles = StyleSheet.create({
fieldStyle: {
paddingVertical: Spacings.s3
},
sectionItem: {
borderBottomWidth: 1,
borderBottomColor: Colors.grey60,
paddingHorizontal: Spacings.s5,
paddingVertical: Spacings.s3
}
});
2 changes: 1 addition & 1 deletion expoDemo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "rnuilib",
"slug": "rnuilib",
"privacy": "public",
"icon": "https://user-images.githubusercontent.com/1780255/76164954-b97b3880-615b-11ea-85b9-209ac7932d89.png",
"icon": "https://user-images.githubusercontent.com/1780255/107911939-34e98a80-6f66-11eb-91a6-1eb1b384e429.png",
"version": "1.0.0",
"entryPoint": "index.js",
"packagerOpts": {
Expand Down
1 change: 1 addition & 0 deletions expoDemo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@react-navigation/native": "^5.0.8",
"@react-navigation/stack": "^5.1.0",
"expo": "^40.0.0",
"fuzzysearch": "^1.0.3",
"lodash": "^4.17.15",
"react": "16.13.1",
"react-dom": "16.13.1",
Expand Down
Binary file added expoDemo/src/assets/chevronRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions expoDemo/src/assets/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Assets} from 'react-native-ui-lib';

Assets.loadAssetsGroup('', {
chevronRight: require('./chevronRight.png'),
search: require('./search.png')
});
Binary file added expoDemo/src/assets/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added expoDemo/src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.