wip popovers

This commit is contained in:
Henry Hiles 2026-04-24 21:22:59 -04:00
commit 6d25568c59
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
7 changed files with 136 additions and 55 deletions

58
lib/widgets/bubble.dart Normal file
View file

@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:wayland_layer_shell/types.dart';
import 'package:wayland_layer_shell/wayland_layer_shell.dart';
class Bubble extends HookWidget {
final Widget child;
final Widget? popover;
const Bubble(this.child, {this.popover, super.key});
@override
Widget build(BuildContext context) {
final isVisible = useState(false);
return PortalTarget(
visible: isVisible.value,
anchor: const Filled(),
portalFollower: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
isVisible.value = false;
WaylandLayerShell().setAnchor(ShellEdge.edgeTop, false);
},
),
child: PortalTarget(
visible: isVisible.value,
anchor: Aligned(
follower: Alignment.bottomCenter,
target: Alignment.topCenter,
),
portalFollower: popover,
child: Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Material(
color: Theme.of(context).colorScheme.surfaceContainerLow,
borderRadius: BorderRadius.circular(999),
child: InkWell(
borderRadius: BorderRadius.circular(999),
onTap: popover == null
? null
: () async {
await WaylandLayerShell().setAnchor(
ShellEdge.edgeTop,
true,
);
isVisible.value = true;
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: child,
),
),
),
),
),
);
}
}