toga icon indicating copy to clipboard operation
toga copied to clipboard

Implemented Divider widget on iOS and fixed bug on Android

Open proneon267 opened this issue 1 year ago • 5 comments

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

proneon267 avatar Apr 03 '24 11:04 proneon267

Thanks! I'll complete them and get back to you soon.

proneon267 avatar Apr 04 '24 02:04 proneon267

Done!

proneon267 avatar Apr 04 '24 02:04 proneon267

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.

proneon267 avatar Apr 04 '24 16:04 proneon267

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?

proneon267 avatar Apr 05 '24 00:04 proneon267

So, should TRANSPARENT mean 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:

  1. a corresponding change in tests; or
  2. An explanation for why the previous behavior was untested; or
  3. 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_transparent on 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.

freakboy3742 avatar Apr 05 '24 01:04 freakboy3742

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?

proneon267 avatar Aug 22 '24 00:08 proneon267

Done :)

proneon267 avatar Aug 22 '24 09:08 proneon267