fix tags panel may overscroll on iOS

This commit is contained in:
2023-09-16 21:46:03 +08:00
parent f7475cbced
commit 24f9baa7dc
7 changed files with 27 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../api/gallery.dart';
import '../globals.dart';
import '../main.dart';
import '../platform/ua.dart' as ua;
import '../utils.dart';
import 'tag.dart';
import 'tag_tooltip.dart';
import 'scroll_parent.dart';
@@ -52,6 +54,9 @@ class _TagsPanel extends State<TagsPanel> {
final stt = prefs.getBool("showTranslatedTag") ??
MainApp.of(context).lang.toLocale().languageCode == "zh";
final re = ListView.builder(
physics: isIOS || ua.isSafari
? const ClampingScrollPhysics()
: null,
padding: const EdgeInsets.all(8),
itemCount: data!.length,
itemBuilder: (context, index) {

1
lib/platform/ua.dart Normal file
View File

@@ -0,0 +1 @@
export 'ua_none.dart' if (dart.library.html) 'ua_web.dart';

View File

@@ -0,0 +1,2 @@
bool get isSafari => false;
bool get isMobile => false;

9
lib/platform/ua_web.dart Normal file
View File

@@ -0,0 +1,9 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'package:user_agent_analyzer/user_agent_analyzer.dart';
UserAgent? _ua;
UserAgent get ua => _ua ??= UserAgent(window.navigator.userAgent);
bool get isSafari => ua.isSafari;
bool get isMobile => ua.isMobile;

View File

@@ -5,6 +5,7 @@ bool get isDesktop =>
!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS);
bool get isWindows => !kIsWeb && Platform.isWindows;
bool get isAndroid => !kIsWeb && Platform.isAndroid;
bool get isIOS => !kIsWeb && Platform.isIOS;
String? getFilenameFromContentDisposition(String? contentDisposition) {
if (contentDisposition == null) {

View File

@@ -883,6 +883,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.2"
user_agent_analyzer:
dependency: "direct main"
description:
name: user_agent_analyzer
sha256: "19f8099f09e4800c3f58601c053db66592e8cd6e6a34ab3b9c21a51e0e245e28"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
uuid:
dependency: transitive
description:

View File

@@ -35,6 +35,7 @@ dependencies:
shared_preferences: ^2.2.0
super_clipboard: ^0.6.4
super_context_menu: ^0.6.4
user_agent_analyzer: ^5.0.0
window_manager: ^0.3.6
dependency_overrides: