add tooltips

This commit is contained in:
Filip Krawczyk 2022-08-21 22:57:56 +02:00
parent 579b4e1d5d
commit cd1f7a3be3
2 changed files with 103 additions and 25 deletions

View File

@ -351,5 +351,65 @@
"no_communities_found": "No communities found",
"@no_communities_found": {},
"network_error": "Network error",
"@network_error": {}
"@network_error": {},
"editor_bold": "bold",
"@editor_bold": {
"description": "tooltip for button making text bold in markdown editor toolbar"
},
"editor_italics": "italics",
"@editor_italics": {
"description": "tooltip for button making text italics in markdown editor toolbar"
},
"editor_link": "insert link",
"@editor_link": {
"description": "tooltip for button that inserts link in markdown editor toolbar"
},
"editor_image": "insert image",
"@editor_image": {
"description": "tooltip for button that inserts image in markdown editor toolbar"
},
"editor_user": "link user",
"@editor_user": {
"description": "tooltip for button that opens a popup to select user to be linked in markdown editor toolbar"
},
"editor_community": "link community",
"@editor_community": {
"description": "tooltip for button that opens a popup to select community to be linked in markdown editor toolbar"
},
"editor_header": "insert header",
"@editor_header": {
"description": "tooltip for button that inserts header in markdown editor toolbar"
},
"editor_strikethrough": "strikethrough",
"@editor_strikethrough": {
"description": "tooltip for button that makes text strikethrough in markdown editor toolbar"
},
"editor_quote": "quote",
"@editor_quote": {
"description": "tooltip for button that makes selected text into quote blocks in markdown editor toolbar"
},
"editor_list": "list",
"@editor_list": {
"description": "tooltip for button that makes selected text into list in markdown editor toolbar"
},
"editor_code": "code",
"@editor_code": {
"description": "tooltip for button that makes text into code in markdown editor toolbar"
},
"editor_subscript": "subscript",
"@editor_subscript": {
"description": "tooltip for button that makes text into subscript in markdown editor toolbar"
},
"editor_superscript": "superscript",
"@editor_superscript": {
"description": "tooltip for button that makes text into superscript in markdown editor toolbar"
},
"editor_spoiler": "spoiler",
"@editor_spoiler": {
"description": "tooltip for button that inserts spoiler in markdown editor toolbar"
},
"editor_help": "markdown guide",
"@editor_help": {
"description": "tooltip for button that goes to page containing a guide for markdown"
}
}

View File

@ -5,6 +5,7 @@ import 'package:logging/logging.dart';
import '../../formatter.dart';
import '../../hooks/logged_in_action.dart';
import '../../l10n/l10n.dart';
import '../../resources/links.dart';
import '../../url_launcher.dart';
import '../../util/async_store_listener.dart';
@ -203,10 +204,12 @@ class _ToolbarBody extends HookWidget {
IconButton(
onPressed: () => controller.surround('**'),
icon: const Icon(Icons.format_bold),
tooltip: L10n.of(context).editor_bold,
),
IconButton(
onPressed: () => controller.surround('*'),
icon: const Icon(Icons.format_italic),
tooltip: L10n.of(context).editor_italics,
),
IconButton(
onPressed: () async {
@ -215,6 +218,7 @@ class _ToolbarBody extends HookWidget {
if (r != null) controller.reformat((_) => r);
},
icon: const Icon(Icons.link),
tooltip: L10n.of(context).editor_link,
),
// Insert image
ObserverBuilder<EditorToolbarStore>(
@ -246,6 +250,7 @@ class _ToolbarBody extends HookWidget {
icon: store.imageUploadState.isLoading
? const CircularProgressIndicator.adaptive()
: const Icon(Icons.image),
tooltip: L10n.of(context).editor_image,
);
},
),
@ -262,6 +267,7 @@ class _ToolbarBody extends HookWidget {
}
},
icon: const Icon(Icons.person),
tooltip: L10n.of(context).editor_user,
),
IconButton(
onPressed: () async {
@ -275,6 +281,7 @@ class _ToolbarBody extends HookWidget {
}
},
icon: const Icon(Icons.home),
tooltip: L10n.of(context).editor_community,
),
PopupMenuButton<HeaderLevel>(
itemBuilder: (context) => [
@ -291,63 +298,74 @@ class _ToolbarBody extends HookWidget {
controller.insertAtBeginningOfFirstSelectedLine(header);
}
},
tooltip: L10n.of(context).editor_header,
child: const Icon(Icons.h_mobiledata),
),
IconButton(
onPressed: () => controller.surround('~~'),
icon: const Icon(Icons.format_strikethrough),
tooltip: L10n.of(context).editor_strikethrough,
),
IconButton(
onPressed: () {
controller.insertAtBeginningOfEverySelectedLine('> ');
},
icon: const Icon(Icons.format_quote),
tooltip: L10n.of(context).editor_quote,
),
IconButton(
onPressed: () {
final line = controller.firstSelectedLine;
onPressed: () {
final line = controller.firstSelectedLine;
if (line.startsWith(RegExp.escape('* '))) {
controller.removeAtBeginningOfEverySelectedLine('* ');
} else if (line.startsWith('- ')) {
controller.removeAtBeginningOfEverySelectedLine('- ');
} else {
controller.insertAtBeginningOfEverySelectedLine('- ');
}
},
icon: const Icon(Icons.format_list_bulleted)),
if (line.startsWith(RegExp.escape('* '))) {
controller.removeAtBeginningOfEverySelectedLine('* ');
} else if (line.startsWith('- ')) {
controller.removeAtBeginningOfEverySelectedLine('- ');
} else {
controller.insertAtBeginningOfEverySelectedLine('- ');
}
},
icon: const Icon(Icons.format_list_bulleted),
tooltip: L10n.of(context).editor_list,
),
IconButton(
onPressed: () => controller.surround('`'),
icon: const Icon(Icons.code),
tooltip: L10n.of(context).editor_code,
),
IconButton(
onPressed: () => controller.surround('~'),
icon: const Icon(Icons.subscript),
tooltip: L10n.of(context).editor_subscript,
),
IconButton(
onPressed: () => controller.surround('^'),
icon: const Icon(Icons.superscript),
tooltip: L10n.of(context).editor_superscript,
),
//spoiler
IconButton(
onPressed: () {
controller.reformat((selection) {
final insides = selection.isNotEmpty ? selection : '___';
Logger.root
.info([21, 21 + insides.length, insides, insides.length]);
return Reformat(
text: '\n::: spoiler spoiler\n$insides\n:::\n',
selectionBeginningShift: 21,
selectionEndingShift: 21 + insides.length - selection.length,
);
});
},
icon: const Icon(Icons.warning)),
onPressed: () {
controller.reformat((selection) {
final insides = selection.isNotEmpty ? selection : '___';
Logger.root
.info([21, 21 + insides.length, insides, insides.length]);
return Reformat(
text: '\n::: spoiler spoiler\n$insides\n:::\n',
selectionBeginningShift: 21,
selectionEndingShift: 21 + insides.length - selection.length,
);
});
},
icon: const Icon(Icons.warning),
tooltip: L10n.of(context).editor_spoiler,
),
IconButton(
onPressed: () {
launchLink(link: markdownGuide, context: context);
},
icon: const Icon(Icons.question_mark),
tooltip: L10n.of(context).editor_help,
),
],
);