@@ -7,6 +7,7 @@ import 'package:irblaster_controller/ir/ir_protocol_registry.dart';
77import 'package:irblaster_controller/ir/ir_protocol_types.dart' ;
88import 'package:irblaster_controller/ir_finder/irblaster_db.dart' ;
99import 'package:irblaster_controller/ir_finder/ir_finder_models.dart' ;
10+ import 'package:irblaster_controller/utils/button_color_accessibility.dart' ;
1011import 'package:irblaster_controller/utils/ir.dart' ;
1112import 'package:irblaster_controller/utils/remote.dart' ;
1213import 'package:irblaster_controller/widgets/code_test.dart' ;
@@ -111,6 +112,7 @@ class _CreateButtonState extends State<CreateButton> {
111112 _selectedIcon = IconData (
112113 b.iconCodePoint! ,
113114 fontFamily: b.iconFontFamily,
115+ fontPackage: b.iconFontPackage,
114116 );
115117 } else if (b.isImage) {
116118 _labelType = _LabelType .image;
@@ -126,7 +128,7 @@ class _CreateButtonState extends State<CreateButton> {
126128 }
127129
128130 if (b.buttonColor != null ) {
129- _selectedColor = Color (b.buttonColor! );
131+ _selectedColor = normalizeAccessibleButtonColor ( Color (b.buttonColor! ) );
130132 }
131133
132134 if (b.protocol != null && b.protocol! .trim ().isNotEmpty) {
@@ -786,18 +788,31 @@ class _CreateButtonState extends State<CreateButton> {
786788 }
787789
788790 Widget _colorOption (Color ? color, String label, ThemeData theme) {
789- final isSelected = _selectedColor == color;
790- final displayColor = color ?? theme.colorScheme.surfaceContainerHighest;
791-
792- return InkWell (
791+ final normalizedOption =
792+ color == null ? null : normalizeAccessibleButtonColor (color);
793+ final isSelected = normalizedOption == null
794+ ? _selectedColor == null
795+ : _selectedColor? .value == normalizedOption.value;
796+ final displayColor =
797+ normalizedOption ?? theme.colorScheme.surfaceContainerHighest;
798+ final checkColor = normalizedOption == null
799+ ? theme.colorScheme.onSurface
800+ : resolveButtonForeground (normalizedOption, Colors .white);
801+
802+ return Semantics (
803+ button: true ,
804+ label: isSelected
805+ ? 'Button color $label , selected'
806+ : 'Button color $label ' ,
807+ child: InkWell (
793808 onTap: () {
794809 setState (() {
795- _selectedColor = color ;
810+ _selectedColor = normalizedOption ;
796811 });
797812 },
798813 borderRadius: BorderRadius .circular (8 ),
799814 child: Container (
800- width : 60 ,
815+ constraints : const BoxConstraints (minWidth : 60 , minHeight : 60 ) ,
801816 padding: const EdgeInsets .symmetric (vertical: 8 ),
802817 child: Column (
803818 mainAxisSize: MainAxisSize .min,
@@ -818,9 +833,7 @@ class _CreateButtonState extends State<CreateButton> {
818833 child: isSelected
819834 ? Icon (
820835 Icons .check,
821- color: color == null
822- ? theme.colorScheme.onSurface
823- : Colors .white,
836+ color: checkColor,
824837 size: 20 ,
825838 )
826839 : null ,
@@ -830,15 +843,20 @@ class _CreateButtonState extends State<CreateButton> {
830843 label,
831844 style: theme.textTheme.bodySmall? .copyWith (fontSize: 10 ),
832845 textAlign: TextAlign .center,
833- maxLines: 1 ,
846+ maxLines: 2 ,
834847 overflow: TextOverflow .ellipsis,
835848 ),
836849 ],
837850 ),
838851 ),
852+ ),
839853 );
840854 }
841855
856+ int ? get _selectedButtonColorValue => _selectedColor == null
857+ ? null
858+ : normalizeAccessibleButtonColor (_selectedColor! ).value;
859+
842860 List <Widget > _buildSignalSummaryChips () {
843861 final List <Widget > chips = [];
844862
@@ -911,7 +929,8 @@ class _CreateButtonState extends State<CreateButton> {
911929 necBitOrder: bitOrder,
912930 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
913931 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
914- buttonColor: _selectedColor? .value,
932+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
933+ buttonColor: _selectedButtonColorValue,
915934 );
916935 }
917936
@@ -926,7 +945,8 @@ class _CreateButtonState extends State<CreateButton> {
926945 isImage: _labelType == _LabelType .image,
927946 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
928947 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
929- buttonColor: _selectedColor? .value,
948+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
949+ buttonColor: _selectedButtonColorValue,
930950 );
931951 }
932952
@@ -968,7 +988,8 @@ class _CreateButtonState extends State<CreateButton> {
968988 protocolParams: params,
969989 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
970990 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
971- buttonColor: _selectedColor? .value,
991+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
992+ buttonColor: _selectedButtonColorValue,
972993 );
973994 }
974995
@@ -2589,7 +2610,8 @@ class _CreateButtonState extends State<CreateButton> {
25892610 necBitOrder: bitOrder,
25902611 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
25912612 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
2592- buttonColor: _selectedColor? .value,
2613+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
2614+ buttonColor: _selectedButtonColorValue,
25932615 );
25942616
25952617 Navigator .pop (context, button);
@@ -2613,7 +2635,8 @@ class _CreateButtonState extends State<CreateButton> {
26132635 isImage: _labelType == _LabelType .image,
26142636 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
26152637 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
2616- buttonColor: _selectedColor? .value,
2638+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
2639+ buttonColor: _selectedButtonColorValue,
26172640 );
26182641
26192642 Navigator .pop (context, button);
@@ -2667,7 +2690,8 @@ class _CreateButtonState extends State<CreateButton> {
26672690 protocolParams: params,
26682691 iconCodePoint: _labelType == _LabelType .icon ? _selectedIcon? .codePoint : null ,
26692692 iconFontFamily: _labelType == _LabelType .icon ? _selectedIcon? .fontFamily : null ,
2670- buttonColor: _selectedColor? .value,
2693+ iconFontPackage: _labelType == _LabelType .icon ? _selectedIcon? .fontPackage : null ,
2694+ buttonColor: _selectedButtonColorValue,
26712695 );
26722696
26732697 Navigator .pop (context, button);
0 commit comments