refactored settings & added content blocking
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:bang_navigator/features/content_block/data/models/host.dart';
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
|
||||
@@ -10,6 +11,8 @@ class Settings with FastEquatable {
|
||||
final bool incognitoMode;
|
||||
final bool enableJavascript;
|
||||
final bool launchUrlExternal;
|
||||
final bool enableContentBlocking;
|
||||
final Set<HostSource> enableHostList;
|
||||
|
||||
Settings({
|
||||
required this.kagiSession,
|
||||
@@ -17,6 +20,8 @@ class Settings with FastEquatable {
|
||||
required this.incognitoMode,
|
||||
required this.enableJavascript,
|
||||
required this.launchUrlExternal,
|
||||
required this.enableContentBlocking,
|
||||
required this.enableHostList,
|
||||
});
|
||||
|
||||
Settings.withDefaults({
|
||||
@@ -25,10 +30,14 @@ class Settings with FastEquatable {
|
||||
bool? incognitoMode,
|
||||
bool? enableJavascript,
|
||||
bool? launchUrlExternal,
|
||||
bool? enableContentBlocking,
|
||||
Set<HostSource>? enableHostList,
|
||||
}) : showEarlyAccessFeatures = showEarlyAccessFeatures ?? true,
|
||||
incognitoMode = incognitoMode ?? true,
|
||||
enableJavascript = enableJavascript ?? true,
|
||||
launchUrlExternal = launchUrlExternal ?? false;
|
||||
launchUrlExternal = launchUrlExternal ?? false,
|
||||
enableContentBlocking = enableContentBlocking ?? true,
|
||||
enableHostList = enableHostList ?? {HostSource.stevenBlackUnified};
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
@@ -40,5 +49,7 @@ class Settings with FastEquatable {
|
||||
incognitoMode,
|
||||
enableJavascript,
|
||||
launchUrlExternal,
|
||||
enableContentBlocking,
|
||||
enableHostList,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -17,6 +17,10 @@ abstract class _$SettingsCWProxy {
|
||||
|
||||
Settings launchUrlExternal(bool launchUrlExternal);
|
||||
|
||||
Settings enableContentBlocking(bool enableContentBlocking);
|
||||
|
||||
Settings enableHostList(Set<HostSource> enableHostList);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Settings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
@@ -29,6 +33,8 @@ abstract class _$SettingsCWProxy {
|
||||
bool? incognitoMode,
|
||||
bool? enableJavascript,
|
||||
bool? launchUrlExternal,
|
||||
bool? enableContentBlocking,
|
||||
Set<HostSource>? enableHostList,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,6 +63,14 @@ class _$SettingsCWProxyImpl implements _$SettingsCWProxy {
|
||||
Settings launchUrlExternal(bool launchUrlExternal) =>
|
||||
this(launchUrlExternal: launchUrlExternal);
|
||||
|
||||
@override
|
||||
Settings enableContentBlocking(bool enableContentBlocking) =>
|
||||
this(enableContentBlocking: enableContentBlocking);
|
||||
|
||||
@override
|
||||
Settings enableHostList(Set<HostSource> enableHostList) =>
|
||||
this(enableHostList: enableHostList);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `Settings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
@@ -71,6 +85,8 @@ class _$SettingsCWProxyImpl implements _$SettingsCWProxy {
|
||||
Object? incognitoMode = const $CopyWithPlaceholder(),
|
||||
Object? enableJavascript = const $CopyWithPlaceholder(),
|
||||
Object? launchUrlExternal = const $CopyWithPlaceholder(),
|
||||
Object? enableContentBlocking = const $CopyWithPlaceholder(),
|
||||
Object? enableHostList = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return Settings(
|
||||
kagiSession: kagiSession == const $CopyWithPlaceholder()
|
||||
@@ -98,6 +114,17 @@ class _$SettingsCWProxyImpl implements _$SettingsCWProxy {
|
||||
? _value.launchUrlExternal
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: launchUrlExternal as bool,
|
||||
enableContentBlocking:
|
||||
enableContentBlocking == const $CopyWithPlaceholder() ||
|
||||
enableContentBlocking == null
|
||||
? _value.enableContentBlocking
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enableContentBlocking as bool,
|
||||
enableHostList: enableHostList == const $CopyWithPlaceholder() ||
|
||||
enableHostList == null
|
||||
? _value.enableHostList
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enableHostList as Set<HostSource>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user