Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
990af6e
Merge pull request #44 from BlueBaseJS/develop
abubakarmani1 Jun 25, 2019
2f1b3f1
fix(fixed issues of picker): fixed picker
Aug 5, 2019
15a901e
fix(fixed picker component): fixed picker component
Aug 5, 2019
10aaaee
fix(fixed issues of component): fixed component
Aug 5, 2019
76d5284
fix(fixed code of picker component in ios): fixed code of picker comp…
Aug 5, 2019
0369a8f
fix(fixed picker component): fixe dpicker component
Aug 6, 2019
be0c152
fix(fixed picker component of react-native-paper): fixed picker com…
Aug 6, 2019
e1aa370
fix(fixed picker component): fixed pciker
Aug 6, 2019
74fd8eb
fix(fixed issue of picker compoennts): fixed picker component
Aug 6, 2019
e4fa21c
test(fixed tests of plugin): fixed picker component
Aug 6, 2019
8d77256
fix(picker): picker component in ios fixed
Aug 6, 2019
a8c57bb
fix(fixed picker component tests): fixed picker component tests
Aug 6, 2019
95516cf
test(test): picker component tests added
Aug 7, 2019
204c5ba
fix(deleted snapshot of test): snapshot deleted
Aug 7, 2019
7721266
fix(picker component): updated issue of picker component
Aug 7, 2019
b6bfa2f
fix(test): fixed tests of plugin
Aug 8, 2019
40bab8d
fix(fixed issues of react-native-picker android): fixed issues of rea…
Aug 15, 2019
a41a06a
test(picker component ): added tests of picker component
Aug 15, 2019
4ce7b10
fix(android modes added): android modes added
Aug 22, 2019
b060099
fix(added android component): fixed android compoent in picker
Aug 22, 2019
a4d6c0d
fix(picker): picker component for ios added
Aug 22, 2019
48c698c
test(picker): added tests of picker
Aug 22, 2019
344b598
fix(picker component): picker component
Aug 26, 2019
27d5f29
fix(fixed issue of picker component): fixed picker component
Aug 26, 2019
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ dist/
.expo

# Jest
.jest
.jest

# storybook Loader
.bluebase/storybook-native/storybook/storyLoader.js
2 changes: 1 addition & 1 deletion bluebase/common/bluebase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
plugins: [
require('../../src') ]
require('../../src')]
};
2 changes: 2 additions & 0 deletions bluebase/storybook-native/storybook/storyLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function loadStories() {
require('../../../src/components/IconButton/__stories__/IconButton.stories');
require('../../../src/components/List.Icon/ListIcon.stories');
require('../../../src/components/List/__stories__/List.stories');
require('../../../src/components/Picker/picker.stories');
Comment thread
adnan1naeem marked this conversation as resolved.
require('../../../src/components/Radio/__stories__/Radio.stories');
require('../../../src/components/RadioGroup/__stories__/RadioGroup.stories');
require('../../../src/components/Switch/__stories__/Switch.stories');
Expand Down Expand Up @@ -53,6 +54,7 @@ const stories = [
'../../../src/components/IconButton/__stories__/IconButton.stories',
'../../../src/components/List.Icon/ListIcon.stories',
'../../../src/components/List/__stories__/List.stories',
'../../../src/components/Picker/picker.stories',
'../../../src/components/Radio/__stories__/Radio.stories',
'../../../src/components/RadioGroup/__stories__/RadioGroup.stories',
'../../../src/components/Switch/__stories__/Switch.stories',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"size-limit": [
{
"limit": "27 KB",
"limit": "30 KB",
"webpack": false,
"path": "dist/**/*.js"
}
Expand Down Expand Up @@ -141,7 +141,7 @@
"size-limit": "^0.21.1",
"trash-cli": "^1.4.0",
"ts-jest": "^24.0.0",
"tslint": "^5.13.1",
"tslint": "5.11.0",
"typedoc": "^0.14.2",
"typescript": "3.4.1"
},
Expand All @@ -156,4 +156,4 @@
"publishConfig": {
"access": "public"
}
}
}
194 changes: 194 additions & 0 deletions src/components/Picker/Picker.android.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import * as React from 'react';

import { List, ListItem, Picker, Text, View, } from '@bluebase/components';
import { Modal, TouchableOpacity, ViewStyle } from 'react-native';

import { Theme } from '@bluebase/core';

export interface ItemsProps {
value: string, label: string
}
export interface PickerStyles {
picker: ViewStyle,
overlay: ViewStyle
actionSheetOverlay: ViewStyle,
}



export interface PickerProps {
items: ItemsProps[],
selectedValue: string,
styles: PickerStyles,
label: string,
mode: 'modal' | 'actionsheet';
onValueChange: (data: string, index: number) => void
}

export interface PickerState {
selectedValueIndex?: number
textStyle?: string
modalVisible?: boolean
selectedValue: string
selected?: string

}
export class PickerComponent extends React.Component<PickerProps, PickerState> {
constructor(props: PickerProps) {
super(props);

this.state = {
modalVisible: false,
selected: '',
selectedValue: '',
};
}

static defaultStyles = (_theme: Theme) => ({
container: {
backgroundColor: '#fff',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are colours hard coded

borderColor: '#ddd',
borderTopWidth: 0.5,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this hard coded

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the colors are hard coded because android does not have any actionsheet effect so just to make it applicable i have made in modal and poped up through bottom

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what happens on dark theme? We cannot hardcode Colors. Or themeing will not work

justifyContent: 'center',
minHeight: 40,
padding: 5,
},
overlay: {
backgroundColor: 'rgba(0,0,0,0.5)',
flex: 1,
justifyContent: 'center',
width: null,
},
actionSheetOverlay: {
backgroundColor: 'rgba(0,0,0,0.5)',
flex: 1,
justifyContent: 'flex-end',
width: null,
},
picker: {
backgroundColor: 'white',
borderColor: '#aaa',
borderTopWidth: 0.5,
padding: 10,
},

})

onValueChange = (data: string, index: number) => {
this.setState({ modalVisible: false, selectedValue: data, selected: data });
this.props.onValueChange(data, index);
}
renderDropdownPicker = () => {
const { items } = this.props;
return (
<Picker
selectedValue={this.state.selected}
onValueChange={this.onValueChange}
>
{
items.map((item: { label: string, value: string }, i: number) =>
<Picker.Item key={i} label={item.label} value={item.value} />
)
}
</Picker>
);
}



renderActionSheetPicker = () => {
const { items, label, styles } = this.props;
return (
<>
<View testID="list-id">
<List>
<List.Item
title={label}
description={<Text>{this.state.selected}</Text>}
onPress={this.dialogHandler}
/>
</List>
</View>
<Modal transparent visible={this.state.modalVisible} animationType="fade">
<TouchableOpacity activeOpacity={1} onPress={this.dialogHandler} style={styles.actionSheetOverlay}>
<View style={styles.picker}>
{
items.map((item: { label: string, value: string }, i: number) => (
<List>
<ListItem key={i} title={item.label} onPress={this.onPressHandler(i)} />
</List>

)
)
}
</View>

</TouchableOpacity>
</Modal>
</>
);
}
onPressHandler = (id: number) => () => {
this.props.items.map((item: { label: string, value: string }, i: number) => {
if (id === i) {
this.setState({ selected: item.label });
}
});
this.dialogHandler();
}

renderPicker = () => {

const picker = { modal: this.renderModalPicker(), actionsheet: this.renderActionSheetPicker() }

return picker[this.props.mode];

}
renderModalPicker = () => {
const { items, label, styles } = this.props;
return (
<>
<View>
<List>
<List.Item
title={label}
description={<Text>{this.state.selected}</Text>}
onPress={this.dialogHandler}
/>
</List>
</View>
<Modal transparent visible={this.state.modalVisible} animationType="fade">
<TouchableOpacity activeOpacity={1} onPress={this.dialogHandler} style={styles.overlay}>
<View style={styles.picker} testID="picker-test">
{
items.map((item: { label: string, value: string }, i: number) => (
<List>
<ListItem key={i} title={item.label} onPress={this.onPressHandler(i)} />
</List>

)
)
}

</View>

</TouchableOpacity>
</Modal>
</>
);
}

dialogHandler = () => {
this.setState({ modalVisible: !this.state.modalVisible });
}

render() {
const { mode } = this.props;
return (
<>
{mode ? this.renderPicker() : this.renderDropdownPicker()}
</>
);
}
}

Loading