settings to choose default tab types

This commit is contained in:
Fabian Freund
2025-08-12 11:53:36 +02:00
parent f3731aa5f6
commit f70cc7acfa
22 changed files with 291 additions and 25 deletions
@@ -21,6 +21,7 @@ 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';
import 'package:weblibre/core/routing/routes.dart';
import 'package:weblibre/features/search/domain/entities/abstract/i_search_suggestion_provider.dart';
part 'general_settings.g.dart';
@@ -54,6 +55,8 @@ class GeneralSettings with FastEquatable {
final bool createChildTabsOption;
final bool showExtensionShortcut;
final bool enableLocalAiFeatures;
final TabType defaultCreateTabType;
final TabType defaultIntentTabType;
final bool proxyPrivateTabsTor;
@@ -68,6 +71,8 @@ class GeneralSettings with FastEquatable {
required this.proxyPrivateTabsTor,
required this.showExtensionShortcut,
required this.enableLocalAiFeatures,
required this.defaultCreateTabType,
required this.defaultIntentTabType,
});
GeneralSettings.withDefaults({
@@ -81,6 +86,8 @@ class GeneralSettings with FastEquatable {
bool? proxyPrivateTabsTor,
bool? showExtensionShortcut,
bool? enableLocalAiFeatures,
TabType? defaultCreateTabType,
TabType? defaultIntentTabType,
}) : themeMode = themeMode ?? ThemeMode.dark,
enableReadability = enableReadability ?? true,
enforceReadability = enforceReadability ?? false,
@@ -90,7 +97,9 @@ class GeneralSettings with FastEquatable {
createChildTabsOption = createChildTabsOption ?? false,
proxyPrivateTabsTor = proxyPrivateTabsTor ?? false,
showExtensionShortcut = showExtensionShortcut ?? false,
enableLocalAiFeatures = enableLocalAiFeatures ?? true;
enableLocalAiFeatures = enableLocalAiFeatures ?? true,
defaultCreateTabType = defaultCreateTabType ?? TabType.regular,
defaultIntentTabType = defaultIntentTabType ?? TabType.regular;
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
_$GeneralSettingsFromJson(json);
@@ -107,7 +116,9 @@ class GeneralSettings with FastEquatable {
defaultSearchSuggestionsProvider,
createChildTabsOption,
showExtensionShortcut,
proxyPrivateTabsTor,
enableLocalAiFeatures,
defaultCreateTabType,
defaultIntentTabType,
proxyPrivateTabsTor,
];
}
@@ -31,6 +31,10 @@ abstract class _$GeneralSettingsCWProxy {
GeneralSettings enableLocalAiFeatures(bool enableLocalAiFeatures);
GeneralSettings defaultCreateTabType(TabType defaultCreateTabType);
GeneralSettings defaultIntentTabType(TabType defaultIntentTabType);
/// 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
@@ -48,6 +52,8 @@ abstract class _$GeneralSettingsCWProxy {
bool proxyPrivateTabsTor,
bool showExtensionShortcut,
bool enableLocalAiFeatures,
TabType defaultCreateTabType,
TabType defaultIntentTabType,
});
}
@@ -98,6 +104,14 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
GeneralSettings enableLocalAiFeatures(bool enableLocalAiFeatures) =>
this(enableLocalAiFeatures: enableLocalAiFeatures);
@override
GeneralSettings defaultCreateTabType(TabType defaultCreateTabType) =>
this(defaultCreateTabType: defaultCreateTabType);
@override
GeneralSettings defaultIntentTabType(TabType defaultIntentTabType) =>
this(defaultIntentTabType: defaultIntentTabType);
@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.
///
@@ -116,6 +130,8 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
Object? proxyPrivateTabsTor = const $CopyWithPlaceholder(),
Object? showExtensionShortcut = const $CopyWithPlaceholder(),
Object? enableLocalAiFeatures = const $CopyWithPlaceholder(),
Object? defaultCreateTabType = const $CopyWithPlaceholder(),
Object? defaultIntentTabType = const $CopyWithPlaceholder(),
}) {
return GeneralSettings(
themeMode: themeMode == const $CopyWithPlaceholder()
@@ -164,6 +180,14 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
? _value.enableLocalAiFeatures
// ignore: cast_nullable_to_non_nullable
: enableLocalAiFeatures as bool,
defaultCreateTabType: defaultCreateTabType == const $CopyWithPlaceholder()
? _value.defaultCreateTabType
// ignore: cast_nullable_to_non_nullable
: defaultCreateTabType as TabType,
defaultIntentTabType: defaultIntentTabType == const $CopyWithPlaceholder()
? _value.defaultIntentTabType
// ignore: cast_nullable_to_non_nullable
: defaultIntentTabType as TabType,
);
}
}
@@ -196,6 +220,14 @@ GeneralSettings _$GeneralSettingsFromJson(Map<String, dynamic> json) =>
proxyPrivateTabsTor: json['proxyPrivateTabsTor'] as bool?,
showExtensionShortcut: json['showExtensionShortcut'] as bool?,
enableLocalAiFeatures: json['enableLocalAiFeatures'] as bool?,
defaultCreateTabType: $enumDecodeNullable(
_$TabTypeEnumMap,
json['defaultCreateTabType'],
),
defaultIntentTabType: $enumDecodeNullable(
_$TabTypeEnumMap,
json['defaultIntentTabType'],
),
);
Map<String, dynamic> _$GeneralSettingsToJson(GeneralSettings instance) =>
@@ -213,6 +245,8 @@ Map<String, dynamic> _$GeneralSettingsToJson(GeneralSettings instance) =>
'createChildTabsOption': instance.createChildTabsOption,
'showExtensionShortcut': instance.showExtensionShortcut,
'enableLocalAiFeatures': instance.enableLocalAiFeatures,
'defaultCreateTabType': _$TabTypeEnumMap[instance.defaultCreateTabType]!,
'defaultIntentTabType': _$TabTypeEnumMap[instance.defaultIntentTabType]!,
'proxyPrivateTabsTor': instance.proxyPrivateTabsTor,
};
@@ -238,3 +272,9 @@ const _$SearchSuggestionProvidersEnumMap = {
SearchSuggestionProviders.kagi: 'kagi',
SearchSuggestionProviders.qwant: 'qwant',
};
const _$TabTypeEnumMap = {
TabType.regular: 'regular',
TabType.private: 'private',
TabType.child: 'child',
};