1+ using System ;
2+ using Gtk ;
3+ using Microsoft . Maui . Graphics ;
4+ // using Microsoft.UI.Xaml;
5+ // using Microsoft.UI.Xaml.Controls;
6+ // using Microsoft.UI.Xaml.Media;
7+ // using WBrush = Microsoft.UI.Xaml.Media.Brush;
8+
9+ namespace Microsoft . Maui . Platform
10+ {
11+ public static class RadioButtonExtensions
12+ {
13+ public static void UpdateIsChecked ( this RadioButton platformRadioButton , IRadioButton radioButton )
14+ {
15+ platformRadioButton . Active = radioButton . IsChecked ;
16+ }
17+
18+ private static readonly string [ ] _backgroundColorKeys =
19+ {
20+ "RadioButtonBackground" ,
21+ "RadioButtonBackgroundPointerOver" ,
22+ "RadioButtonBackgroundPressed" ,
23+ "RadioButtonBackgroundDisabled"
24+ } ;
25+
26+ [ MissingMapper ]
27+ public static void UpdateBackground ( this RadioButton platformRadioButton , IRadioButton button )
28+ {
29+ // if (button.Background is SolidPaint solidPaint)
30+ // {
31+ // UpdateColors(platformRadioButton.Resources, _backgroundColorKeys, solidPaint.ToPlatform());
32+
33+ // platformRadioButton.RefreshThemeResources();
34+ // }
35+ }
36+
37+ private static readonly string [ ] _foregroundColorKeys =
38+ {
39+ "RadioButtonForeground" ,
40+ "RadioButtonForegroundPointerOver" ,
41+ "RadioButtonForegroundPressed" ,
42+ "RadioButtonForegroundDisabled"
43+ } ;
44+
45+ [ MissingMapper ]
46+ public static void UpdateTextColor ( this RadioButton platformRadioButton , ITextStyle button )
47+ {
48+ // UpdateColors(platformRadioButton.Resources, _foregroundColorKeys, button.TextColor?.ToPlatform());
49+
50+ // platformRadioButton.RefreshThemeResources();
51+ }
52+
53+ public static void UpdateContent ( this RadioButton platformRadioButton , IRadioButton radioButton )
54+ {
55+ _ = radioButton . Handler ? . MauiContext ?? throw new InvalidOperationException ( $ "{ nameof ( MauiContext ) } should have been set by base class.") ;
56+
57+ if ( radioButton is { PresentedContent : IView view } )
58+ platformRadioButton . Label = $ "{ view . ToPlatform ( radioButton . Handler . MauiContext ) } ";
59+ // else
60+ // platformRadioButton.Label = $"{radioButton.Content}";
61+ }
62+
63+ private static readonly string [ ] _borderColorKeys =
64+ {
65+ "RadioButtonBorderBrush" ,
66+ "RadioButtonBorderBrushPointerOver" ,
67+ "RadioButtonBorderBrushPressed" ,
68+ "RadioButtonBorderBrushDisabled"
69+ } ;
70+
71+ [ MissingMapper ]
72+ public static void UpdateStrokeColor ( this RadioButton platformRadioButton , IRadioButton radioButton )
73+ {
74+ // UpdateColors(platformRadioButton.Resources, _borderColorKeys, radioButton.StrokeColor?.ToPlatform());
75+
76+ // platformRadioButton.RefreshThemeResources();
77+ }
78+
79+ // [MissingMapper]
80+ // static void UpdateColors(ResourceDictionary resource, string[] keys, WBrush? brush)
81+ // {
82+ // if (brush is null)
83+ // resource.RemoveKeys(keys);
84+ // else
85+ // resource.SetValueForAllKey(keys, brush);
86+ // }
87+
88+ [ MissingMapper ]
89+ public static void UpdateStrokeThickness ( this RadioButton nativeRadioButton , IRadioButton radioButton )
90+ {
91+ // nativeRadioButton.BorderThickness = radioButton.StrokeThickness <= 0 ? WinUIHelpers.CreateThickness(3) : WinUIHelpers.CreateThickness(radioButton.StrokeThickness);
92+ }
93+
94+ [ MissingMapper ]
95+ public static void UpdateCornerRadius ( this RadioButton nativeRadioButton , IRadioButton radioButton )
96+ {
97+ // nativeRadioButton.CornerRadius = WinUIHelpers.CreateCornerRadius(radioButton.CornerRadius);
98+ }
99+ }
100+ }
0 commit comments