nexus/lib/widgets/html/spoiler_text.dart

25 lines
783 B
Dart

import "package:material_ui/material_ui.dart";
import "package:flutter_hooks/flutter_hooks.dart";
class const SpoilerText(final String text, {super.key}) extends HookWidget {
@override
Widget build(BuildContext context) {
final revealed = useState(false);
return InkWell(
onTap: () => revealed.value = !revealed.value,
child: AnimatedContainer(
duration: const .new(milliseconds: 100),
padding: const .symmetric(horizontal: 4, vertical: 2),
decoration: BoxDecoration(
color: revealed.value ? Colors.transparent : Colors.blueGrey,
borderRadius: .circular(4),
),
child: Text(
text,
style: .new(color: revealed.value ? null : Colors.transparent),
),
),
);
}
}