This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cf7c2d  feat(ios): use `UIBarButtonSystemItemClose` since iOS 26 
(#1138)
5cf7c2d is described below

commit 5cf7c2d034becd98c16559387ddff425f5d2c288
Author: Manuel Beck <[email protected]>
AuthorDate: Tue May 5 18:39:30 2026 +0200

    feat(ios): use `UIBarButtonSystemItemClose` since iOS 26 (#1138)
    
    - Since iOS 13 it's possible to use `UIBarButtonSystemItemClose` instead of 
`UIBarButtonSystemItemDone` which correspond perfectly to a close button. Since 
`UIBarButtonSystemItemClose` looks akward on iOS 18 and older, because an X 
inside a round button is shown, instead of a text, the close button is only 
applied since iOS 26.
    
    Co-authored-by: Copilot <[email protected]>
---
 src/ios/CDVWKInAppBrowser.m | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index daf3a9f..e3d87bd 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -38,6 +38,8 @@
 
 #define    IAB_BRIDGE_NAME @"cordova_iab"
 
+#define    kCloseButtonSystemItem (@available(iOS 26.0, *) ? 
UIBarButtonSystemItemClose : UIBarButtonSystemItemDone)
+
 #pragma mark CDVWKInAppBrowser
 
 @implementation CDVWKInAppBrowser
@@ -811,7 +813,9 @@ BOOL isExiting = NO;
 
     // NOTE: On iOS 26 using `UIBarButtonItem initWithBarButtonSystemItem:` 
gives constraint warnings,
     // which is a known UIKit bug.
-    self.closeButton = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self 
action:@selector(close)];
+    self.closeButton = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:kCloseButtonSystemItem
+                                                                     
target:self
+                                                                     
action:@selector(close)];
     self.closeButton.enabled = YES;
 
     UIBarButtonItem *flexibleSpaceButton = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil 
action:nil];
@@ -1014,11 +1018,11 @@ BOOL isExiting = NO;
 
 - (void)setCloseButtonTitle:(NSString *)title withColor:(NSString 
*)colorString atIndex:(int)buttonIndex
 {
-    // The advantage of using UIBarButtonSystemItemDone is the system will 
localize it for you automatically
-    // but, if you want to set this yourself, knock yourself out. (We can't 
set the title for a system Done button, so we have to create a new one.)
+    // The system Close/Done button title is localized automatically.
+    // If a custom caption is provided, create a title-based button instead.
     self.closeButton = nil;
-    // Initialize with title if title is set, otherwise the title will be 
'Done' localized.
-    self.closeButton = title != nil ? [[UIBarButtonItem alloc] 
initWithTitle:title style:UIBarButtonItemStylePlain target:self 
action:@selector(close)] : [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self 
action:@selector(close)];
+    // Initialize with title if set, otherwise use the system-localized 
Close/Done item.
+    self.closeButton = title != nil ? [[UIBarButtonItem alloc] 
initWithTitle:title style:UIBarButtonItemStylePlain target:self 
action:@selector(close)] : [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:kCloseButtonSystemItem target:self 
action:@selector(close)];
     self.closeButton.enabled = YES;
     // If color on closebutton is requested then initialize with that that 
color, otherwise use initialize with default.
     self.closeButton.tintColor = colorString != nil ? [self 
colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 
green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to