@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
22import 'package:flutter_bloc/flutter_bloc.dart' ;
33import 'package:squadron_en_route/components/kancolle_model/kancolle_model.dart' ;
44import 'package:squadron_en_route/helper/mod.dart' ;
5+ import 'package:url_launcher/url_launcher.dart' ;
56
67class QuestlistView extends StatefulWidget {
78 const QuestlistView ({super .key});
@@ -12,6 +13,7 @@ class QuestlistView extends StatefulWidget {
1213
1314class QuestlistViewState extends State <QuestlistView > {
1415 late QuestlistStateData ? apiData;
16+ final flyoutCtlr = FlyoutController ();
1517
1618 @override
1719 void initState () {
@@ -56,18 +58,56 @@ class QuestlistViewState extends State<QuestlistView> {
5658 ? const Center ()
5759 : ListView .builder (
5860 itemBuilder: (context, index) {
59- return Tooltip (
60- message: apiData! .apiList[index].apiDetail,
61- child: ListTile .selectable (
62- leading: Text ('月' ),
63- title: Text (apiData! .apiList[index].apiTitle),
64- trailing: Text (
65- apiData! .apiList[index].apiState.toString ()),
66- selected: apiData! .apiList[index].apiState !=
67- QuestState .unaccepted,
61+ return FlyoutTarget (
62+ controller: flyoutCtlr,
63+ child: GestureDetector (
64+ onTapDown: (details) {
65+ _showContextMenu (
66+ context,
67+ details.globalPosition,
68+ apiData! .apiList[index].apiTitle);
69+ },
70+ child: Tooltip (
71+ message: apiData! .apiList[index].apiDetail,
72+ child: ListTile .selectable (
73+ leading: Text ('月' ),
74+ title: Text (apiData! .apiList[index].apiTitle),
75+ trailing: Text (apiData!
76+ .apiList[index].apiState
77+ .toString ()),
78+ selected: apiData! .apiList[index].apiState !=
79+ QuestState .unaccepted,
80+ ),
81+ ),
6882 ));
6983 },
7084 itemCount: apiData! .apiList.length))
7185 ]));
7286 }
87+
88+ void _showContextMenu (BuildContext content, Offset position, String quest) {
89+ flyoutCtlr.showFlyout (
90+ position: position,
91+ builder: (context) {
92+ return FlyoutContent (
93+ child: MenuFlyout (
94+ items: [
95+ MenuFlyoutItem (
96+ leading: const Icon (FluentIcons .accept),
97+ text: const Text ('google' ),
98+ onPressed: () async {
99+ final Uri url = Uri .parse (
100+ 'https://www.google.com/search?q=${Uri .encodeComponent (quest )}' );
101+ if (! await launchUrl (url)) {
102+ throw Exception ('Could not launch $url ' );
103+ }
104+ if (! context.mounted) return ;
105+ Navigator .of (context).pop ();
106+ },
107+ ),
108+ const MenuFlyoutSeparator (),
109+ ],
110+ ));
111+ });
112+ }
73113}
0 commit comments