Support Multi Row Toolbar (#273)

pull/278/head
florianh01 4 years ago committed by GitHub
parent 40d853e631
commit 3c1ee9eec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      example/lib/pages/home_page.dart
  2. 23
      lib/src/widgets/toolbar.dart

@ -141,7 +141,10 @@ class _HomePageState extends State<HomePage> {
embedBuilder: defaultEmbedBuilderWeb); embedBuilder: defaultEmbedBuilderWeb);
} }
var toolbar = QuillToolbar.basic( var toolbar = QuillToolbar.basic(
controller: _controller!, onImagePickCallback: _onImagePickCallback); controller: _controller!,
multiRowsDisplay: false,
onImagePickCallback: _onImagePickCallback,
);
if (kIsWeb) { if (kIsWeb) {
toolbar = QuillToolbar.basic( toolbar = QuillToolbar.basic(
controller: _controller!, controller: _controller!,

@ -49,6 +49,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
this.toolBarHeight = 36, this.toolBarHeight = 36,
this.color, this.color,
this.filePickImpl, this.filePickImpl,
this.multiRowsDisplay,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@ -72,6 +73,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
bool showLink = true, bool showLink = true,
bool showHistory = true, bool showHistory = true,
bool showHorizontalRule = false, bool showHorizontalRule = false,
bool multiRowsDisplay = true,
OnImagePickCallback? onImagePickCallback, OnImagePickCallback? onImagePickCallback,
FilePickImpl? filePickImpl, FilePickImpl? filePickImpl,
WebImagePickImpl? webImagePickImpl, WebImagePickImpl? webImagePickImpl,
@ -96,6 +98,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
return QuillToolbar( return QuillToolbar(
key: key, key: key,
toolBarHeight: toolbarIconSize * 2, toolBarHeight: toolbarIconSize * 2,
multiRowsDisplay: multiRowsDisplay,
children: [ children: [
if (showHistory) if (showHistory)
HistoryButton( HistoryButton(
@ -282,6 +285,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
final List<Widget> children; final List<Widget> children;
final double toolBarHeight; final double toolBarHeight;
final bool? multiRowsDisplay;
/// The color of the toolbar. /// The color of the toolbar.
/// ///
@ -296,10 +300,19 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( if (multiRowsDisplay ?? true) {
constraints: BoxConstraints.tightFor(height: preferredSize.height), return Wrap(
color: color ?? Theme.of(context).canvasColor, alignment: WrapAlignment.center,
child: ArrowIndicatedButtonList(buttons: children), runSpacing: 4,
); spacing: 4,
children: children,
);
} else {
return Container(
constraints: BoxConstraints.tightFor(height: preferredSize.height),
color: color ?? Theme.of(context).canvasColor,
child: ArrowIndicatedButtonList(buttons: children),
);
}
} }
} }

Loading…
Cancel
Save