-
Notifications
You must be signed in to change notification settings - Fork 1
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
ui-components: integration of modal in native #17
ui-components: integration of modal in native #17
Conversation
native/TEST-REACT-NATIVE.xml
Outdated
<testcase classname="Alert Componenent -should render text" name="Alert Componenent -should render text" time="0.139"> | ||
<testsuite name="/src/Modal/Modal.spec.js" tests="2" errors="0" failures="0" skipped="0" timestamp="2018-02-05T11:27:21" time="0.837"> | ||
<testcase classname="(Modal) rendering-should render Modal component" name="(Modal) rendering-should render Modal component" time="0.248"> | ||
</testcase> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I missed that part but why we push test reporting XML in the repository?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange, git is showing them as ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added before to be added to .gitignore. This file should be removed and name of the generated test results file should be improved a bit as TEST-REACT_NATIVE.xml doesn't sound good.
// file with test results of the native package
TEST-RESULTS-NATIVE.xml
native/TEST-REACT-NATIVE.xml
Outdated
<testcase classname="Alert Componenent -should render text" name="Alert Componenent -should render text" time="0.139"> | ||
<testsuite name="/src/Modal/Modal.spec.js" tests="2" errors="0" failures="0" skipped="0" timestamp="2018-02-05T11:27:21" time="0.837"> | ||
<testcase classname="(Modal) rendering-should render Modal component" name="(Modal) rendering-should render Modal component" time="0.248"> | ||
</testcase> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added before to be added to .gitignore. This file should be removed and name of the generated test results file should be improved a bit as TEST-REACT_NATIVE.xml doesn't sound good.
// file with test results of the native package
TEST-RESULTS-NATIVE.xml
native/src/Modal/Modal.js
Outdated
} | ||
} | ||
|
||
show() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open() ?
You should write a story using these functions with "ref".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
native/src/Modal/Modal.js
Outdated
this.setState({ visible: true }) | ||
} | ||
|
||
close() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinmilev you mean close to become hide or something else you have in mind ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I think naming can be improved.
show(), hide()
or
open(), close()
Requested changes are made. |
Can you consider modal to be opened with a flag like RN Modal there are some cases when you can't use trigger or refs? |
Do we have cases with such usages ? |
native/src/Modal/Modal.js
Outdated
> | ||
<View style={this.props.containerStyles}> | ||
<View style={this.props.bodyStyles}> | ||
<ScrollView>{children}</ScrollView> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the body of the modal component in the signer project there is header with cross icon which closes the modal. It's being used for troubles and tasks.
Here is how it looks:
<View style={this.props.containerStyles}>
<View style={this.props.bodyStyles}>
{this.props.hasCloseHeader && (
<View style={this.props.headerStyles}>
<Icon
name={'close'}
type={'material-community'}
onPress={() => this.setState({ visible: false })}
/>
</View>
)}
<ScrollView>{children}</ScrollView>
</View>
</View>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also has default props:
Modal.defaultProps = {
hasCloseHeader: false,
headerStyles: {
flexDirection: 'row',
justifyContent: 'flex-end',
margin: 0,
padding: 0,
borderBottomWidth: 0
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be named something easier to remember like "closeButton" and have better styling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, modify it as you wish.
Actually yes at least when I was migrating activate assets modal there should be opened when a specific error occurred so I can't use a trigger or can't call ref from the reducer. At least that's the way I could solve this so I change the modal in my PR (please have a look https://github.com/clouway/telcong.wss/pull/539/files#diff-674edb0335cb7e016ff6c534ecfa05bdR58) |
return React.cloneElement(child, {
onPress: () => {
if (typeof onPressCall === 'function') {
if (onPressCall.then !== undefined) {
onPressCall()
.then(result => {
this.props.onShowDialog()
return Promise.resolve(result)
})
.catch(error => {
return Promise.reject(error)
})
} else {
onPressCall()
this.props.onShowDialog()
}
} else {
this.props.onShowDialog()
}
}
}) |
PR is rebased and integrated into storybook. Should opening with flag be implemented? |
Write README.md with description. |
native/src/Modal/Modal.js
Outdated
<View style={this.props.bodyStyles}> | ||
{this.props.hasCloseHeader && ( | ||
<View style={this.props.headerStyles}> | ||
<TouchableOpacity onPress={() => this.setState({ visible: false })}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.close() ?
native/src/Modal/Modal.js
Outdated
if (child.type === Trigger) { | ||
return React.cloneElement(child, { | ||
onShowDialog: () => { | ||
this.setState({ visible: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.show()
Flag for opening the modal is included. |
I'm not able to hide the StatusBar, I think it's a bug with react native. Here's some more info: |
Ok, as it's just for the example we can live with that for now. |
Ready for a review! |
import Modal from './Modal' | ||
|
||
describe('(Modal) rendering', () => { | ||
it('should render Modal component', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- should render Modal component with header.
As I remember there was an issue with shallow/mount rendering and ref statements, but there should be also cases like:
- show modal using ref
- hide modal using ref
All requested changes are fixed. |
native/src/Modal/README.md
Outdated
|
||
### Usage | ||
``` | ||
<Modal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this means that the story.js couldn't be used as example ?
The storybook may have a plugin for code example which to be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storybook could be used as an example. We thought that if we include README.md it would provide an additional source of information if someone prefers it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this means that the code in README.md and code in the story book should be maintained at the same time, e.g 2 things to maintain with the same information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will remove the README.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Integration of a simple modal component in the native part, so it can be later reused in the different apps. Fixes #16
@mgenov requested changes are fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
Integration of a simple modal component in the native part, so it can be later reused in the different apps.
Fixes #16
