@@ -156,6 +156,11 @@ public class Sheet extends Container {
156156 */
157157 private String tabletPosition = position ;
158158
159+ /**
160+ * Original padding values to prevent accumulation when showing the sheet multiple times.
161+ * These are set the first time the sheet is shown and used as the base for safe area calculations.
162+ */
163+ private int [] originalPadding = null ;
159164
160165 private ActionListener formPointerListener = new ActionListener () {
161166 @ Override
@@ -369,29 +374,49 @@ public void show(final int duration) {
369374 // Deal with iPhoneX notch.
370375 UIManager uim = UIManager .getInstance ();
371376
377+ // Store original padding values on first show to prevent accumulation
378+ if (originalPadding == null ) {
379+ originalPadding = new int [4 ];
380+ originalPadding [0 ] = s .getPaddingTop (); // top
381+ originalPadding [1 ] = s .getPaddingRightNoRTL (); // right
382+ originalPadding [2 ] = s .getPaddingBottom (); // bottom
383+ originalPadding [3 ] = s .getPaddingLeftNoRTL (); // left
384+ } else {
385+ // Check if style was reset (current padding much smaller than stored original)
386+ // This can happen if the component was removed and re-added with a new style
387+ int currentBottom = s .getPaddingBottom ();
388+ if (currentBottom < originalPadding [2 ] / 2 && currentBottom >= 0 ) {
389+ // Style appears to have been reset, update our cache
390+ originalPadding [0 ] = s .getPaddingTop ();
391+ originalPadding [1 ] = s .getPaddingRightNoRTL ();
392+ originalPadding [2 ] = s .getPaddingBottom ();
393+ originalPadding [3 ] = s .getPaddingLeftNoRTL ();
394+ }
395+ }
396+
372397 Style statusBarStyle = uim .getComponentStyle ("StatusBar" );
373398 Style titleAreaStyle = uim .getComponentStyle ("TitleArea" );
374399
375400 int topPadding = statusBarStyle .getPaddingTop () + statusBarStyle .getPaddingBottom () + titleAreaStyle .getPaddingTop ();
376401 int positionInt = getPositionInt ();
377402 Rectangle displaySafeArea = new Rectangle ();
378403 Display .getInstance ().getDisplaySafeArea (displaySafeArea );
379- int bottomPadding = s .getPaddingBottom ();
404+ // Use original bottom padding to prevent accumulation
405+ int bottomPadding = originalPadding [2 ];
380406 int safeAreaBottomPadding = CN .getDisplayHeight () - (displaySafeArea .getY () + displaySafeArea .getHeight ());
381407 bottomPadding = bottomPadding + safeAreaBottomPadding ;
382408 if (positionInt == S || positionInt == C ) {
383409 // For Center and South position we use margin to
384410 // prevent overlap with top notch. This looks better as overlap is only
385411 // an edge case that occurs when the sheet is the full screen height.
386412 $ (this ).setMargin (topPadding , 0 , 0 , 0 );
387- $ (this ).setPadding (s . getPaddingTop (), s . getPaddingRightNoRTL () , bottomPadding , s . getPaddingLeftNoRTL () );
413+ $ (this ).setPadding (originalPadding [ 0 ], originalPadding [ 1 ] , bottomPadding , originalPadding [ 3 ] );
388414 } else {
389415 // For other cases we use padding to prevent overlap with top notch. This looks
390416 // better as it appears that the sheet bleeds all the way to the top edge of the screen,
391417 // but the content is not obscured by the notch.
392418
393-
394- $ (this ).setPadding (topPadding , s .getPaddingRightNoRTL (), bottomPadding , s .getPaddingLeftNoRTL ());
419+ $ (this ).setPadding (topPadding , originalPadding [1 ], bottomPadding , originalPadding [3 ]);
395420 }
396421
397422 // END Deal with iPhoneX notch
0 commit comments