Skip to content

Conversation

leonardo2204
Copy link
Contributor

I created this PR to address #32 enhancement.
My previous code from the #37 is also here, so, sorry for the long commit.
I'd suggest taking a look at 2c33eaf for code only of the #32 issue.
I managed the issue addressed by @zawadz88 :

When we go to the previous step? If so, when we then go back to the failed step the regular state should be shown instead of the error state?

Adding a showErrorStateOnBack flag, so the user can choose whether or not to clean the error from the current step when moving back.

The main point I'd like to discuss is when we get an error on "complete" state, do all the necessary steps to get it right and press "complete" again. Currently the callback is correctly fired, but the "error" state is never cleared. Not sure if this should be treated, as most of the cases the user will move forward to another screen.

What are your thoughts on that ?

Thanks!

@zawadz88
Copy link
Contributor

Hi @leonardo2204,
Thanks for the PR!
I have a few comments:

  1. According to the material doc (https://material.io/guidelines/components/steppers.html#steppers-types-of-steps) the tab title should also change to red on error.
  2. Regarding:

Not sure if this should be treated, as most of the cases the user will move forward to another screen.
I guess it should get cleared as well in this scenario.

  1. Showing an error in the tabs should be optional and disabled by default. Enabling this should be probably done via a custom attribute from StepperLayout. The reason for this is that we wouldn't want to change the default behavior for ppl already using this library.
  2. It might be worth adding an option to override the default color of the warning with styles in a similar way you can change the color of the selected tab.

app:srcCompat="@drawable/ic_check"
android:visibility="gone" />

<android.support.v7.widget.AppCompatImageView
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a separate ImageView needed here? Maybe we could use ms_stepDoneIndicator and change the drawable + tint? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about that when developing, but I kinda came to realize that even tough it's an indicator and they will never show at the same time, it just seems better to have two separate views, to apply styling, show and hide.
But it's easily changeable, if you prefer, I'd can do it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm you're about the styling. I guess it would be easier to have two separate views for that :)

<!-- Flag indicating if the Back (Previous step) button should be shown on the first step. False by default. -->
<attr name="ms_showBackButtonOnFirstStep" format="boolean" />

<!-- Flag indicating wheter to keep showing the error state when user moves back. Only available with 'tabs' type. False by default. -->
Copy link
Contributor

Choose a reason for hiding this comment

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

wheter -> whether ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch haha, thanks !

}

//if moving forward and got no errors, set hasError to false, so we can have the tab with the check mark.
if(mStepperType instanceof TabsStepperType)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could replace the if statements with polymorphism i.e. this could be changed to

mStepperType.setErrorStep(mCurrentStepPosition, flag)

by default this would do nothing, but for TabsStepperType this would call:

mTabsContainer.setErrorStep(stepPosition, false); 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've given this a lot of thought also, my solution really is not the best, but I was thinking if adding a flag just to use in one place a good approach here...
Also, it didn't seem to me that in the near future a new kind of tab or something like it would be needed, making a lot of spaghetti 'if's'.

Also it's a no problem to change it !

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi,
I'm considering adding the alternative tabs look so it might be a pain in the a*s to update all those ifs :/
Could you replaced them with the proposed solution so that it's easier to maintain it later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure !

Copy link
Contributor

@zawadz88 zawadz88 left a comment

Choose a reason for hiding this comment

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

Please see the comments

@leonardo2204
Copy link
Contributor Author

About your points:

  1. You got it, I really forgot it.
  2. Sure, totally agree.
  3. Agreed also.
  4. Ok, no problem !

@leonardo2204
Copy link
Contributor Author

Think I got it all covered on my last commit !
Thanks

@zawadz88
Copy link
Contributor

Hi @leonardo2204,
Could you rebase your commits on top of master as a 2.0.0 version was released?
Also, I noticed that ShowErrorOnBackTabActivity does not show the errors - I suppose setShowErrorState should be called?
Could you add a sample where an attribute is used + custom color + maybe a different one were setShowErrorStateOnBack is set to false & setShowErrorState is set to true. The samples are so that we can test this with each update :)

I've also noticed that point 2. from my previous comment is still not covered?

@zawadz88 zawadz88 merged commit cc56792 into stepstone-tech:master Jan 17, 2017
@zawadz88
Copy link
Contributor

Hi @leonardo2204,
Thanks for the PR! I have no further comments and I have to say it's looking good :)

@leonardo2204 leonardo2204 deleted the error_back branch January 17, 2017 13:01
@leonardo2204
Copy link
Contributor Author

Hey @zawadz88 Cool, thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants