mirror of
https://github.com/block/buzz.git
synced 2026-10-31 22:41:12 +00:00
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
103 lines
2.4 KiB
Dart
103 lines
2.4 KiB
Dart
part of '../compose_bar.dart';
|
|
|
|
class _FormattingToolbar extends StatelessWidget {
|
|
final void Function(String prefix, [String? suffix]) onFormat;
|
|
|
|
const _FormattingToolbar({required this.onFormat});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: Grid.half),
|
|
child: Row(
|
|
children: [
|
|
_FormatButton(
|
|
icon: LucideIcons.bold,
|
|
tooltip: 'Bold',
|
|
onTap: () => onFormat('**'),
|
|
),
|
|
_FormatButton(
|
|
icon: LucideIcons.italic,
|
|
tooltip: 'Italic',
|
|
onTap: () => onFormat('_'),
|
|
),
|
|
_FormatButton(
|
|
icon: LucideIcons.strikethrough,
|
|
tooltip: 'Strikethrough',
|
|
onTap: () => onFormat('~~'),
|
|
),
|
|
_FormatButton(
|
|
icon: LucideIcons.code,
|
|
tooltip: 'Code',
|
|
onTap: () => onFormat('`'),
|
|
),
|
|
_FormatButton(
|
|
icon: LucideIcons.squareCode,
|
|
tooltip: 'Code block',
|
|
onTap: () => onFormat('```\n', '\n```'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FormatButton extends StatelessWidget {
|
|
final IconData icon;
|
|
final String tooltip;
|
|
final VoidCallback onTap;
|
|
|
|
const _FormatButton({
|
|
required this.icon,
|
|
required this.tooltip,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Tooltip(
|
|
message: tooltip,
|
|
child: InkWell(
|
|
borderRadius: BorderRadius.circular(Radii.sm),
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(Grid.xxs),
|
|
child: Icon(icon, size: 18, color: context.colors.onSurfaceVariant),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ComposeAction extends StatelessWidget {
|
|
final IconData icon;
|
|
final bool active;
|
|
final VoidCallback onTap;
|
|
|
|
const _ComposeAction({
|
|
required this.icon,
|
|
this.active = false,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: 36,
|
|
height: 36,
|
|
child: IconButton(
|
|
onPressed: onTap,
|
|
icon: Icon(
|
|
icon,
|
|
size: 20,
|
|
color: active
|
|
? context.colors.primary
|
|
: context.colors.onSurfaceVariant,
|
|
),
|
|
padding: EdgeInsets.zero,
|
|
visualDensity: VisualDensity.compact,
|
|
),
|
|
);
|
|
}
|
|
}
|