1- using System ;
1+ using Gtk ;
2+ using System ;
23
34namespace Microsoft . Maui . Handlers
45{
5- public partial class RadioButtonHandler : ViewHandler < IRadioButton , NotImplementedView >
6+ public partial class RadioButtonHandler : ViewHandler < IRadioButton , RadioButton >
67 {
7- protected override NotImplementedView CreatePlatformView ( ) => new ( nameof ( IRadioButton ) ) ;
8+ static RadioButton baseRadioButton = new ( "base" ) ;
89
9- public static void MapBackground ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
10- public static void MapIsChecked ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
11- public static void MapContent ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
12- public static void MapTextColor ( IRadioButtonHandler handler , ITextStyle textStyle ) { }
10+ protected override RadioButton CreatePlatformView ( )
11+ {
12+ return new RadioButton ( baseRadioButton , "foo" ) ;
13+ }
14+
15+ protected override void ConnectHandler ( RadioButton platformView )
16+ {
17+ platformView . Toggled += OnClicked ;
18+ }
19+
20+ protected override void DisconnectHandler ( RadioButton platformView )
21+ {
22+ platformView . Toggled -= OnClicked ;
23+ }
24+
25+ public static void MapBackground ( IRadioButtonHandler handler , IRadioButton radioButton )
26+ {
27+ if ( handler . PlatformView is RadioButton rb )
28+ rb . UpdateBackground ( radioButton ) ;
29+ }
30+
31+ public static void MapIsChecked ( IRadioButtonHandler handler , IRadioButton radioButton )
32+ {
33+ if ( handler . PlatformView is RadioButton rb )
34+ rb . UpdateIsChecked ( radioButton ) ;
35+ }
36+
37+ public static void MapContent ( IRadioButtonHandler handler , IRadioButton radioButton )
38+ {
39+ if ( handler . PlatformView is RadioButton rb )
40+ rb . UpdateContent ( radioButton ) ;
41+ }
42+
43+ public static void MapTextColor ( IRadioButtonHandler handler , ITextStyle textStyle )
44+ {
45+ handler . PlatformView ? . UpdateTextColor ( textStyle . TextColor ) ;
46+ }
47+
48+ [ MissingMapper ]
1349 public static void MapCharacterSpacing ( IRadioButtonHandler handler , ITextStyle textStyle ) { }
14- public static void MapFont ( IRadioButtonHandler handler , ITextStyle textStyle ) { }
50+
51+ public static void MapFont ( IRadioButtonHandler handler , ITextStyle textStyle )
52+ {
53+ var fontManager = handler . GetRequiredService < IFontManager > ( ) ;
54+ handler . PlatformView ? . UpdateFont ( textStyle , fontManager ) ;
55+ }
56+
57+ [ MissingMapper ]
1558 public static void MapStrokeColor ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
59+
60+ [ MissingMapper ]
1661 public static void MapStrokeThickness ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
62+
63+ [ MissingMapper ]
1764 public static void MapCornerRadius ( IRadioButtonHandler handler , IRadioButton radioButton ) { }
65+
66+ void OnClicked ( object ? sender , EventArgs e )
67+ {
68+ if ( sender is RadioButton platformView && VirtualView != null )
69+ VirtualView . IsChecked = platformView . Active ;
70+ }
1871 }
1972}
0 commit comments