Skip to content

Commit 057a52b

Browse files
committed
✨: add url_launcher support and implement context menu for quest items in QuestlistView
1 parent 628ebcd commit 057a52b

File tree

12 files changed

+181
-63
lines changed

12 files changed

+181
-63
lines changed

lib/components/kancolle_model/kcsapi/get/member/questlist/questlist_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class QuestlistStateData with _$QuestlistStateData implements EquatableMixin {
5656
required int apiCompletedKind,
5757
required List<Quest> apiList, //fixit
5858
required int apiExecCount,
59-
required List<ApiClist> apiCList, //fixit
59+
// required List<ApiClist> apiCList, //fixit
6060
required int apiExecType,
6161
}) = _StateLoaded;
6262

lib/screens/home.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class _HomeViewState extends State<HomeView>
5353
),
5454
PlatformMenuItem(
5555
label: 'Receive',
56-
onSelected: () {
57-
},
56+
onSelected: () {},
5857
),
5958
]),
6059
],
@@ -63,8 +62,7 @@ class _HomeViewState extends State<HomeView>
6362
PlatformMenu(label: 'panel', menus: [
6463
PlatformMenuItem(
6564
label: context.L.menubar_webview,
66-
onSelected: () {
67-
},
65+
onSelected: () {},
6866
),
6967
PlatformMenuItem(
7068
label: 'FleetForcesCommand',
@@ -91,9 +89,13 @@ class _HomeViewState extends State<HomeView>
9189
PlatformMenuItem(
9290
label: 'quest',
9391
onSelected: () {
94-
_layout.addItemOnRoot(
95-
newItem: DockingView.createQuestlist(),
96-
dropPosition: DropPosition.top);
92+
try {
93+
_layout.addItemOnRoot(
94+
newItem: DockingView.createQuestlist(),
95+
dropPosition: DropPosition.top);
96+
} catch (e) {
97+
print(e);
98+
}
9799
},
98100
),
99101
]),
@@ -112,8 +114,7 @@ class _HomeViewState extends State<HomeView>
112114
PlatformMenu(label: 'help', menus: [
113115
PlatformMenuItem(
114116
label: 'about',
115-
onSelected: () {
116-
},
117+
onSelected: () {},
117118
),
118119
]),
119120
]),

lib/screens/questlist.dart

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:squadron_en_route/components/kancolle_model/kancolle_model.dart';
44
import 'package:squadron_en_route/helper/mod.dart';
5+
import 'package:url_launcher/url_launcher.dart';
56

67
class QuestlistView extends StatefulWidget {
78
const QuestlistView({super.key});
@@ -12,6 +13,7 @@ class QuestlistView extends StatefulWidget {
1213

1314
class 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
}

linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <desktop_drop/desktop_drop_plugin.h>
1010
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
11+
#include <url_launcher_linux/url_launcher_plugin.h>
1112
#include <window_manager/window_manager_plugin.h>
1213

1314
void fl_register_plugins(FlPluginRegistry* registry) {
@@ -17,6 +18,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
1718
g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar =
1819
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin");
1920
screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar);
21+
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
22+
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
23+
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
2024
g_autoptr(FlPluginRegistrar) window_manager_registrar =
2125
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
2226
window_manager_plugin_register_with_registrar(window_manager_registrar);

linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
list(APPEND FLUTTER_PLUGIN_LIST
66
desktop_drop
77
screen_retriever_linux
8+
url_launcher_linux
89
window_manager
910
)
1011

macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import desktop_drop
99
import flutter_inappwebview_macos
1010
import path_provider_foundation
1111
import screen_retriever_macos
12+
import url_launcher_macos
1213
import window_manager
1314

1415
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
1516
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
1617
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
1718
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
1819
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
20+
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
1921
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
2022
}

macos/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ EXTERNAL SOURCES:
3535
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
3636

3737
SPEC CHECKSUMS:
38-
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
39-
flutter_inappwebview_macos: bdf207b8f4ebd58e86ae06cd96b147de99a67c9b
38+
desktop_drop: e0b672a7d84c0a6cbc378595e82cdb15f2970a43
39+
flutter_inappwebview_macos: c2d68649f9f8f1831bfcd98d73fd6256366d9d1d
4040
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
4141
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
42-
screen_retriever_macos: 776e0fa5d42c6163d2bf772d22478df4b302b161
43-
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
42+
screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f
43+
window_manager: 1d01fa7ac65a6e6f83b965471b1a7fdd3f06166c
4444

4545
PODFILE CHECKSUM: 2e6060c123c393d6beb3ee5b7beaf789de4d2e47
4646

macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
ignoresPersistentStateOnLaunch = "NO"
7878
debugDocumentVersioning = "YES"
7979
debugServiceExtension = "internal"
80+
enableGPUValidationMode = "1"
8081
allowLocationSimulation = "YES">
8182
<BuildableProductRunnable
8283
runnableDebuggingMode = "0">

0 commit comments

Comments
 (0)