push
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
@@ -6,18 +7,45 @@ part 'engine_settings.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class EngineSettings extends GeckoEngineSettings {
|
||||
class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
||||
@override
|
||||
bool get javascriptEnabled => super.javascriptEnabled!;
|
||||
@override
|
||||
TrackingProtectionPolicy get trackingProtectionPolicy =>
|
||||
super.trackingProtectionPolicy!;
|
||||
@override
|
||||
HttpsOnlyMode get httpsOnlyMode => super.httpsOnlyMode!;
|
||||
@override
|
||||
ColorScheme get preferredColorScheme => super.preferredColorScheme!;
|
||||
@override
|
||||
bool get globalPrivacyControlEnabled => super.globalPrivacyControlEnabled!;
|
||||
@override
|
||||
CookieBannerHandlingMode get cookieBannerHandlingMode =>
|
||||
super.cookieBannerHandlingMode!;
|
||||
@override
|
||||
CookieBannerHandlingMode get cookieBannerHandlingModePrivateBrowsing =>
|
||||
super.cookieBannerHandlingModePrivateBrowsing!;
|
||||
@override
|
||||
bool get cookieBannerHandlingGlobalRules =>
|
||||
super.cookieBannerHandlingGlobalRules!;
|
||||
@override
|
||||
bool get cookieBannerHandlingGlobalRulesSubFrames =>
|
||||
super.cookieBannerHandlingGlobalRulesSubFrames!;
|
||||
@override
|
||||
WebContentIsolationStrategy get webContentIsolationStrategy =>
|
||||
super.webContentIsolationStrategy!;
|
||||
|
||||
EngineSettings({
|
||||
super.javascriptEnabled,
|
||||
super.trackingProtectionPolicy,
|
||||
super.httpsOnlyMode,
|
||||
super.globalPrivacyControlEnabled,
|
||||
super.preferredColorScheme,
|
||||
super.cookieBannerHandlingMode,
|
||||
super.cookieBannerHandlingModePrivateBrowsing,
|
||||
super.cookieBannerHandlingGlobalRules,
|
||||
super.cookieBannerHandlingGlobalRulesSubFrames,
|
||||
super.webContentIsolationStrategy,
|
||||
required super.javascriptEnabled,
|
||||
required super.trackingProtectionPolicy,
|
||||
required super.httpsOnlyMode,
|
||||
required super.globalPrivacyControlEnabled,
|
||||
required super.preferredColorScheme,
|
||||
required super.cookieBannerHandlingMode,
|
||||
required super.cookieBannerHandlingModePrivateBrowsing,
|
||||
required super.cookieBannerHandlingGlobalRules,
|
||||
required super.cookieBannerHandlingGlobalRulesSubFrames,
|
||||
required super.webContentIsolationStrategy,
|
||||
});
|
||||
|
||||
EngineSettings.withDefaults({
|
||||
@@ -50,4 +78,26 @@ class EngineSettings extends GeckoEngineSettings {
|
||||
webContentIsolationStrategy: webContentIsolationStrategy ??
|
||||
WebContentIsolationStrategy.isolateHighValue,
|
||||
);
|
||||
|
||||
factory EngineSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$EngineSettingsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$EngineSettingsToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
super.javascriptEnabled,
|
||||
super.trackingProtectionPolicy,
|
||||
super.httpsOnlyMode,
|
||||
super.globalPrivacyControlEnabled,
|
||||
super.preferredColorScheme,
|
||||
super.cookieBannerHandlingMode,
|
||||
super.cookieBannerHandlingModePrivateBrowsing,
|
||||
super.cookieBannerHandlingGlobalRules,
|
||||
super.cookieBannerHandlingGlobalRulesSubFrames,
|
||||
super.webContentIsolationStrategy,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -225,22 +225,22 @@ Map<String, dynamic> _$EngineSettingsToJson(EngineSettings instance) =>
|
||||
<String, dynamic>{
|
||||
'javascriptEnabled': instance.javascriptEnabled,
|
||||
'trackingProtectionPolicy':
|
||||
_$TrackingProtectionPolicyEnumMap[instance.trackingProtectionPolicy],
|
||||
'httpsOnlyMode': _$HttpsOnlyModeEnumMap[instance.httpsOnlyMode],
|
||||
'globalPrivacyControlEnabled': instance.globalPrivacyControlEnabled,
|
||||
_$TrackingProtectionPolicyEnumMap[instance.trackingProtectionPolicy]!,
|
||||
'httpsOnlyMode': _$HttpsOnlyModeEnumMap[instance.httpsOnlyMode]!,
|
||||
'preferredColorScheme':
|
||||
_$ColorSchemeEnumMap[instance.preferredColorScheme],
|
||||
_$ColorSchemeEnumMap[instance.preferredColorScheme]!,
|
||||
'globalPrivacyControlEnabled': instance.globalPrivacyControlEnabled,
|
||||
'cookieBannerHandlingMode':
|
||||
_$CookieBannerHandlingModeEnumMap[instance.cookieBannerHandlingMode],
|
||||
_$CookieBannerHandlingModeEnumMap[instance.cookieBannerHandlingMode]!,
|
||||
'cookieBannerHandlingModePrivateBrowsing':
|
||||
_$CookieBannerHandlingModeEnumMap[
|
||||
instance.cookieBannerHandlingModePrivateBrowsing],
|
||||
instance.cookieBannerHandlingModePrivateBrowsing]!,
|
||||
'cookieBannerHandlingGlobalRules':
|
||||
instance.cookieBannerHandlingGlobalRules,
|
||||
'cookieBannerHandlingGlobalRulesSubFrames':
|
||||
instance.cookieBannerHandlingGlobalRulesSubFrames,
|
||||
'webContentIsolationStrategy': _$WebContentIsolationStrategyEnumMap[
|
||||
instance.webContentIsolationStrategy],
|
||||
instance.webContentIsolationStrategy]!,
|
||||
};
|
||||
|
||||
const _$TrackingProtectionPolicyEnumMap = {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'general_settings.g.dart';
|
||||
|
||||
enum DeleteBrowsingDataType {
|
||||
tabs('Open tabs'),
|
||||
history('Browsing history'),
|
||||
cookies('Cookies and site data', 'You’ll be logged out of most sites'),
|
||||
cache('Cached images and files', 'Frees up storage space'),
|
||||
permissions('Site permissions'),
|
||||
downloads('Downloads');
|
||||
|
||||
final String title;
|
||||
final String? description;
|
||||
|
||||
const DeleteBrowsingDataType(this.title, [this.description]);
|
||||
}
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class GeneralSettings with FastEquatable {
|
||||
final ThemeMode themeMode;
|
||||
final bool enableReadability;
|
||||
final Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit;
|
||||
|
||||
GeneralSettings({
|
||||
required this.themeMode,
|
||||
required this.enableReadability,
|
||||
required this.deleteBrowsingDataOnQuit,
|
||||
});
|
||||
|
||||
GeneralSettings.withDefaults({
|
||||
ThemeMode? themeMode,
|
||||
bool? enableReadability,
|
||||
this.deleteBrowsingDataOnQuit,
|
||||
}) : themeMode = themeMode ?? ThemeMode.dark,
|
||||
enableReadability = enableReadability ?? true;
|
||||
|
||||
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$GeneralSettingsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$GeneralSettingsToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
themeMode,
|
||||
enableReadability,
|
||||
deleteBrowsingDataOnQuit,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'general_settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$GeneralSettingsCWProxy {
|
||||
GeneralSettings themeMode(ThemeMode themeMode);
|
||||
|
||||
GeneralSettings enableReadability(bool enableReadability);
|
||||
|
||||
GeneralSettings deleteBrowsingDataOnQuit(
|
||||
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GeneralSettings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GeneralSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GeneralSettings call({
|
||||
ThemeMode themeMode,
|
||||
bool enableReadability,
|
||||
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfGeneralSettings.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfGeneralSettings.copyWith.fieldName(...)`
|
||||
class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
const _$GeneralSettingsCWProxyImpl(this._value);
|
||||
|
||||
final GeneralSettings _value;
|
||||
|
||||
@override
|
||||
GeneralSettings themeMode(ThemeMode themeMode) => this(themeMode: themeMode);
|
||||
|
||||
@override
|
||||
GeneralSettings enableReadability(bool enableReadability) =>
|
||||
this(enableReadability: enableReadability);
|
||||
|
||||
@override
|
||||
GeneralSettings deleteBrowsingDataOnQuit(
|
||||
Set<DeleteBrowsingDataType>? deleteBrowsingDataOnQuit) =>
|
||||
this(deleteBrowsingDataOnQuit: deleteBrowsingDataOnQuit);
|
||||
|
||||
@override
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `GeneralSettings(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// GeneralSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
GeneralSettings call({
|
||||
Object? themeMode = const $CopyWithPlaceholder(),
|
||||
Object? enableReadability = const $CopyWithPlaceholder(),
|
||||
Object? deleteBrowsingDataOnQuit = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GeneralSettings(
|
||||
themeMode: themeMode == const $CopyWithPlaceholder()
|
||||
? _value.themeMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: themeMode as ThemeMode,
|
||||
enableReadability: enableReadability == const $CopyWithPlaceholder()
|
||||
? _value.enableReadability
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enableReadability as bool,
|
||||
deleteBrowsingDataOnQuit:
|
||||
deleteBrowsingDataOnQuit == const $CopyWithPlaceholder()
|
||||
? _value.deleteBrowsingDataOnQuit
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: deleteBrowsingDataOnQuit as Set<DeleteBrowsingDataType>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $GeneralSettingsCopyWith on GeneralSettings {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfGeneralSettings.copyWith(...)` or like so:`instanceOfGeneralSettings.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$GeneralSettingsCWProxy get copyWith => _$GeneralSettingsCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GeneralSettings _$GeneralSettingsFromJson(Map<String, dynamic> json) =>
|
||||
GeneralSettings.withDefaults(
|
||||
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']),
|
||||
enableReadability: json['enableReadability'] as bool?,
|
||||
deleteBrowsingDataOnQuit:
|
||||
(json['deleteBrowsingDataOnQuit'] as List<dynamic>?)
|
||||
?.map((e) => $enumDecode(_$DeleteBrowsingDataTypeEnumMap, e))
|
||||
.toSet(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GeneralSettingsToJson(GeneralSettings instance) =>
|
||||
<String, dynamic>{
|
||||
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
|
||||
'enableReadability': instance.enableReadability,
|
||||
'deleteBrowsingDataOnQuit': instance.deleteBrowsingDataOnQuit
|
||||
?.map((e) => _$DeleteBrowsingDataTypeEnumMap[e]!)
|
||||
.toList(),
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
ThemeMode.system: 'system',
|
||||
ThemeMode.light: 'light',
|
||||
ThemeMode.dark: 'dark',
|
||||
};
|
||||
|
||||
const _$DeleteBrowsingDataTypeEnumMap = {
|
||||
DeleteBrowsingDataType.tabs: 'tabs',
|
||||
DeleteBrowsingDataType.history: 'history',
|
||||
DeleteBrowsingDataType.cookies: 'cookies',
|
||||
DeleteBrowsingDataType.cache: 'cache',
|
||||
DeleteBrowsingDataType.permissions: 'permissions',
|
||||
DeleteBrowsingDataType.downloads: 'downloads',
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'settings.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(includeIfNull: true, constructor: 'withDefaults')
|
||||
class Settings with FastEquatable {
|
||||
final bool incognitoMode;
|
||||
final bool enableJavascript;
|
||||
final bool blockHttpProtocol;
|
||||
final ThemeMode themeMode;
|
||||
final bool enableReadability;
|
||||
|
||||
Settings({
|
||||
required this.incognitoMode,
|
||||
required this.enableJavascript,
|
||||
required this.blockHttpProtocol,
|
||||
required this.themeMode,
|
||||
required this.enableReadability,
|
||||
});
|
||||
|
||||
Settings.withDefaults({
|
||||
bool? incognitoMode,
|
||||
bool? enableJavascript,
|
||||
bool? blockHttpProtocol,
|
||||
ThemeMode? themeMode,
|
||||
bool? enableReadability,
|
||||
}) : incognitoMode = incognitoMode ?? true,
|
||||
enableJavascript = enableJavascript ?? true,
|
||||
blockHttpProtocol = blockHttpProtocol ?? false,
|
||||
themeMode = themeMode ?? ThemeMode.dark,
|
||||
enableReadability = enableReadability ?? true;
|
||||
|
||||
factory Settings.fromJson(Map<String, dynamic> json) =>
|
||||
_$SettingsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$SettingsToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
incognitoMode,
|
||||
enableJavascript,
|
||||
blockHttpProtocol,
|
||||
themeMode,
|
||||
enableReadability,
|
||||
];
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'settings.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$SettingsCWProxy {
|
||||
Settings incognitoMode(bool incognitoMode);
|
||||
|
||||
Settings enableJavascript(bool enableJavascript);
|
||||
|
||||
Settings blockHttpProtocol(bool blockHttpProtocol);
|
||||
|
||||
Settings themeMode(ThemeMode themeMode);
|
||||
|
||||
Settings enableReadability(bool enableReadability);
|
||||
|
||||
/// 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
|
||||
/// ```dart
|
||||
/// Settings(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Settings call({
|
||||
bool incognitoMode,
|
||||
bool enableJavascript,
|
||||
bool blockHttpProtocol,
|
||||
ThemeMode themeMode,
|
||||
bool enableReadability,
|
||||
});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSettings.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSettings.copyWith.fieldName(...)`
|
||||
class _$SettingsCWProxyImpl implements _$SettingsCWProxy {
|
||||
const _$SettingsCWProxyImpl(this._value);
|
||||
|
||||
final Settings _value;
|
||||
|
||||
@override
|
||||
Settings incognitoMode(bool incognitoMode) =>
|
||||
this(incognitoMode: incognitoMode);
|
||||
|
||||
@override
|
||||
Settings enableJavascript(bool enableJavascript) =>
|
||||
this(enableJavascript: enableJavascript);
|
||||
|
||||
@override
|
||||
Settings blockHttpProtocol(bool blockHttpProtocol) =>
|
||||
this(blockHttpProtocol: blockHttpProtocol);
|
||||
|
||||
@override
|
||||
Settings themeMode(ThemeMode themeMode) => this(themeMode: themeMode);
|
||||
|
||||
@override
|
||||
Settings enableReadability(bool enableReadability) =>
|
||||
this(enableReadability: enableReadability);
|
||||
|
||||
@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.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// Settings(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
Settings call({
|
||||
Object? incognitoMode = const $CopyWithPlaceholder(),
|
||||
Object? enableJavascript = const $CopyWithPlaceholder(),
|
||||
Object? blockHttpProtocol = const $CopyWithPlaceholder(),
|
||||
Object? themeMode = const $CopyWithPlaceholder(),
|
||||
Object? enableReadability = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return Settings(
|
||||
incognitoMode: incognitoMode == const $CopyWithPlaceholder()
|
||||
? _value.incognitoMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: incognitoMode as bool,
|
||||
enableJavascript: enableJavascript == const $CopyWithPlaceholder()
|
||||
? _value.enableJavascript
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enableJavascript as bool,
|
||||
blockHttpProtocol: blockHttpProtocol == const $CopyWithPlaceholder()
|
||||
? _value.blockHttpProtocol
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: blockHttpProtocol as bool,
|
||||
themeMode: themeMode == const $CopyWithPlaceholder()
|
||||
? _value.themeMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: themeMode as ThemeMode,
|
||||
enableReadability: enableReadability == const $CopyWithPlaceholder()
|
||||
? _value.enableReadability
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: enableReadability as bool,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $SettingsCopyWith on Settings {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfSettings.copyWith(...)` or like so:`instanceOfSettings.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$SettingsCWProxy get copyWith => _$SettingsCWProxyImpl(this);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Settings _$SettingsFromJson(Map<String, dynamic> json) => Settings.withDefaults(
|
||||
incognitoMode: json['incognitoMode'] as bool?,
|
||||
enableJavascript: json['enableJavascript'] as bool?,
|
||||
blockHttpProtocol: json['blockHttpProtocol'] as bool?,
|
||||
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']),
|
||||
enableReadability: json['enableReadability'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{
|
||||
'incognitoMode': instance.incognitoMode,
|
||||
'enableJavascript': instance.enableJavascript,
|
||||
'blockHttpProtocol': instance.blockHttpProtocol,
|
||||
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
|
||||
'enableReadability': instance.enableReadability,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
ThemeMode.system: 'system',
|
||||
ThemeMode.light: 'light',
|
||||
ThemeMode.dark: 'dark',
|
||||
};
|
||||
Reference in New Issue
Block a user