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

Pixel-perfect styling of Popup Dialogs #3233

Merged
merged 3 commits into from
Aug 19, 2020
Merged

Pixel-perfect styling of Popup Dialogs #3233

merged 3 commits into from
Aug 19, 2020

Conversation

jsfan3
Copy link
Contributor

@jsfan3 jsfan3 commented Aug 18, 2020

This commit is the solution for https://stackoverflow.com/questions/63449222/problems-in-the-styling-of-a-popupdialog

It adds the method setUIIDByPopupPosition to use the UIIDs "PopupContentPaneDownwards", "PopupContentPaneUpwards", "PopupContentPaneRight", "PopupContentPaneLeft".

If this method is not explicitly invoked, the working of the code remains the same as before, ensuring backward compatibility.

Example of usage:

Dialog d = new Dialog(new BorderLayout());
if (DeviceUtilities.isAndroidTheme) d.setUIIDByPopupPosition(true);
d.add(BorderLayout.CENTER, dialogBody);
d.showPopupDialog(groupInfoBtn);

Example of CSS to get (almost) identical styling on iOS and Android, assuming that in the previous code I call d.setUIIDByPopupPosition(true) only on Android devices (this is not a requirement, it's my choice):

PopupDialog {
    padding: 1mm;
}

PopupDialogTitle {
    margin: 0px;
    padding: 0px;
}

@media platform-and {   
    PopupContentPaneDownwards {
        margin: 0px;
        padding: 1.5mm;
        padding-top: 3.0mm;
    }
    
    PopupContentPaneUpwards {
        margin: 0px;
        padding: 1.5mm;
    }
}

@media platform-ios { 
    PopupContentPane {
        margin: 0px;
        padding: 2.0mm;
        padding-top: 0px;
    }
}

Final note: the use of custom UIIDs for 'PopupContentPane' is safe, while the use of custom UIIDs for PopupDialog is not safe because it can break the UI (I experienced that, that's why my method sets custom UIIDs for 'PopupContentPane' only).

@shai-almog shai-almog merged commit 1c04a80 into codenameone:master Aug 19, 2020
@shai-almog
Copy link
Collaborator

Thanks!

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.

None yet

2 participants