Skip to content
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

Merged
merged 1 commit into from
Mar 13, 2018
Merged

ui-components: integration of modal in native #17

merged 1 commit into from
Mar 13, 2018

Conversation

gadjevb
Copy link

@gadjevb gadjevb commented Feb 6, 2018

Integration of a simple modal component in the native part, so it can be later reused in the different apps.

Fixes #16
modaldemo

<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>
Copy link

@p-nedelchev p-nedelchev Feb 6, 2018

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?

Copy link
Author

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.

Copy link
Member

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

<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>
Copy link
Member

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

}
}

show() {
Copy link
Contributor

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".

Copy link
Member

Choose a reason for hiding this comment

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

.

this.setState({ visible: true })
}

close() {
Copy link
Contributor

Choose a reason for hiding this comment

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

.

Copy link
Member

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 ?

Copy link
Contributor

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()

@gadjevb
Copy link
Author

gadjevb commented Feb 6, 2018

Requested changes are made.

@p-nedelchev
Copy link

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?

@mgenov
Copy link
Member

mgenov commented Feb 20, 2018

Do we have cases with such usages ?

>
<View style={this.props.containerStyles}>
<View style={this.props.bodyStyles}>
<ScrollView>{children}</ScrollView>

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>

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
  }
}

Copy link
Contributor

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?

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.

@p-nedelchev
Copy link

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)

@martinmilev
Copy link
Contributor

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()
          }
        }
      })

@gadjevb
Copy link
Author

gadjevb commented Feb 20, 2018

PR is rebased and integrated into storybook. Should opening with flag be implemented?

@martinmilev
Copy link
Contributor

Write README.md with description.

<View style={this.props.bodyStyles}>
{this.props.hasCloseHeader && (
<View style={this.props.headerStyles}>
<TouchableOpacity onPress={() => this.setState({ visible: false })}>
Copy link
Contributor

Choose a reason for hiding this comment

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

this.close() ?

if (child.type === Trigger) {
return React.cloneElement(child, {
onShowDialog: () => {
this.setState({ visible: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

this.show()

@gadjevb
Copy link
Author

gadjevb commented Feb 20, 2018

Flag for opening the modal is included.

@gadjevb
Copy link
Author

gadjevb commented Feb 20, 2018

I'm not able to hide the StatusBar, I think it's a bug with react native. Here's some more info:
facebook/react-native#7474 - Issue about the problem.
facebook/react-native#18004 - PR for the issue opened 3 days ago.

@mgenov
Copy link
Member

mgenov commented Feb 20, 2018

Ok, as it's just for the example we can live with that for now.

@gadjevb
Copy link
Author

gadjevb commented Feb 20, 2018

Ready for a review!

import Modal from './Modal'

describe('(Modal) rendering', () => {
it('should render Modal component', () => {
Copy link
Member

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

@gadjevb
Copy link
Author

gadjevb commented Mar 13, 2018

All requested changes are fixed.


### Usage
```
<Modal
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

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.

Copy link
Contributor

@martinmilev martinmilev left a 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
@gadjevb
Copy link
Author

gadjevb commented Mar 13, 2018

@mgenov requested changes are fixed.

Copy link
Member

@mgenov mgenov left a comment

Choose a reason for hiding this comment

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

LGTM !

@mgenov mgenov merged commit 5996216 into clouway:master Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants