try fix platformview overlap
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024-2025 Fabian Freund.
|
||||||
|
*
|
||||||
|
* This file is part of WebLibre
|
||||||
|
* (see https://weblibre.eu).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
part 'device_info.g.dart';
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class AndroidDeviceInfo extends _$AndroidDeviceInfo {
|
||||||
|
@override
|
||||||
|
Future<AndroidDeviceInfoData?> build() async {
|
||||||
|
if (!Platform.isAndroid) return null;
|
||||||
|
|
||||||
|
final deviceInfo = DeviceInfoPlugin();
|
||||||
|
final androidInfo = await deviceInfo.androidInfo;
|
||||||
|
|
||||||
|
return AndroidDeviceInfoData(sdkInt: androidInfo.version.sdkInt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AndroidDeviceInfoData {
|
||||||
|
final int sdkInt;
|
||||||
|
|
||||||
|
const AndroidDeviceInfoData({required this.sdkInt});
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'device_info.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint, type=warning
|
||||||
|
|
||||||
|
@ProviderFor(AndroidDeviceInfo)
|
||||||
|
final androidDeviceInfoProvider = AndroidDeviceInfoProvider._();
|
||||||
|
|
||||||
|
final class AndroidDeviceInfoProvider
|
||||||
|
extends $AsyncNotifierProvider<AndroidDeviceInfo, AndroidDeviceInfoData?> {
|
||||||
|
AndroidDeviceInfoProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'androidDeviceInfoProvider',
|
||||||
|
isAutoDispose: false,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$androidDeviceInfoHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
AndroidDeviceInfo create() => AndroidDeviceInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$androidDeviceInfoHash() => r'05c6cc63a6ee34f137aef538d65e8ab94b9cca89';
|
||||||
|
|
||||||
|
abstract class _$AndroidDeviceInfo
|
||||||
|
extends $AsyncNotifier<AndroidDeviceInfoData?> {
|
||||||
|
FutureOr<AndroidDeviceInfoData?> build();
|
||||||
|
@$mustCallSuper
|
||||||
|
@override
|
||||||
|
void runBuild() {
|
||||||
|
final ref =
|
||||||
|
this.ref
|
||||||
|
as $Ref<AsyncValue<AndroidDeviceInfoData?>, AndroidDeviceInfoData?>;
|
||||||
|
final element =
|
||||||
|
ref.element
|
||||||
|
as $ClassProviderElement<
|
||||||
|
AnyNotifier<
|
||||||
|
AsyncValue<AndroidDeviceInfoData?>,
|
||||||
|
AndroidDeviceInfoData?
|
||||||
|
>,
|
||||||
|
AsyncValue<AndroidDeviceInfoData?>,
|
||||||
|
Object?,
|
||||||
|
Object?
|
||||||
|
>;
|
||||||
|
element.handleCreate(ref, build);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,3 +52,26 @@ Future<GoRouter> router(Ref ref) async {
|
|||||||
initialLocation: initialLocation ?? const BrowserRoute().location,
|
initialLocation: initialLocation ?? const BrowserRoute().location,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class CurrentTopRoute extends _$CurrentTopRoute {
|
||||||
|
@override
|
||||||
|
RouteBase? build() {
|
||||||
|
final router = ref.watch(routerProvider).value;
|
||||||
|
if (router == null) return null;
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
final config = router.routerDelegate.currentConfiguration;
|
||||||
|
final match = config.last;
|
||||||
|
|
||||||
|
state = match.route;
|
||||||
|
}
|
||||||
|
|
||||||
|
router.routerDelegate.addListener(update);
|
||||||
|
ref.onDispose(() => router.routerDelegate.removeListener(update));
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -42,3 +42,55 @@ final class RouterProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$routerHash() => r'cbaa7e982114942303574f9573f4a75b79955583';
|
String _$routerHash() => r'cbaa7e982114942303574f9573f4a75b79955583';
|
||||||
|
|
||||||
|
@ProviderFor(CurrentTopRoute)
|
||||||
|
final currentTopRouteProvider = CurrentTopRouteProvider._();
|
||||||
|
|
||||||
|
final class CurrentTopRouteProvider
|
||||||
|
extends $NotifierProvider<CurrentTopRoute, RouteBase?> {
|
||||||
|
CurrentTopRouteProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'currentTopRouteProvider',
|
||||||
|
isAutoDispose: false,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$currentTopRouteHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
CurrentTopRoute create() => CurrentTopRoute();
|
||||||
|
|
||||||
|
/// {@macro riverpod.override_with_value}
|
||||||
|
Override overrideWithValue(RouteBase? value) {
|
||||||
|
return $ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
providerOverride: $SyncValueProvider<RouteBase?>(value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$currentTopRouteHash() => r'71a66713adafb5f64359eec88a69344167aae64f';
|
||||||
|
|
||||||
|
abstract class _$CurrentTopRoute extends $Notifier<RouteBase?> {
|
||||||
|
RouteBase? build();
|
||||||
|
@$mustCallSuper
|
||||||
|
@override
|
||||||
|
void runBuild() {
|
||||||
|
final ref = this.ref as $Ref<RouteBase?, RouteBase?>;
|
||||||
|
final element =
|
||||||
|
ref.element
|
||||||
|
as $ClassProviderElement<
|
||||||
|
AnyNotifier<RouteBase?, RouteBase?>,
|
||||||
|
RouteBase?,
|
||||||
|
Object?,
|
||||||
|
Object?
|
||||||
|
>;
|
||||||
|
element.handleCreate(ref, build);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+25
-1
@@ -28,6 +28,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:nullability/nullability.dart';
|
import 'package:nullability/nullability.dart';
|
||||||
import 'package:quick_actions/quick_actions.dart';
|
import 'package:quick_actions/quick_actions.dart';
|
||||||
import 'package:weblibre/core/logger.dart';
|
import 'package:weblibre/core/logger.dart';
|
||||||
|
import 'package:weblibre/core/providers/device_info.dart';
|
||||||
import 'package:weblibre/core/providers/router.dart';
|
import 'package:weblibre/core/providers/router.dart';
|
||||||
import 'package:weblibre/core/routing/routes.dart';
|
import 'package:weblibre/core/routing/routes.dart';
|
||||||
import 'package:weblibre/features/bangs/domain/providers/bangs.dart';
|
import 'package:weblibre/features/bangs/domain/providers/bangs.dart';
|
||||||
@@ -248,6 +249,26 @@ class _BrowserViewState extends ConsumerState<BrowserView>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final topRoute = ref.watch(currentTopRouteProvider);
|
||||||
|
final androidInfoAsync = ref.watch(androidDeviceInfoProvider);
|
||||||
|
|
||||||
|
final isGeckoViewVisible = androidInfoAsync.when(
|
||||||
|
data: (androidInfo) {
|
||||||
|
if (androidInfo == null) {
|
||||||
|
// Not Android, always show GeckoView based on route
|
||||||
|
return topRoute is GoRoute && topRoute.name == BrowserRoute.name;
|
||||||
|
}
|
||||||
|
// Android: only apply visibility fix on Android 12 and lower (API <= 31)
|
||||||
|
if (androidInfo.sdkInt <= 31) {
|
||||||
|
return topRoute is GoRoute && topRoute.name == BrowserRoute.name;
|
||||||
|
}
|
||||||
|
// Android 13+: always show GeckoView
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
loading: () => true, // Show by default while loading
|
||||||
|
error: (_, _) => true, // Show by default on error
|
||||||
|
);
|
||||||
|
|
||||||
return Listener(
|
return Listener(
|
||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
onPointerMove: (widget.pointerMoveEventSink != null)
|
onPointerMove: (widget.pointerMoveEventSink != null)
|
||||||
@@ -259,7 +280,9 @@ class _BrowserViewState extends ConsumerState<BrowserView>
|
|||||||
: null,
|
: null,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
GeckoView(
|
Visibility(
|
||||||
|
visible: isGeckoViewVisible,
|
||||||
|
child: GeckoView(
|
||||||
preInitializationStep: () async {
|
preInitializationStep: () async {
|
||||||
await ref
|
await ref
|
||||||
.read(eventServiceProvider)
|
.read(eventServiceProvider)
|
||||||
@@ -325,6 +348,7 @@ class _BrowserViewState extends ConsumerState<BrowserView>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (!hasTab)
|
if (!hasTab)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: SizedBox.expand(
|
child: SizedBox.expand(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ dependencies:
|
|||||||
country_codes: ^3.3.0
|
country_codes: ^3.3.0
|
||||||
country_flags: ^4.1.1
|
country_flags: ^4.1.1
|
||||||
cryptography_flutter: ^2.3.4
|
cryptography_flutter: ^2.3.4
|
||||||
|
device_info_plus: ^12.3.0
|
||||||
drift: ^2.30.1
|
drift: ^2.30.1
|
||||||
drift_dev: ^2.30.1
|
drift_dev: ^2.30.1
|
||||||
dynamic_color: ^1.8.1
|
dynamic_color: ^1.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user