added functionality to:

* info button
* spoiler button
This commit is contained in:
Filip Krawczyk 2022-08-21 20:47:30 +02:00
parent 63032ebae1
commit 462ce5df76
2 changed files with 22 additions and 2 deletions

View File

@ -1,3 +1,5 @@
const lemmurRepositoryUrl = 'https://github.com/LemmurOrg/lemmur';
const patreonUrl = 'https://patreon.com/lemmur';
const buyMeACoffeeUrl = 'https://buymeacoff.ee/lemmur';
const markdownGuide =
'https://join-lemmy.org/docs/en/about/guide.html#using-markdown';

View File

@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:logging/logging.dart';
import '../../formatter.dart';
import '../../hooks/logged_in_action.dart';
import '../../resources/links.dart';
import '../../url_launcher.dart';
import '../../util/async_store_listener.dart';
import '../../util/extensions/api.dart';
import '../../util/extensions/spaced.dart';
@ -286,9 +289,24 @@ class _ToolbarBody extends HookWidget {
icon: const Icon(Icons.superscript),
),
//spoiler
IconButton(onPressed: () {}, icon: const Icon(Icons.warning)),
IconButton(
onPressed: () {},
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)),
IconButton(
onPressed: () {
launchLink(link: markdownGuide, context: context);
},
icon: const Icon(Icons.question_mark),
),
],