Implemented Divider widget on iOS and fixed bug on Android
Implemented the divider widget on iOS. I have also enabled divider widget test for iOS and updated the support matrix. Here is the example divider app:
PR Checklist:
- [x] All new features have been tested
- [x] All new features have been documented
- [x] I have read the CONTRIBUTING.md file
- [x] I will abide by the code of conduct
Thanks! I'll complete them and get back to you soon.
Done!
The test was failing because of a bug in Android's set_background_simple() where it wasn't actually setting the color to transparent. I have fixed it.
This is changing the behaviour of the set_background_simple, not changing the probe to expect a different value because of the implementation of divider. The fact that you're able to make a fairly radical change to the implementation of a method that is used in many other widgets without also changing tests is a major red flag. The only way I can see this passing is if the default background for all the widgets that use set_background_simple is TRANSPARENT.
I think on Android, divider widget is the only one that is explicitly setting a background color on initialization: https://github.com/beeware/toga/blob/1b96ca1afed7867c9a60ed6dcb4e86821658a04c/android/src/toga_android/widgets/divider.py#L13-L14
Hence, the default background is also not transparent: https://github.com/beeware/toga/blob/1b96ca1afed7867c9a60ed6dcb4e86821658a04c/android/src/toga_android/widgets/base.py#L138-L142
So, should TRANSPARENT mean the default color that the widget sets or actual transparency?
You can get to the bottom of what background=TRANSPARENT means...
Does that mean enabling test_background_transparent on all widgets and then checking for errors?
So, should
TRANSPARENTmean the default color that the widget sets or actual transparency?
It depends what you're proposing. Right now, the implementation is clearly saying the background_color=TRANSPARENT resets to the default.
I completely agree that this isn't a great interpretation, and I agree this should be addressed. Modifying this behavior is a reasonable change to propose. However, it is a change in behavior. You cannot change behavior without either:
- a corresponding change in tests; or
- An explanation for why the previous behavior was untested; or
- a very good explanation for why the behaviour can't be tested at all.
You can get to the bottom of what background=TRANSPARENT means...
Does that mean enabling
test_background_transparenton all widgets and then checking for errors?
Yes.
In addition, you need to verify that test_background_transparent is actually testing transparency - because at present, it clearly isn't, at least in the Android case.
Since, we've established in #2667, that the background color of a Divider widget shouldn't be allowed to change, so I have removed any such changes from this PR. Can this be merged now?
Done :)