feat: add secondary button

This commit is contained in:
Vincent Chan 2022-08-29 15:13:13 +08:00
parent fe549e8d67
commit 072d94ebe6

View File

@ -1,8 +1,14 @@
import 'package:flutter/material.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
class PopoverMenu extends StatelessWidget {
class PopoverMenu extends StatefulWidget {
@override
State<StatefulWidget> createState() => _PopoverMenuState();
}
class _PopoverMenuState extends State<PopoverMenu> {
final AppFlowyPopoverController popover = AppFlowyPopoverController();
final AppFlowyPopoverController hoverPopover = AppFlowyPopoverController();
@override
Widget build(BuildContext context) {
return Container(
@ -23,6 +29,35 @@ class PopoverMenu extends StatelessWidget {
onPressed: () {
popover.show();
},
onHover: (value) {
if (value) {
popover.show();
} else {
popover.close();
}
},
child: const Text("First"),
),
),
AppFlowyPopover(
controller: hoverPopover,
offset: const Offset(10, 0),
targetAnchor: Alignment.topRight,
followerAnchor: Alignment.topLeft,
popupBuilder: (BuildContext context) {
return PopoverMenu();
},
child: TextButton(
onPressed: () {
hoverPopover.show();
},
onHover: (value) {
if (value) {
hoverPopover.show();
} else {
hoverPopover.close();
}
},
child: const Text("Second"),
),
),