Update select header style buttons to look good on material 3

pull/1682/head
Ellet 1 year ago
parent d23fe603b7
commit a20278190f
  1. 37
      example/lib/screens/quill/my_quill_toolbar.dart
  2. 49
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart

@ -222,24 +222,25 @@ class MyQuillToolbar extends StatelessWidget {
'35': '35.0', '35': '35.0',
'40': '40.0' '40': '40.0'
}, },
buttonOptions: QuillSimpleToolbarButtonOptions( // headerStyleType: HeaderStyleType.buttons,
base: QuillToolbarBaseButtonOptions( // buttonOptions: QuillSimpleToolbarButtonOptions(
afterButtonPressed: focusNode.requestFocus, // base: QuillToolbarBaseButtonOptions(
// iconSize: 20, // afterButtonPressed: focusNode.requestFocus,
// iconTheme: QuillIconTheme( // // iconSize: 20,
// iconButtonSelectedData: IconButtonData( // iconTheme: QuillIconTheme(
// style: IconButton.styleFrom( // iconButtonSelectedData: IconButtonData(
// foregroundColor: Colors.blue, // style: IconButton.styleFrom(
// ), // foregroundColor: Colors.blue,
// ), // ),
// iconButtonUnselectedData: IconButtonData( // ),
// style: IconButton.styleFrom( // iconButtonUnselectedData: IconButtonData(
// foregroundColor: Colors.red, // style: IconButton.styleFrom(
// ), // foregroundColor: Colors.red,
// ), // ),
// ), // ),
), // ),
), // ),
// ),
customButtons: [ customButtons: [
QuillToolbarCustomButtonOptions( QuillToolbarCustomButtonOptions(
icon: const Icon(Icons.add_alarm_rounded), icon: const Icon(Icons.add_alarm_rounded),

@ -89,8 +89,7 @@ class QuillToolbarSelectHeaderStyleButtonsState
return options.axis ?? return options.axis ??
context.quillSimpleToolbarConfigurations?.axis ?? context.quillSimpleToolbarConfigurations?.axis ??
context.quillToolbarConfigurations?.axis ?? context.quillToolbarConfigurations?.axis ??
(throw ArgumentError( Axis.horizontal;
'There is no default value for the Axis of the toolbar'));
} }
void _sharedOnPressed(Attribute attribute) { void _sharedOnPressed(Attribute attribute) {
@ -130,15 +129,7 @@ class QuillToolbarSelectHeaderStyleButtonsState
final children = _attrbuites.map((attribute) { final children = _attrbuites.map((attribute) {
if (childBuilder != null) { if (childBuilder != null) {
return childBuilder( return childBuilder(
QuillToolbarSelectHeaderStyleButtonsOptions( options,
afterButtonPressed: afterButtonPressed,
attributes: _attrbuites,
axis: axis,
iconSize: iconSize,
iconButtonFactor: iconButtonFactor,
iconTheme: iconTheme,
tooltip: tooltip,
),
QuillToolbarSelectHeaderStyleButtonsExtraOptions( QuillToolbarSelectHeaderStyleButtonsExtraOptions(
controller: controller, controller: controller,
context: context, context: context,
@ -146,30 +137,24 @@ class QuillToolbarSelectHeaderStyleButtonsState
), ),
); );
} }
// final theme = Theme.of(context);
final isSelected = _selectedAttribute == attribute; final isSelected = _selectedAttribute == attribute;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: !kIsWeb ? 1.0 : 5.0), padding: const EdgeInsets.symmetric(horizontal: !kIsWeb ? 1.0 : 5.0),
child: ConstrainedBox( child: QuillToolbarIconButton(
constraints: BoxConstraints.tightFor( tooltip: tooltip,
width: iconSize * iconButtonFactor, iconTheme: iconTheme,
height: iconSize * iconButtonFactor, isSelected: isSelected,
), onPressed: () => _sharedOnPressed(attribute),
child: QuillToolbarIconButton( icon: Text(
tooltip: tooltip, _valueToText[attribute] ??
iconTheme: iconTheme, (throw ArgumentError.notNull(
isSelected: isSelected, 'attrbuite',
onPressed: () => _sharedOnPressed(attribute), )),
icon: Text( style: style.copyWith(
_valueToText[attribute] ?? color: isSelected
(throw ArgumentError.notNull( ? iconTheme?.iconButtonSelectedData?.color
'attrbuite', : iconTheme?.iconButtonUnselectedData?.color,
)),
style: style.copyWith(
color: isSelected
? iconTheme?.iconButtonSelectedData?.color
: iconTheme?.iconButtonUnselectedData?.color,
),
), ),
), ),
), ),

Loading…
Cancel
Save