Skip to content

Commit 140e0f0

Browse files
Inbal-Tishethanshar
authored andcommitted
Feat/stack aggregator (#541)
* StackAggregator component * StackAggregatorScreen * adjust container height * remove unused const * Adding LayoutAnimation * switching to children * wrapping child with overflow hidden view * moving Card inside the component to control content appearance * adding style options, onPress, button icon * fix Android collapsed issue * cosmetics * adjusting elevation * adjusting elevation * fix for bottom padding * lint fix * removing arrow function from onLayout; moving inline style to StyleSheet
1 parent a5dfdd9 commit 140e0f0

File tree

10 files changed

+380
-10
lines changed

10 files changed

+380
-10
lines changed

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const navigationData = {
3737
{title: 'Pan Listener', tags: 'pan swipe drag listener', screen: 'unicorn.components.PanListenerScreen'},
3838
{title: 'Pan Responder', tags: 'pan swipe drag responder', screen: 'unicorn.components.PanResponderScreen'},
3939
{title: 'Shared Transition', tags: 'shared transition element', screen: 'unicorn.components.SharedTransitionScreen'},
40+
{title: 'Stack Aggregator', tags: 'stack aggregator', screen: 'unicorn.components.StackAggregatorScreen'},
4041
{title: 'TabBar', tags: 'tab bar', screen: 'unicorn.components.TabBarScreen'},
4142
{title: 'Toast', tags: 'toast top bottom snackbar', screen: 'unicorn.components.ToastsScreen'},
4243
{title: 'Wheel Picker Dialog', tags: 'wheel picker dialog', screen: 'unicorn.components.WheelPickerDialogScreen'},

demo/src/screens/PlaygroundScreen.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1+
import _ from 'lodash';
12
import React, {Component} from 'react';
23
import {StyleSheet} from 'react-native';
3-
import {Colors, View, Text} from 'react-native-ui-lib'; //eslint-disable-line
4+
import {View, Text} from 'react-native-ui-lib'; //eslint-disable-line
45

5-
export default class PlaygroundScreen extends Component {
6-
7-
constructor(props) {
8-
super(props);
9-
this.state = {};
10-
}
116

12-
componentDidMount() {}
7+
export default class PlaygroundScreen extends Component {
138

149
render() {
1510
return (
16-
<View flex bg-dark80 center style={styles.container}>
17-
<Text>Unicorn Playground Screen</Text>
11+
<View center bg-dark80 flex>
12+
<Text text50>Playground Screen</Text>
1813
</View>
1914
);
2015
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import _ from 'lodash';
2+
import React, {Component} from 'react';
3+
import {ScrollView} from 'react-native';
4+
import {/* Colors, Typography, */View, Text, Button, StackAggregator} from 'react-native-ui-lib'; //eslint-disable-line
5+
6+
7+
const contents = [
8+
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
9+
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
10+
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
11+
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
12+
]
13+
14+
export default class StackAggregatorScreen extends Component {
15+
16+
onItemPress = (index) => {
17+
console.warn('item pressed: ', index);
18+
}
19+
20+
onPress = (index) => {
21+
console.warn('item\'s button pressed: ', index);
22+
}
23+
24+
renderItem = (item, index) => {
25+
return (
26+
<View key={index} center padding-12>
27+
<Button label={`${index}`} marginB-10 size={'small'} onPress={() => this.onPress(index)}/>
28+
<Text>{contents[index]}</Text>
29+
</View>
30+
);
31+
}
32+
33+
render() {
34+
return (
35+
<ScrollView bg-dark80 keyboardShouldPersistTaps={'handled'} showsVerticalScrollIndicator={false}>
36+
<Text center dark40 text90 marginT-20>Thu, 10 Dec, 11:29</Text>
37+
<StackAggregator
38+
containerStyle={{marginTop: 12}}
39+
onItemPress={this.onItemPress}
40+
>
41+
{_.map(contents, (item, index) => {
42+
return this.renderItem(item, index);
43+
})}
44+
</StackAggregator>
45+
46+
<Text center dark40 text90 marginT-20>Thu, 11 Dec, 13:03</Text>
47+
<StackAggregator
48+
containerStyle={{marginTop: 12}}
49+
onItemPress={this.onItemPress}
50+
collapsed={false}
51+
// contentContainerStyle={{backgroundColor: Colors.red30}}
52+
// itemBorderRadius={10}
53+
// buttonProps={{color: Colors.green30, labelStyle: {...Typography.text80, fontWeight: '500'}}}
54+
>
55+
{_.map(contents, (item, index) => {
56+
return this.renderItem(item, index);
57+
})}
58+
</StackAggregator>
59+
</ScrollView>
60+
);
61+
}
62+
}

demo/src/screens/componentScreens/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import WheelPickerDialogScreen from './WheelPickerDialogScreen';
3131
import SliderScreen from './SliderScreen';
3232
import FloatingButtonScreen from './FloatingButtonScreen';
3333
import ColorPickerScreen from './ColorPickerScreen';
34+
import StackAggregatorScreen from './StackAggregatorScreen';
3435

3536

3637
Navigation.registerComponent('unicorn.components.ActionSheetScreen', () => ActionSheetScreen);
@@ -65,3 +66,4 @@ Navigation.registerComponent('unicorn.components.WheelPickerDialogScreen', () =>
6566
Navigation.registerComponent('unicorn.components.SliderScreen', () => SliderScreen);
6667
Navigation.registerComponent('unicorn.components.FloatingButtonScreen', () => FloatingButtonScreen);
6768
Navigation.registerComponent('unicorn.components.ColorPickerScreen', () => ColorPickerScreen);
69+
Navigation.registerComponent('unicorn.components.StackAggregatorScreen', () => StackAggregatorScreen);

src/components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ module.exports = {
123123
get SharedTransition() {
124124
return require('./sharedTransition').default;
125125
},
126+
get StackAggregator() {
127+
return require('./stackAggregator').default;
128+
},
126129

127130
get Slider() {
128131
return require('./slider').default;
Loading
Loading
Loading

0 commit comments

Comments
 (0)