@ -6,6 +6,7 @@ import '../../models/config/toolbar/toolbar_configurations.dart';
import ' ../../models/documents/attribute.dart ' ;
import ' ../../models/documents/attribute.dart ' ;
import ' ../utils/provider.dart ' ;
import ' ../utils/provider.dart ' ;
import ' base_toolbar.dart ' ;
import ' base_toolbar.dart ' ;
import ' buttons/arrow_indicated_list_button.dart ' ;
import ' buttons/select_alignment_buttons.dart ' ;
import ' buttons/select_alignment_buttons.dart ' ;
import ' buttons/select_header_style_button.dart ' ;
import ' buttons/select_header_style_button.dart ' ;
@ -50,22 +51,7 @@ class QuillSimpleToolbar extends StatelessWidget
configurations . showLink | | configurations . showSearchButton
configurations . showLink | | configurations . showSearchButton
] ;
] ;
return QuillToolbarProvider (
List < Widget > childrenBuilder ( context ) {
toolbarConfigurations: configurations ,
child: QuillToolbar (
configurations: QuillToolbarConfigurations (
color: configurations . color ,
decoration: configurations . decoration ,
toolbarSectionSpacing: configurations . toolbarSectionSpacing ,
toolbarIconAlignment: configurations . toolbarIconAlignment ,
toolbarIconCrossAlignment: configurations . toolbarIconCrossAlignment ,
linkDialogAction: configurations . linkDialogAction ,
multiRowsDisplay: configurations . multiRowsDisplay ,
sectionDividerColor: configurations . sectionDividerColor ,
axis: configurations . axis ,
sectionDividerSpace: configurations . sectionDividerSpace ,
toolbarSize: configurations . toolbarSize ,
childrenBuilder: ( context ) {
final toolbarConfigurations =
final toolbarConfigurations =
context . requireQuillSimpleToolbarConfigurations ;
context . requireQuillSimpleToolbarConfigurations ;
@ -83,8 +69,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton (
QuillToolbarHistoryButton (
isUndo: true ,
isUndo: true ,
options: toolbarConfigurations . buttonOptions . undoHistory ,
options: toolbarConfigurations . buttonOptions . undoHistory ,
controller: toolbarConfigurations
controller:
. buttonOptions . undoHistory . controller ? ?
toolbarConfigurations . buttonOptions . undoHistory . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -93,8 +79,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarHistoryButton (
QuillToolbarHistoryButton (
isUndo: false ,
isUndo: false ,
options: toolbarConfigurations . buttonOptions . redoHistory ,
options: toolbarConfigurations . buttonOptions . redoHistory ,
controller: toolbarConfigurations
controller:
. buttonOptions . redoHistory . controller ? ?
toolbarConfigurations . buttonOptions . redoHistory . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -102,8 +88,8 @@ class QuillSimpleToolbar extends StatelessWidget
if ( configurations . showFontFamily ) . . . [
if ( configurations . showFontFamily ) . . . [
QuillToolbarFontFamilyButton (
QuillToolbarFontFamilyButton (
options: toolbarConfigurations . buttonOptions . fontFamily ,
options: toolbarConfigurations . buttonOptions . fontFamily ,
controller: toolbarConfigurations
controller:
. buttonOptions . fontFamily . controller ? ?
toolbarConfigurations . buttonOptions . fontFamily . controller ? ?
globalController ,
globalController ,
defaultDispalyText: context . loc . font ,
defaultDispalyText: context . loc . font ,
) ,
) ,
@ -112,8 +98,8 @@ class QuillSimpleToolbar extends StatelessWidget
if ( configurations . showFontSize ) . . . [
if ( configurations . showFontSize ) . . . [
QuillToolbarFontSizeButton (
QuillToolbarFontSizeButton (
options: toolbarConfigurations . buttonOptions . fontSize ,
options: toolbarConfigurations . buttonOptions . fontSize ,
controller: toolbarConfigurations
controller:
. buttonOptions . fontFamily . controller ? ?
toolbarConfigurations . buttonOptions . fontFamily . controller ? ?
globalController ,
globalController ,
defaultDisplayText: context . loc . fontSize ,
defaultDisplayText: context . loc . fontSize ,
) ,
) ,
@ -123,8 +109,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . bold ,
attribute: Attribute . bold ,
options: toolbarConfigurations . buttonOptions . bold ,
options: toolbarConfigurations . buttonOptions . bold ,
controller:
controller: toolbarConfigurations . buttonOptions . bold . controller ? ?
toolbarConfigurations . buttonOptions . bold . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -133,8 +118,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . italic ,
attribute: Attribute . italic ,
options: toolbarConfigurations . buttonOptions . italic ,
options: toolbarConfigurations . buttonOptions . italic ,
controller:
controller: toolbarConfigurations . buttonOptions . italic . controller ? ?
toolbarConfigurations . buttonOptions . italic . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -143,8 +127,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . underline ,
attribute: Attribute . underline ,
options: toolbarConfigurations . buttonOptions . underLine ,
options: toolbarConfigurations . buttonOptions . underLine ,
controller: toolbarConfigurations
controller:
. buttonOptions . underLine . controller ? ?
toolbarConfigurations . buttonOptions . underLine . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -153,8 +137,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . inlineCode ,
attribute: Attribute . inlineCode ,
options: toolbarConfigurations . buttonOptions . inlineCode ,
options: toolbarConfigurations . buttonOptions . inlineCode ,
controller: toolbarConfigurations
controller:
. buttonOptions . inlineCode . controller ? ?
toolbarConfigurations . buttonOptions . inlineCode . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -163,8 +147,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . subscript ,
attribute: Attribute . subscript ,
options: toolbarConfigurations . buttonOptions . subscript ,
options: toolbarConfigurations . buttonOptions . subscript ,
controller: toolbarConfigurations
controller:
. buttonOptions . subscript . controller ? ?
toolbarConfigurations . buttonOptions . subscript . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -173,8 +157,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . superscript ,
attribute: Attribute . superscript ,
options: toolbarConfigurations . buttonOptions . superscript ,
options: toolbarConfigurations . buttonOptions . superscript ,
controller: toolbarConfigurations
controller:
. buttonOptions . superscript . controller ? ?
toolbarConfigurations . buttonOptions . superscript . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -183,8 +167,7 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . small ,
attribute: Attribute . small ,
options: toolbarConfigurations . buttonOptions . small ,
options: toolbarConfigurations . buttonOptions . small ,
controller:
controller: toolbarConfigurations . buttonOptions . small . controller ? ?
toolbarConfigurations . buttonOptions . small . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -193,16 +176,15 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . strikeThrough ,
attribute: Attribute . strikeThrough ,
options: toolbarConfigurations . buttonOptions . strikeThrough ,
options: toolbarConfigurations . buttonOptions . strikeThrough ,
controller: toolbarConfigurations
controller:
. buttonOptions . strikeThrough . controller ? ?
toolbarConfigurations . buttonOptions . strikeThrough . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
] ,
] ,
if ( configurations . showColorButton ) . . . [
if ( configurations . showColorButton ) . . . [
QuillToolbarColorButton (
QuillToolbarColorButton (
controller:
controller: toolbarConfigurations . buttonOptions . color . controller ? ?
toolbarConfigurations . buttonOptions . color . controller ? ?
globalController ,
globalController ,
isBackground: false ,
isBackground: false ,
options: toolbarConfigurations . buttonOptions . color ,
options: toolbarConfigurations . buttonOptions . color ,
@ -212,8 +194,7 @@ class QuillSimpleToolbar extends StatelessWidget
if ( configurations . showBackgroundColorButton ) . . . [
if ( configurations . showBackgroundColorButton ) . . . [
QuillToolbarColorButton (
QuillToolbarColorButton (
options: toolbarConfigurations . buttonOptions . backgroundColor ,
options: toolbarConfigurations . buttonOptions . backgroundColor ,
controller:
controller: toolbarConfigurations . buttonOptions . color . controller ? ?
toolbarConfigurations . buttonOptions . color . controller ? ?
globalController ,
globalController ,
isBackground: true ,
isBackground: true ,
) ,
) ,
@ -221,8 +202,8 @@ class QuillSimpleToolbar extends StatelessWidget
] ,
] ,
if ( configurations . showClearFormat ) . . . [
if ( configurations . showClearFormat ) . . . [
QuillToolbarClearFormatButton (
QuillToolbarClearFormatButton (
controller: toolbarConfigurations
controller:
. buttonOptions . clearFormat . controller ? ?
toolbarConfigurations . buttonOptions . clearFormat . controller ? ?
globalController ,
globalController ,
options: toolbarConfigurations . buttonOptions . clearFormat ,
options: toolbarConfigurations . buttonOptions . clearFormat ,
) ,
) ,
@ -252,8 +233,7 @@ class QuillSimpleToolbar extends StatelessWidget
controller: toolbarConfigurations
controller: toolbarConfigurations
. buttonOptions . selectAlignmentButtons . controller ? ?
. buttonOptions . selectAlignmentButtons . controller ? ?
globalController ,
globalController ,
options: toolbarConfigurations
options: toolbarConfigurations . buttonOptions . selectAlignmentButtons ,
. buttonOptions . selectAlignmentButtons ,
showLeftAlignment: configurations . showLeftAlignment ,
showLeftAlignment: configurations . showLeftAlignment ,
showCenterAlignment: configurations . showCenterAlignment ,
showCenterAlignment: configurations . showCenterAlignment ,
showRightAlignment: configurations . showRightAlignment ,
showRightAlignment: configurations . showRightAlignment ,
@ -265,8 +245,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . rtl ,
attribute: Attribute . rtl ,
options: toolbarConfigurations . buttonOptions . direction ,
options: toolbarConfigurations . buttonOptions . direction ,
controller: toolbarConfigurations
controller:
. buttonOptions . direction . controller ? ?
toolbarConfigurations . buttonOptions . direction . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -287,8 +267,8 @@ class QuillSimpleToolbar extends StatelessWidget
controller: toolbarConfigurations
controller: toolbarConfigurations
. buttonOptions . selectHeaderStyleButtons . controller ? ?
. buttonOptions . selectHeaderStyleButtons . controller ? ?
globalController ,
globalController ,
options: toolbarConfigurations
options:
. buttonOptions . selectHeaderStyleButtons ,
toolbarConfigurations . buttonOptions . selectHeaderStyleButtons ,
) ,
) ,
spacerWidget ,
spacerWidget ,
] ,
] ,
@ -307,8 +287,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . ol ,
attribute: Attribute . ol ,
options: toolbarConfigurations . buttonOptions . listNumbers ,
options: toolbarConfigurations . buttonOptions . listNumbers ,
controller: toolbarConfigurations
controller:
. buttonOptions . listNumbers . controller ? ?
toolbarConfigurations . buttonOptions . listNumbers . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -317,8 +297,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . ul ,
attribute: Attribute . ul ,
options: toolbarConfigurations . buttonOptions . listBullets ,
options: toolbarConfigurations . buttonOptions . listBullets ,
controller: toolbarConfigurations
controller:
. buttonOptions . listBullets . controller ? ?
toolbarConfigurations . buttonOptions . listBullets . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -336,8 +316,8 @@ class QuillSimpleToolbar extends StatelessWidget
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
attribute: Attribute . codeBlock ,
attribute: Attribute . codeBlock ,
options: toolbarConfigurations . buttonOptions . codeBlock ,
options: toolbarConfigurations . buttonOptions . codeBlock ,
controller: toolbarConfigurations
controller:
. buttonOptions . codeBlock . controller ? ?
toolbarConfigurations . buttonOptions . codeBlock . controller ? ?
globalController ,
globalController ,
) ,
) ,
spacerWidget ,
spacerWidget ,
@ -354,8 +334,7 @@ class QuillSimpleToolbar extends StatelessWidget
if ( configurations . showQuote ) . . . [
if ( configurations . showQuote ) . . . [
QuillToolbarToggleStyleButton (
QuillToolbarToggleStyleButton (
options: toolbarConfigurations . buttonOptions . quote ,
options: toolbarConfigurations . buttonOptions . quote ,
controller:
controller: toolbarConfigurations . buttonOptions . quote . controller ? ?
toolbarConfigurations . buttonOptions . quote . controller ? ?
globalController ,
globalController ,
attribute: Attribute . blockQuote ,
attribute: Attribute . blockQuote ,
) ,
) ,
@ -363,8 +342,8 @@ class QuillSimpleToolbar extends StatelessWidget
] ,
] ,
if ( configurations . showIndent ) . . . [
if ( configurations . showIndent ) . . . [
QuillToolbarIndentButton (
QuillToolbarIndentButton (
controller: toolbarConfigurations
controller:
. buttonOptions . indentIncrease . controller ? ?
toolbarConfigurations . buttonOptions . indentIncrease . controller ? ?
globalController ,
globalController ,
isIncrease: true ,
isIncrease: true ,
options: toolbarConfigurations . buttonOptions . indentIncrease ,
options: toolbarConfigurations . buttonOptions . indentIncrease ,
@ -373,8 +352,8 @@ class QuillSimpleToolbar extends StatelessWidget
] ,
] ,
if ( configurations . showIndent ) . . . [
if ( configurations . showIndent ) . . . [
QuillToolbarIndentButton (
QuillToolbarIndentButton (
controller: toolbarConfigurations
controller:
. buttonOptions . indentDecrease . controller ? ?
toolbarConfigurations . buttonOptions . indentDecrease . controller ? ?
globalController ,
globalController ,
isIncrease: false ,
isIncrease: false ,
options: toolbarConfigurations . buttonOptions . indentDecrease ,
options: toolbarConfigurations . buttonOptions . indentDecrease ,
@ -407,8 +386,7 @@ class QuillSimpleToolbar extends StatelessWidget
] ,
] ,
if ( configurations . showSearchButton ) . . . [
if ( configurations . showSearchButton ) . . . [
QuillToolbarSearchButton (
QuillToolbarSearchButton (
controller:
controller: toolbarConfigurations . buttonOptions . search . controller ? ?
toolbarConfigurations . buttonOptions . search . controller ? ?
globalController ,
globalController ,
options: toolbarConfigurations . buttonOptions . search ,
options: toolbarConfigurations . buttonOptions . search ,
) ,
) ,
@ -443,9 +421,48 @@ class QuillSimpleToolbar extends StatelessWidget
spacerWidget ,
spacerWidget ,
] ,
] ,
] ;
] ;
}
return QuillToolbarProvider (
toolbarConfigurations: configurations ,
child: QuillToolbar (
configurations: QuillToolbarConfigurations (
buttonOptions: configurations . buttonOptions ,
child: Builder (
builder: ( context ) {
if ( configurations . multiRowsDisplay ) {
return Wrap (
direction: configurations . axis ,
alignment: configurations . toolbarIconAlignment ,
crossAxisAlignment: configurations . toolbarIconCrossAlignment ,
runSpacing: 4 ,
spacing: configurations . toolbarSectionSpacing ,
children: childrenBuilder ( context ) ,
) ;
}
return Container (
decoration: configurations . decoration ? ?
BoxDecoration (
color:
configurations . color ? ? Theme . of ( context ) . canvasColor ,
) ,
constraints: BoxConstraints . tightFor (
height: configurations . axis = = Axis . horizontal
? configurations . toolbarSize
: null ,
width: configurations . axis = = Axis . vertical
? configurations . toolbarSize
: null ,
) ,
child: QuillToolbarArrowIndicatedButtonList (
axis: configurations . axis ,
buttons: childrenBuilder ( context ) ,
) ,
) ;
} ,
} ,
) ,
) ,
) ,
) ,
) ,
) ;
) ;
}
}
@ -454,3 +471,51 @@ class QuillSimpleToolbar extends StatelessWidget
? const Size . fromHeight ( defaultToolbarSize )
? const Size . fromHeight ( defaultToolbarSize )
: const Size . fromWidth ( defaultToolbarSize ) ;
: const Size . fromWidth ( defaultToolbarSize ) ;
}
}
/ / / The divider which is used for separation of buttons in the toolbar .
/ / /
/ / / It can be used outside of this package , for example when user does not use
/ / / [ QuillToolbar . basic ] and compose toolbar ' s children on its own.
class QuillToolbarDivider extends StatelessWidget {
const QuillToolbarDivider (
this . axis , {
super . key ,
this . color ,
this . space ,
} ) ;
/ / / Provides a horizontal divider for vertical toolbar .
const QuillToolbarDivider . horizontal ( { Key ? key , Color ? color , double ? space } )
: this ( Axis . horizontal , color: color , space: space , key: key ) ;
/ / / Provides a horizontal divider for horizontal toolbar .
const QuillToolbarDivider . vertical ( { Key ? key , Color ? color , double ? space } )
: this ( Axis . vertical , color: color , space: space , key: key ) ;
/ / / The axis along which the toolbar is .
final Axis axis ;
/ / / The color to use when painting this divider ' s line.
final Color ? color ;
/ / / The divider ' s space (width or height) depending of [axis].
final double ? space ;
@ override
Widget build ( BuildContext context ) {
/ / Vertical toolbar requires horizontal divider , and vice versa
return axis = = Axis . vertical
? Divider (
height: space ,
color: color ,
indent: 12 ,
endIndent: 12 ,
)
: VerticalDivider (
width: space ,
color: color ,
indent: 12 ,
endIndent: 12 ,
) ;
}
}