@@ -46,6 +46,13 @@ final class NavigationGlassButton: UIButton {
4646 var menuVisibilityChanged : ( ( Bool ) -> Void ) ?
4747 var animateMenu : ( ( Bool , UIContextMenuInteractionAnimating ? ) -> Void ) ?
4848 weak var glassPreview : UIView ?
49+ var onHighlightChanged : ( ( Bool ) -> Void ) ?
50+
51+ override var isHighlighted : Bool {
52+ didSet {
53+ if oldValue != isHighlighted { onHighlightChanged ? ( isHighlighted ) }
54+ }
55+ }
4956
5057 override func contextMenuInteraction (
5158 _ interaction : UIContextMenuInteraction ,
@@ -266,6 +273,9 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
266273 if arguments ? [ " plain " ] as? Bool == true || arguments ? [ " mergingNavigation " ] as? Bool == true { configuration = . plain ( ) }
267274 configuration . cornerStyle = . capsule
268275 button . configuration = configuration
276+ button . onHighlightChanged = { [ weak self ] highlighted in
277+ self ? . channel . invokeMethod ( " highlighted " , arguments : highlighted )
278+ }
269279 applyContent ( from : arguments )
270280 button . titleLabel ? . numberOfLines = 1
271281 button . titleLabel ? . lineBreakMode = . byClipping
@@ -275,6 +285,7 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
275285 bottom : max ( 0 , ( hitTargetHeight - controlSize ) / 2 ) ,
276286 right : max ( 0 , hitTargetWidth - buttonCenterX - controlWidth / 2 )
277287 )
288+ containerView . accessibilityElementsHidden = arguments ? [ " accessibilityHidden " ] as? Bool ?? false
278289 button . accessibilityLabel = arguments ? [ " accessibilityLabel " ] as? String ?? " Back "
279290 button . translatesAutoresizingMaskIntoConstraints = false
280291 button . addAction (
@@ -311,6 +322,11 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
311322
312323 applyAppearance ( from : args )
313324 channel . setMethodCallHandler { [ weak self ] call , result in
325+ if call . method == " setArtworkPressed " {
326+ self ? . button . isHighlighted = call . arguments as? Bool ?? false
327+ result ( nil )
328+ return
329+ }
314330 if call . method == " setContent " {
315331 self ? . setContent ( from : call . arguments )
316332 result ( nil )
@@ -426,10 +442,10 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
426442 containerView . overrideUserInterfaceStyle = interfaceStyle
427443 button . overrideUserInterfaceStyle = interfaceStyle
428444 button . isEnabled = enabled
429- button . isSelected = selected
445+ button . isSelected = selected && ( arguments ? [ " tintsSelection " ] as? Bool ?? true )
430446 // Resolve label contrast explicitly on the first selected frame as well as
431447 // later selections; UIKit may retain the initial glass title foreground.
432- labelForegroundColor = selected
448+ labelForegroundColor = button . isSelected
433449 ? ( interfaceStyle == . dark ? . black : . white )
434450 : foregroundColor
435451 isBusy = busy
0 commit comments