@@ -407,6 +407,10 @@ pub use http;
407407pub use proxy:: { ProxyConfig , ProxyEndpoint } ;
408408pub use web_context:: WebContext ;
409409
410+ #[ cfg( target_os = "ios" ) ]
411+ pub type InputAccessoryViewBuilder =
412+ dyn Fn ( & objc2_ui_kit:: UIView ) -> Option < Retained < objc2_ui_kit:: UIView > > ;
413+
410414/// A rectangular region.
411415#[ derive( Clone , Copy , Debug ) ]
412416pub struct Rect {
@@ -1410,11 +1414,12 @@ impl<'a> WebViewBuilder<'a> {
14101414}
14111415
14121416#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
1413- #[ derive( Clone ) ]
14141417pub ( crate ) struct PlatformSpecificWebViewAttributes {
14151418 data_store_identifier : Option < [ u8 ; 16 ] > ,
14161419 traffic_light_inset : Option < dpi:: Position > ,
14171420 allow_link_preview : bool ,
1421+ #[ cfg( target_os = "ios" ) ]
1422+ input_accessory_view_builder : Option < Box < InputAccessoryViewBuilder > > ,
14181423}
14191424
14201425#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
@@ -1425,6 +1430,8 @@ impl Default for PlatformSpecificWebViewAttributes {
14251430 traffic_light_inset : None ,
14261431 // platform default for this is true
14271432 allow_link_preview : true ,
1433+ #[ cfg( target_os = "ios" ) ]
1434+ input_accessory_view_builder : None ,
14281435 }
14291436 }
14301437}
@@ -1476,6 +1483,40 @@ impl WebViewBuilderExtDarwin for WebViewBuilder<'_> {
14761483 }
14771484}
14781485
1486+ #[ cfg( target_os = "ios" ) ]
1487+ pub trait WebViewBuilderExtIos {
1488+ /// Allows overriding the the keyboard accessory view on iOS.
1489+ /// Returning `None` effectively removes the view.
1490+ ///
1491+ /// The closure parameter is the webview instance.
1492+ ///
1493+ /// The accessory view is the view that appears above the keyboard when a text input element is focused.
1494+ /// It usually displays a view with "Done", "Next" buttons.
1495+ fn with_input_accessory_view_builder <
1496+ F : Fn ( & objc2_ui_kit:: UIView ) -> Option < Retained < objc2_ui_kit:: UIView > > + ' static ,
1497+ > (
1498+ self ,
1499+ builder : F ,
1500+ ) -> Self ;
1501+ }
1502+
1503+ #[ cfg( target_os = "ios" ) ]
1504+ impl WebViewBuilderExtIos for WebViewBuilder < ' _ > {
1505+ fn with_input_accessory_view_builder <
1506+ F : Fn ( & objc2_ui_kit:: UIView ) -> Option < Retained < objc2_ui_kit:: UIView > > + ' static ,
1507+ > (
1508+ self ,
1509+ builder : F ,
1510+ ) -> Self {
1511+ self . and_then ( |mut b| {
1512+ b. platform_specific
1513+ . input_accessory_view_builder
1514+ . replace ( Box :: new ( builder) ) ;
1515+ Ok ( b)
1516+ } )
1517+ }
1518+ }
1519+
14791520#[ cfg( windows) ]
14801521#[ derive( Clone ) ]
14811522pub ( crate ) struct PlatformSpecificWebViewAttributes {
0 commit comments