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

[BUG]? Popup does not wrap content (on Android) #1150

Closed
2 tasks done
Dry-Tech opened this issue Apr 20, 2023 · 6 comments · Fixed by #1500
Closed
2 tasks done

[BUG]? Popup does not wrap content (on Android) #1150

Dry-Tech opened this issue Apr 20, 2023 · 6 comments · Fixed by #1500
Labels
bug Something isn't working unverified

Comments

@Dry-Tech
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Hello,
maybe I'm missing something very simple, but it seems that you can't use long texts as a label in a popup, because there is no line break and thus the popup will be wider than the display area.

I attached a sample repository and a screenshot.

Expected Behavior

Popup takes almost full width of the display because the text is so long, and the label text has line breaks when necessary.

Steps To Reproduce

  1. Run the sample project
  2. Click the button
  3. You will see the result as shown in the screenshot

Link to public reproduction project repository

https://github.com/Dry-Tech/NetMauiPopupNoWrapBug

Environment

- .NET MAUI CommunityToolkit: 5.1.0
- OS: Android 10
- .NET MAUI: 7.0

Anything else?

NetMauiPopupNoWrapBug

@Dry-Tech Dry-Tech added bug Something isn't working unverified labels Apr 20, 2023
@VladislavAntonyuk
Copy link
Collaborator

Try replacing VerticalStackLayout with Grid

@Dry-Tech
Copy link
Author

Try replacing VerticalStackLayout with Grid

No sorry, did not work.

@pictos
Copy link
Member

pictos commented Apr 21, 2023

@Dry-Tech you can set a size on popup, if it doesn't measure as you would like. And you can force the word wrap using the Label.LineBreakMode property

@cat0363
Copy link
Contributor

cat0363 commented Aug 28, 2023

This issue may be resolved by PR #1361.

@cat0363
Copy link
Contributor

cat0363 commented Nov 6, 2023

In API Level 29 and below, the following method is used to obtain the height of the status bar, but this seems to be the problem.

[src\CommunityToolkit.Maui.Core\Views\Popup\PopupExtensions.android.cs]

decorView.GetWindowVisibleDisplayFrame(contentRect);
statusBarHeight = contentRect.Top;

When you call the above method, the Label will not wrap.
Although it is not very desirable, if you obtain the height of the status bar using the method introduced below, the label will be wrapped correctly. (This is the method I gave up on in PR #1320.)

var resourceIdStatus = decorView?.Context?.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0;
statusBarHeight = resourceIdStatus > 0 ? decorView?.Context?.Resources?.GetDimensionPixelSize(resourceIdStatus) ?? 0 : 0;

If you can get the height of the status bar without calling the GetWindowVisibleDisplayFrame method, the problem for API Level 29 and below will be resolved.

Below are the results of the operation verification of the latest version of main.

[Use GetWindowVisibleDisplayFrame]

[Don't use GetWindowVisibleDisplayFrame]

API Level 30 and above is working as intended.
I'm looking into how to get the Statusbar height in API Level 29 and below, but I haven't found it yet.

Additional Information:
The label wrapping issue below API Level 29 can probably be resolved if you can get the status bar height without calling the GetWindowVisibleDisplayFrame method.

@brminnick , I would like to hear your opinion.

@cat0363
Copy link
Contributor

cat0363 commented Nov 6, 2023

@brminnick , I found a solution.

I found a way to calculate the status bar height without using the method below.
I will create a PR.

var resourceIdStatus = decorView?.Context?.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0;
statusBarHeight = resourceIdStatus > 0 ? decorView?.Context?.Resources?.GetDimensionPixelSize(resourceIdStatus) ?? 0 : 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unverified
Projects
None yet
4 participants