added list view; persist tab view ui settings;
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
* 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:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:riverpod/experimental/persist.dart';
|
||||
import 'package:riverpod_annotation/experimental/json_persist.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/features/geckoview/features/history/domain/entities/history_filter_options.dart';
|
||||
import 'package:weblibre/features/geckoview/features/history/domain/repositories/history.dart';
|
||||
@@ -30,6 +29,7 @@ import 'package:weblibre/features/user/data/providers.dart';
|
||||
part 'providers.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
@JsonPersist()
|
||||
class HistoryFilter extends _$HistoryFilter {
|
||||
void updateVisitType(VisitType type, bool value) {
|
||||
if (value) {
|
||||
@@ -49,15 +49,9 @@ class HistoryFilter extends _$HistoryFilter {
|
||||
|
||||
@override
|
||||
HistoryFilterOptions build() {
|
||||
final riverpodStorage = ref.watch(riverpodDatabaseStorageProvider);
|
||||
|
||||
persist(
|
||||
riverpodStorage,
|
||||
ref.watch(riverpodDatabaseStorageProvider),
|
||||
key: 'HistoryFilterOptions',
|
||||
decode: (encoded) => HistoryFilterOptions.fromJson(
|
||||
jsonDecode(encoded) as Map<String, dynamic>,
|
||||
),
|
||||
encode: (state) => jsonEncode(state.toJson()),
|
||||
);
|
||||
|
||||
return stateOrNull ?? HistoryFilterOptions.withDefaults();
|
||||
|
||||
@@ -10,8 +10,10 @@ part of 'providers.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(HistoryFilter)
|
||||
@JsonPersist()
|
||||
const historyFilterProvider = HistoryFilterProvider._();
|
||||
|
||||
@JsonPersist()
|
||||
final class HistoryFilterProvider
|
||||
extends $NotifierProvider<HistoryFilter, HistoryFilterOptions> {
|
||||
const HistoryFilterProvider._()
|
||||
@@ -41,9 +43,10 @@ final class HistoryFilterProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$historyFilterHash() => r'1f8269e5f1227d6efde194e00c3d79a268ab1e4d';
|
||||
String _$historyFilterHash() => r'685b92590011ec450ef0c19820e4a6750d26b79d';
|
||||
|
||||
abstract class _$HistoryFilter extends $Notifier<HistoryFilterOptions> {
|
||||
@JsonPersist()
|
||||
abstract class _$HistoryFilterBase extends $Notifier<HistoryFilterOptions> {
|
||||
HistoryFilterOptions build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
@@ -100,3 +103,40 @@ final class BrowsingHistoryProvider
|
||||
}
|
||||
|
||||
String _$browsingHistoryHash() => r'3b6ee5853387481d7544bc9733741a5519f84f40';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
abstract class _$HistoryFilter extends _$HistoryFilterBase {
|
||||
/// The default key used by [persist].
|
||||
String get key {
|
||||
const resolvedKey = "HistoryFilter";
|
||||
return resolvedKey;
|
||||
}
|
||||
|
||||
/// A variant of [persist], for JSON-specific encoding.
|
||||
///
|
||||
/// You can override [key] to customize the key used for storage.
|
||||
PersistResult persist(
|
||||
FutureOr<Storage<String, String>> storage, {
|
||||
String? key,
|
||||
String Function(HistoryFilterOptions state)? encode,
|
||||
HistoryFilterOptions Function(String encoded)? decode,
|
||||
StorageOptions options = const StorageOptions(),
|
||||
}) {
|
||||
return NotifierPersistX(this).persist<String, String>(
|
||||
storage,
|
||||
key: key ?? this.key,
|
||||
encode: encode ?? $jsonCodex.encode,
|
||||
decode:
|
||||
decode ??
|
||||
(encoded) {
|
||||
final e = $jsonCodex.decode(encoded);
|
||||
return HistoryFilterOptions.fromJson(e as Map<String, Object?>);
|
||||
},
|
||||
options: options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user