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

Fix margins in ListView #3281

Open
wants to merge 5 commits into
base: ucr
Choose a base branch
from
Open

Fix margins in ListView #3281

wants to merge 5 commits into from

Conversation

patryk84a
Copy link
Contributor

General items:

If your code changes how something works on the device (i.e., it affects the companion):

  • I branched from ucr
  • My pull request has ucr as the base

Further, if you've changed the blocks language or another user-facing designer/blocks API (added a SimpleProperty, etc.):

  • I have updated the corresponding version number in YaVersion.java
  • I have updated the corresponding upgrader in YoungAndroidFormUpgrader.java (components only)
  • I have updated the corresponding entries in versioning.js

For all other changes:

  • I branched from master
  • My pull request has master as the base

What does this PR accomplish?

Description

There was no implementation for setting margins in the horizontal layout of ListView. Therefore, the horizontal layout displayed margins incorrectly, adjusting them as for the vertical layout.

@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

@patryk84a patryk84a changed the base branch from master to ucr December 8, 2024 20:42
@patryk84a
Copy link
Contributor Author

Why do I have 3 additional commits in this PR?

  • I synced my fork's ucr branch with mit ucr
  • I created a fix_margins branch from my fork ucr
  • I made changes to the file and committed them to my fork's fix_margins
  • then I created a PR

Did something go wrong or is this how it should be?

@patryk84a patryk84a changed the title Fix margins Fix margins in ListView Dec 8, 2024
@ewpatton ewpatton requested a review from a team December 10, 2024 00:51
@ewpatton
Copy link
Member

@AppInventorWorkerBee ok to test

@ewpatton
Copy link
Member

@patryk84a It looks like because you used the Github-based merge (which creates a merge commit by default), your ucr branch got a bit out of sync with ours. Don't worry about this as we will squash merge this PR into a single commit once approved.

@patryk84a
Copy link
Contributor Author

What do I need to do to revert my fork's ucr branch to its original state for future reference? Because now it shows me it's in sync.

@ewpatton
Copy link
Member

ewpatton commented Dec 11, 2024

@patryk84a Assuming you have origin set up to be your fork and upstream set up to be mit-cml's repo (this one):

git checkout ucr  # switch to your local ucr branch
git fetch upstream  # gets the latest MIT version
git reset --hard upstream/ucr  # makes your local ucr point to the same commit as our ucr
git push -f origin ucr  # force-push to reset the fork to match MIT and local

Note that the use of the force push is only really necessary because they aren't in sync. If you keep the branches clean, then you can do:

git checkout ucr
git pull --ff-only upstream ucr
git push  # assuming your local ucr is set to track origin/ucr
git push origin ucr  # otherwise...

if (position == 0) {
outRect.set(margins, margins, margins, margins);
} else {
outRect.set(0, margins, margins, margins);
Copy link
Member

Choose a reason for hiding this comment

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

So one issue with doing this here is that it seems to make the elements unbalanced. Here are two screen shots with the first and last elements of the list in horizontal layout mode. Note how the last element is flush with the edge whereas the first element isn't.

Screenshot_20241213-121310

Screenshot_20241213-121314

Copy link
Contributor Author

@patryk84a patryk84a Dec 14, 2024

Choose a reason for hiding this comment

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

Yes, I focused on margins, not paying attention to element widths. To fix this we need to set the element width. I also added a screen orientation listener to update widths after screen rotation. I also simplified the code for setting margins for vertical layout, removing lines of code that I had tested with Grid layout before.

@patryk84a
Copy link
Contributor Author

Now is good:

Screenshot_2024-12-14-18-18-08-543_appinventor ai_test listview_margins
Screenshot_2024-12-14-18-18-35-109_appinventor ai_test listview_margins
Screenshot_2024-12-14-18-18-54-638_appinventor ai_test listview_margins

@ewpatton ewpatton added this to the nb201 milestone Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants