Skip to content

Commit

Permalink
ADD: Home Screen Layout
Browse files Browse the repository at this point in the history
- Created: ProductList component
- Added: NumberUtils.js
- Added: images for UI
  • Loading branch information
k-cool committed Nov 22, 2021
1 parent 4418cc9 commit 5808e29
Show file tree
Hide file tree
Showing 13 changed files with 736 additions and 11 deletions.
11 changes: 5 additions & 6 deletions algo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable curly */

// solution

function solution(input) {
Expand All @@ -19,9 +21,7 @@ function solution(input) {
};

const getChoSung = char => {
if (!/[-|-|-]/.test(char)) {
return 0;
}
if (!/[-|-|-]/.test(char)) return 0;

const jaEum = [
'ㄱ',
Expand Down Expand Up @@ -54,9 +54,7 @@ function solution(input) {

for (let i = 0; i < input.length; i++) {
const nthChoSung = getChoSung(input.charAt(i));
if (!nthChoSung) {
continue;
}
if (!nthChoSung) continue;
output[nthChoSung] += 1;
}

Expand Down Expand Up @@ -86,4 +84,5 @@ const expectedOutput = {

const output = solution(input);
const result = JSON.stringify(output) === JSON.stringify(expectedOutput);

console.log('resutl: ', result);
Binary file added src/assets/dinoIcon.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 src/assets/favicon.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 src/assets/logo.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 src/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions src/components/HomeScreen/ProductItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from 'react';
import {StyleSheet, TouchableOpacity, Text, View, Image} from 'react-native';

import {addComma} from '../../utils/NumberUtils';

const ProductItem = ({id, title, brand, price}) => {
return (
<TouchableOpacity style={styles.block} activeOpacity={0.5}>
<Image
style={styles.icon}
source={require('../../assets/dinoIcon.png')}
/>
<View style={styles.description}>
<Text style={styles.title}>{title}</Text>
<View style={styles.secondLine}>
<Text style={styles.brand}>{brand}</Text>
<Text style={styles.price}>{addComma(price)}</Text>
</View>
</View>
</TouchableOpacity>
);
};

const styles = StyleSheet.create({
block: {
flex: 0.5,
flexDirection: 'row',
alignItems: 'center',
},

icon: {
width: 50,
height: 50,
marginHorizontal: 5,
resizeMode: 'contain',
},

description: {
flex: 1,
padding: 10,
},

title: {
fontSize: 18,
},

secondLine: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 10,
},

brand: {
fontWeight: '600',
},

price: {
// marginRight: 10,
fontSize: 15,
},
});

export default ProductItem;
26 changes: 26 additions & 0 deletions src/components/HomeScreen/ProductList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import {StyleSheet, FlatList, View} from 'react-native';
import ProductItem from './ProductItem';

const ProductList = ({products}) => {
return (
<FlatList
style={styles.list}
data={products}
renderItem={({item}) => <ProductItem {...item} />}
keyExtractor={item => item.id}
ItemSeparatorComponent={() => <View style={styles.separator} />}
/>
);
};

const styles = StyleSheet.create({
list: {},

separator: {
height: 1,
backgroundColor: 'lightgrey',
},
});

export default ProductList;
Loading

0 comments on commit 5808e29

Please sign in to comment.