prepare for multiple apps

This commit is contained in:
Fabian Freund
2026-04-06 12:23:11 +02:00
parent bd1600e8dc
commit 5afc323f04
904 changed files with 29 additions and 29 deletions
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024-2026 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 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'readerable.g.dart';
@Riverpod(keepAlive: true)
GeckoReaderableService readerableService(Ref ref) {
final service = GeckoReaderableService.setUp();
ref.onDispose(() async {
await service.dispose();
});
return service;
}
@Riverpod()
Stream<bool> appearanceButtonVisibility(Ref ref) {
final service = ref.watch(readerableServiceProvider);
return service.appearanceVisibility;
}
@@ -0,0 +1,92 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'readerable.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(readerableService)
final readerableServiceProvider = ReaderableServiceProvider._();
final class ReaderableServiceProvider
extends
$FunctionalProvider<
GeckoReaderableService,
GeckoReaderableService,
GeckoReaderableService
>
with $Provider<GeckoReaderableService> {
ReaderableServiceProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'readerableServiceProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$readerableServiceHash();
@$internal
@override
$ProviderElement<GeckoReaderableService> $createElement(
$ProviderPointer pointer,
) => $ProviderElement(pointer);
@override
GeckoReaderableService create(Ref ref) {
return readerableService(ref);
}
/// {@macro riverpod.override_with_value}
Override overrideWithValue(GeckoReaderableService value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<GeckoReaderableService>(value),
);
}
}
String _$readerableServiceHash() => r'0c432ede496d85ed6a7d028af346b129d97f7502';
@ProviderFor(appearanceButtonVisibility)
final appearanceButtonVisibilityProvider =
AppearanceButtonVisibilityProvider._();
final class AppearanceButtonVisibilityProvider
extends $FunctionalProvider<AsyncValue<bool>, bool, Stream<bool>>
with $FutureModifier<bool>, $StreamProvider<bool> {
AppearanceButtonVisibilityProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'appearanceButtonVisibilityProvider',
isAutoDispose: true,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$appearanceButtonVisibilityHash();
@$internal
@override
$StreamProviderElement<bool> $createElement($ProviderPointer pointer) =>
$StreamProviderElement(pointer);
@override
Stream<bool> create(Ref ref) {
return appearanceButtonVisibility(ref);
}
}
String _$appearanceButtonVisibilityHash() =>
r'e7102b63113937dd5d17028a5ec8dac428c38bbb';
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024-2026 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 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:weblibre/features/geckoview/domain/providers.dart';
import 'package:weblibre/features/geckoview/features/readerview/domain/providers/readerable.dart';
part 'readerable.g.dart';
@Riverpod(keepAlive: true)
class ReaderableScreenController extends _$ReaderableScreenController {
late GeckoReaderableService _service;
Future<void> toggleReaderView(bool enable) async {
state = const AsyncValue.loading();
final eventChange = ref.read(eventServiceProvider).readerableEvents.first;
final toggle = _service.toggleReaderView(enable);
state = await AsyncValue.guard(() => Future.wait([toggle, eventChange]));
}
@override
Future<void> build() {
_service = ref.watch(readerableServiceProvider);
return Future.value();
}
}
@@ -0,0 +1,56 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'readerable.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(ReaderableScreenController)
final readerableScreenControllerProvider =
ReaderableScreenControllerProvider._();
final class ReaderableScreenControllerProvider
extends $AsyncNotifierProvider<ReaderableScreenController, void> {
ReaderableScreenControllerProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'readerableScreenControllerProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$readerableScreenControllerHash();
@$internal
@override
ReaderableScreenController create() => ReaderableScreenController();
}
String _$readerableScreenControllerHash() =>
r'62b2167ff8f9fe21c3cf3339e135a50aa684160c';
abstract class _$ReaderableScreenController extends $AsyncNotifier<void> {
FutureOr<void> build();
@$mustCallSuper
@override
void runBuild() {
final ref = this.ref as $Ref<AsyncValue<void>, void>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<AsyncValue<void>, void>,
AsyncValue<void>,
Object?,
Object?
>;
element.handleCreate(ref, build);
}
}
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2024-2026 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 'package:flutter/material.dart';
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:weblibre/features/geckoview/domain/entities/states/readerable.dart';
import 'package:weblibre/features/geckoview/domain/providers/tab_state.dart';
import 'package:weblibre/features/geckoview/features/readerview/presentation/controllers/readerable.dart';
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
import 'package:weblibre/presentation/widgets/animate_gradient_shader.dart';
class ReaderButton extends HookConsumerWidget {
final Widget Function(bool isLoading, bool readerActive, Widget icon)
buttonBuilder;
const ReaderButton({super.key, required this.buttonBuilder});
@override
Widget build(BuildContext context, WidgetRef ref) {
final colorScheme = Theme.of(context).colorScheme;
final readerChanging = ref.watch(readerableScreenControllerProvider);
final enableReadability = ref.watch(
generalSettingsWithDefaultsProvider.select(
(value) => value.enableReadability,
),
);
final enforceReadability = ref.watch(
generalSettingsWithDefaultsProvider.select(
(value) => value.enforceReadability,
),
);
final readerabilityState = ref.watch(
selectedTabStateProvider.select(
(state) => state?.readerableState ?? ReaderableState.$default(),
),
);
final icon = readerabilityState.active
? Icon(MdiIcons.bookOpen, color: Theme.of(context).colorScheme.primary)
: Icon(
MdiIcons.bookOpenOutline,
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
return Visibility(
visible:
(readerabilityState.readerable &&
(enableReadability || readerabilityState.active)) ||
(enforceReadability && enableReadability),
child: readerChanging.when(
skipLoadingOnReload: true,
data: (_) => buttonBuilder(
readerChanging.isLoading,
readerabilityState.active,
icon,
),
error: (error, stackTrace) =>
Center(child: Icon(Icons.error_outline, color: colorScheme.error)),
loading: () => AnimateGradientShader(
duration: const Duration(milliseconds: 500),
primaryEnd: Alignment.bottomLeft,
secondaryEnd: Alignment.topRight,
primaryColors: [colorScheme.primary, colorScheme.primaryContainer],
secondaryColors: [
colorScheme.secondary,
colorScheme.secondaryContainer,
],
child: buttonBuilder(true, readerabilityState.active, icon),
),
),
);
}
}