refactor: moving buttons into tabs.dart
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rich_editor/src/models/button.dart';
|
||||
import 'package:rich_editor/src/utils/constants.dart';
|
||||
import 'package:rich_editor/src/utils/javascript_executor_base.dart';
|
||||
import 'package:rich_editor/src/widgets/insert_link_dialog.dart';
|
||||
import 'package:rich_editor/src/widgets/tab_button.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@@ -28,13 +27,40 @@ class GroupedTab extends StatelessWidget {
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
for (Button button in buttons)
|
||||
TabButton(
|
||||
icon: button.icon,
|
||||
onTap: () async {
|
||||
button.onTap!(javascriptExecutorBase);
|
||||
},
|
||||
)
|
||||
TabButton(
|
||||
icon: Icons.format_bold,
|
||||
onTap: () async {
|
||||
await javascriptExecutorBase.setBold();
|
||||
},
|
||||
),
|
||||
TabButton(
|
||||
icon: Icons.format_italic,
|
||||
onTap: () async {
|
||||
await javascriptExecutorBase.setItalic();
|
||||
},
|
||||
),
|
||||
TabButton(
|
||||
icon: Icons.link,
|
||||
onTap: () async {
|
||||
var link = await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) {
|
||||
return InsertLinkDialog();
|
||||
},
|
||||
);
|
||||
if(link != null)
|
||||
await javascriptExecutorBase.insertLink(link[0], link[1]);
|
||||
},
|
||||
),
|
||||
TabButton(
|
||||
icon: Icons.image,
|
||||
onTap: () async {
|
||||
await javascriptExecutorBase.insertImage(
|
||||
'https://avatars.githubusercontent.com/u/24323581?v=4'
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user