added support for desktop mode
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:weblibre/features/geckoview/domain/providers/tab_session.dart';
|
||||||
|
|
||||||
|
part 'desktop_mode.g.dart';
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class DesktopMode extends _$DesktopMode {
|
||||||
|
// ignore: use_setters_to_change_properties
|
||||||
|
void enabled(bool value) {
|
||||||
|
state = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggle() {
|
||||||
|
state = !state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool build(String tabId) {
|
||||||
|
listenSelf((previous, next) async {
|
||||||
|
if (previous != null) {
|
||||||
|
await ref
|
||||||
|
.read(tabSessionProvider(tabId: tabId).notifier)
|
||||||
|
.requestDesktopSite(next);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'desktop_mode.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint, type=warning
|
||||||
|
|
||||||
|
@ProviderFor(DesktopMode)
|
||||||
|
const desktopModeProvider = DesktopModeFamily._();
|
||||||
|
|
||||||
|
final class DesktopModeProvider extends $NotifierProvider<DesktopMode, bool> {
|
||||||
|
const DesktopModeProvider._({
|
||||||
|
required DesktopModeFamily super.from,
|
||||||
|
required String super.argument,
|
||||||
|
}) : super(
|
||||||
|
retry: null,
|
||||||
|
name: r'desktopModeProvider',
|
||||||
|
isAutoDispose: false,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$desktopModeHash();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return r'desktopModeProvider'
|
||||||
|
''
|
||||||
|
'($argument)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
DesktopMode create() => DesktopMode();
|
||||||
|
|
||||||
|
/// {@macro riverpod.override_with_value}
|
||||||
|
Override overrideWithValue(bool value) {
|
||||||
|
return $ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
providerOverride: $SyncValueProvider<bool>(value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is DesktopModeProvider && other.argument == argument;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
return argument.hashCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$desktopModeHash() => r'18550009e95a23ff82d30206ce81daa859c57c26';
|
||||||
|
|
||||||
|
final class DesktopModeFamily extends $Family
|
||||||
|
with $ClassFamilyOverride<DesktopMode, bool, bool, bool, String> {
|
||||||
|
const DesktopModeFamily._()
|
||||||
|
: super(
|
||||||
|
retry: null,
|
||||||
|
name: r'desktopModeProvider',
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
isAutoDispose: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
DesktopModeProvider call(String tabId) =>
|
||||||
|
DesktopModeProvider._(argument: tabId, from: this);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => r'desktopModeProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _$DesktopMode extends $Notifier<bool> {
|
||||||
|
late final _$args = ref.$arg as String;
|
||||||
|
String get tabId => _$args;
|
||||||
|
|
||||||
|
bool build(String tabId);
|
||||||
|
@$mustCallSuper
|
||||||
|
@override
|
||||||
|
void runBuild() {
|
||||||
|
final created = build(_$args);
|
||||||
|
final ref = this.ref as $Ref<bool, bool>;
|
||||||
|
final element =
|
||||||
|
ref.element
|
||||||
|
as $ClassProviderElement<
|
||||||
|
AnyNotifier<bool, bool>,
|
||||||
|
bool,
|
||||||
|
Object?,
|
||||||
|
Object?
|
||||||
|
>;
|
||||||
|
element.handleValue(ref, created);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,10 @@ class TabSession extends _$TabSession {
|
|||||||
return _sessionService.requestScreenshot(requireImageResult);
|
return _sessionService.requestScreenshot(requireImageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> requestDesktopSite(bool enable) {
|
||||||
|
return _sessionService.requestDesktopSite(enable: enable);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void build({required String? tabId}) {
|
void build({required String? tabId}) {
|
||||||
_sessionService = (tabId != null)
|
_sessionService = (tabId != null)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ final class TabSessionProvider extends $NotifierProvider<TabSession, void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$tabSessionHash() => r'1b42eb21212df2c88be9f2cb10bc4ca5df437b3b';
|
String _$tabSessionHash() => r'f0a3aca70719afd37cad260c5d36621455252bfb';
|
||||||
|
|
||||||
final class TabSessionFamily extends $Family
|
final class TabSessionFamily extends $Family
|
||||||
with $ClassFamilyOverride<TabSession, void, void, void, String?> {
|
with $ClassFamilyOverride<TabSession, void, void, void, String?> {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ final class EngineBoundIntentStreamProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$engineBoundIntentStreamHash() =>
|
String _$engineBoundIntentStreamHash() =>
|
||||||
r'fa7c3e0277b25e8129a12feaadf39db6b65a1cd5';
|
r'ab9804f97e0222b2306683d2fcfa71d3d57ecd21';
|
||||||
|
|
||||||
abstract class _$EngineBoundIntentStream
|
abstract class _$EngineBoundIntentStream
|
||||||
extends $StreamNotifier<SharedContent> {
|
extends $StreamNotifier<SharedContent> {
|
||||||
|
|||||||
+32
@@ -29,6 +29,7 @@ import 'package:weblibre/core/providers/defaults.dart';
|
|||||||
import 'package:weblibre/core/routing/routes.dart';
|
import 'package:weblibre/core/routing/routes.dart';
|
||||||
import 'package:weblibre/features/geckoview/domain/controllers/bottom_sheet.dart';
|
import 'package:weblibre/features/geckoview/domain/controllers/bottom_sheet.dart';
|
||||||
import 'package:weblibre/features/geckoview/domain/providers.dart';
|
import 'package:weblibre/features/geckoview/domain/providers.dart';
|
||||||
|
import 'package:weblibre/features/geckoview/domain/providers/desktop_mode.dart';
|
||||||
import 'package:weblibre/features/geckoview/domain/providers/selected_tab.dart';
|
import 'package:weblibre/features/geckoview/domain/providers/selected_tab.dart';
|
||||||
import 'package:weblibre/features/geckoview/domain/providers/tab_session.dart';
|
import 'package:weblibre/features/geckoview/domain/providers/tab_session.dart';
|
||||||
import 'package:weblibre/features/geckoview/domain/providers/tab_state.dart';
|
import 'package:weblibre/features/geckoview/domain/providers/tab_state.dart';
|
||||||
@@ -410,6 +411,37 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
|||||||
leadingIcon: const Icon(Icons.search),
|
leadingIcon: const Icon(Icons.search),
|
||||||
child: const Text('Find in page'),
|
child: const Text('Find in page'),
|
||||||
),
|
),
|
||||||
|
if (selectedTabId != null)
|
||||||
|
Consumer(
|
||||||
|
builder: (context, childRef, child) {
|
||||||
|
final enabled = childRef.watch(
|
||||||
|
desktopModeProvider(selectedTabId),
|
||||||
|
);
|
||||||
|
|
||||||
|
return MenuItemButton(
|
||||||
|
onPressed: () {
|
||||||
|
ref
|
||||||
|
.read(desktopModeProvider(selectedTabId).notifier)
|
||||||
|
.toggle();
|
||||||
|
},
|
||||||
|
leadingIcon: const Icon(MdiIcons.monitor),
|
||||||
|
trailingIcon: Checkbox(
|
||||||
|
value: enabled,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (value != null) {
|
||||||
|
ref
|
||||||
|
.read(
|
||||||
|
desktopModeProvider(selectedTabId).notifier,
|
||||||
|
)
|
||||||
|
.enabled(value);
|
||||||
|
trippleDotMenuController.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
child: const Text('Desktop Mode'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
if (selectedTabId != null) const Divider(),
|
if (selectedTabId != null) const Divider(),
|
||||||
if (selectedTabId != null)
|
if (selectedTabId != null)
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
|
|||||||
Reference in New Issue
Block a user