nexus/lib/widgets/html/spoiler_text.dart
Henry-Hiles d2ec5f035b
treewide: use dot shorthands where possible
Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
2026-06-02 12:50:56 -04:00

29 lines
815 B
Dart

import "package:flutter/material.dart";
import "package:flutter_hooks/flutter_hooks.dart";
class SpoilerText extends HookWidget {
final String text;
const SpoilerText({super.key, required this.text});
@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),
),
),
);
}
}