mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat: manually detect and define touch behavior #1763
This commit is contained in:
parent
411115327d
commit
af60cfc067
29
lib/hooks/configurators/use_pointer_devices.dart
Normal file
29
lib/hooks/configurators/use_pointer_devices.dart
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
|
|
||||||
|
Set<PointerDeviceKind> usePointerDevices() {
|
||||||
|
final devices = useState<Set<PointerDeviceKind>>({
|
||||||
|
if (kIsMobile) PointerDeviceKind.touch,
|
||||||
|
if (kIsDesktop || kIsWeb) PointerDeviceKind.mouse,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
GestureBinding.instance.pointerRouter
|
||||||
|
.addGlobalRoute((PointerEvent event) {
|
||||||
|
if (devices.value.contains(event.kind)) return;
|
||||||
|
devices.value = {
|
||||||
|
...devices.value,
|
||||||
|
event.kind,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return devices.value;
|
||||||
|
}
|
@ -22,6 +22,7 @@ import 'package:spotube/hooks/configurators/use_deep_linking.dart';
|
|||||||
import 'package:spotube/hooks/configurators/use_disable_battery_optimizations.dart';
|
import 'package:spotube/hooks/configurators/use_disable_battery_optimizations.dart';
|
||||||
import 'package:spotube/hooks/configurators/use_fix_window_stretching.dart';
|
import 'package:spotube/hooks/configurators/use_fix_window_stretching.dart';
|
||||||
import 'package:spotube/hooks/configurators/use_get_storage_perms.dart';
|
import 'package:spotube/hooks/configurators/use_get_storage_perms.dart';
|
||||||
|
import 'package:spotube/hooks/configurators/use_pointer_devices.dart';
|
||||||
import 'package:spotube/models/database/database.dart';
|
import 'package:spotube/models/database/database.dart';
|
||||||
import 'package:spotube/provider/audio_player/audio_player_streams.dart';
|
import 'package:spotube/provider/audio_player/audio_player_streams.dart';
|
||||||
import 'package:spotube/provider/database/database.dart';
|
import 'package:spotube/provider/database/database.dart';
|
||||||
@ -92,7 +93,7 @@ Future<void> main(List<String> rawArgs) async {
|
|||||||
await FlutterDiscordRPC.initialize(Env.discordAppId);
|
await FlutterDiscordRPC.initialize(Env.discordAppId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kIsWindows){
|
if (kIsWindows) {
|
||||||
await SMTCWindows.initialize();
|
await SMTCWindows.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +143,7 @@ class Spotube extends HookConsumerWidget {
|
|||||||
final paletteColor =
|
final paletteColor =
|
||||||
ref.watch(paletteProvider.select((s) => s?.dominantColor?.color));
|
ref.watch(paletteProvider.select((s) => s?.dominantColor?.color));
|
||||||
final router = ref.watch(routerProvider);
|
final router = ref.watch(routerProvider);
|
||||||
|
final pointerDevices = usePointerDevices();
|
||||||
|
|
||||||
ref.listen(audioPlayerStreamListenersProvider, (_, __) {});
|
ref.listen(audioPlayerStreamListenersProvider, (_, __) {});
|
||||||
ref.listen(bonsoirProvider, (_, __) {});
|
ref.listen(bonsoirProvider, (_, __) {});
|
||||||
@ -179,6 +181,10 @@ class Spotube extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
|
scrollBehavior: const MaterialScrollBehavior()
|
||||||
|
..copyWith(
|
||||||
|
dragDevices: pointerDevices,
|
||||||
|
),
|
||||||
supportedLocales: L10n.all,
|
supportedLocales: L10n.all,
|
||||||
locale: locale.languageCode == "system" ? null : locale,
|
locale: locale.languageCode == "system" ? null : locale,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
|
Loading…
Reference in New Issue
Block a user