Describe the bug
From Reddit post with same title.
I am working on implementing the standard iOS feature tap-to-scroll-to-top in my app. My approach is to replace the standard StatusBar (an empty container) with a button which I size to the same size as the StatusBar container (defined by the default CN1 theme).
However, it seems that the default height (defined by the "StatusBar" uiid in the default CN1 iOS theme) is too small and on the device (iPhone Xr), tapping the button doesn't work (although it works fine in the Simulator).
I'm guessing that either the default height of the StatusBar is too small (so maybe not reaching down into the 'tappable' area of the screen) or that some other issue prevents tapping the top of the screen (like the safeArea?).
I can post a test example code if the above description is not sufficient.
Shai feedback:
We already have that code: https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/ui/Form.java#L598-L624
I'm guessing that the pull down in iOS native is grabbing the tap but I never got around to investigate this in xcode.
To Reproduce
Code I used to test on device (you can play around with the size of the statusbar and check whether the touch registers or not):
Form hi = new Form("Cannot tap statusbar on iOS device", BoxLayout.y());
Label statusBarHeight = new Label("0");
//buttons to increase/decrease statusbar height
Button increaseStatusBarHeight = new Button(Command.create("Increase 1px", null, ev -> {
statusBarHeight.setText("" + (Integer.parseInt(statusBarHeight.getText()) + 1));
getCurrentForm().revalidate();
}));
Button decreaseStatusBarHeight = new Button(Command.create("Decrease 1px", null, ev -> {
statusBarHeight.setText("" + (Integer.parseInt(statusBarHeight.getText()) - 1));
getCurrentForm().revalidate();
}));
//https://developer.apple.com/forums/thread/662466: Other iPhones: 44. 44 leaves a few pixels active at the bottom of the visible statusbar.
Button px00 = new Button(Command.create("0px ", null, ev -> {
statusBarHeight.setText("" + 0);
getCurrentForm().revalidate();
}));
Button px32 = new Button(Command.create("32px ", null, ev -> {
statusBarHeight.setText("" + 32);
getCurrentForm().revalidate();
}));
Button px40 = new Button(Command.create("40px ", null, ev -> {
statusBarHeight.setText("" + 40);
getCurrentForm().revalidate();
}));
Button px44 = new Button(Command.create("44px ", null, ev -> {
statusBarHeight.setText("" + 44);
getCurrentForm().revalidate();
}));
Label countStatusBarTaps = new Label("0");
hi.add(FlowLayout.encloseIn(new Label("Count statusbar taps: "), countStatusBarTaps));
hi.add(increaseStatusBarHeight);
hi.add(decreaseStatusBarHeight);
hi.add(FlowLayout.encloseIn(new Label("Set statusbar height: "), px00, px40, px44));
hi.add(FlowLayout.encloseIn(new Label("Additional statusbar height: "), statusBarHeight));
Button statusBarButton = new Button() {
@Override
public void pointerReleased(int x, int y) {
Log.p("StatusButton pressed");
countStatusBarTaps.setText("" + (Integer.parseInt(countStatusBarTaps.getText()) + 1)); //count successful taps on statusbarButton
super.pointerReleased(x, y);
}
@Override
public Dimension getPreferredSize() {
Container fakeStatusBar = new Container();
fakeStatusBar.setUIID("StatusBar");
Dimension statusBarDim = new Dimension(
Display.getInstance().getDisplayWidth(), //force to full screen width
fakeStatusBar.getPreferredH() + fakeStatusBar.getStyle().getVerticalMargins() //default statusbar height
+ Integer.parseInt(statusBarHeight.getText())); //forcing the statusbarbutton to filling up the statusbar area
return statusBarDim;
}
};
//Color the statusbar blue and titlebar grey to see their size.
statusBarButton.setShowEvenIfBlank(true);
statusBarButton.getAllStyles().setBgColor(0x84B1D0);
statusBarButton.getAllStyles().setBgTransparency(128);
Toolbar toolbar = hi.getToolbar();
toolbar.getTitleComponent().getAllStyles().setBgColor(0xcccccc);
toolbar.getTitleComponent().getAllStyles().setBgTransparency(128);
BorderLayout currentStatusBarLayout = (BorderLayout) toolbar.getLayout();
Container statusBarNorth = (Container) currentStatusBarLayout.getNorth();
statusBarNorth.setUIID("Container"); //remove margin/padding from the statusbar container
statusBarNorth.addComponent(statusBarButton); //add new statusBarButton
hi.show();
Expected behavior
Taps on the device statusbar should be sent to the underlying components. This is happens correctly on the Simulator.
Smartphone (please complete the following information):
- Device: iOS 15 (iPhone XR)
Describe the bug
From Reddit post with same title.
I am working on implementing the standard iOS feature tap-to-scroll-to-top in my app. My approach is to replace the standard StatusBar (an empty container) with a button which I size to the same size as the StatusBar container (defined by the default CN1 theme).
However, it seems that the default height (defined by the "StatusBar" uiid in the default CN1 iOS theme) is too small and on the device (iPhone Xr), tapping the button doesn't work (although it works fine in the Simulator).
I'm guessing that either the default height of the StatusBar is too small (so maybe not reaching down into the 'tappable' area of the screen) or that some other issue prevents tapping the top of the screen (like the safeArea?).
I can post a test example code if the above description is not sufficient.
Shai feedback:
We already have that code: https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/ui/Form.java#L598-L624
I'm guessing that the pull down in iOS native is grabbing the tap but I never got around to investigate this in xcode.
To Reproduce
Code I used to test on device (you can play around with the size of the statusbar and check whether the touch registers or not):
Expected behavior
Taps on the device statusbar should be sent to the underlying components. This is happens correctly on the Simulator.
Smartphone (please complete the following information):