Fix per-app proxy selection

This commit is contained in:
problematicconsumer
2023-09-14 12:56:22 +03:30
parent ea6f8b5fad
commit 90fa8455ac
2 changed files with 17 additions and 4 deletions

View File

@@ -94,8 +94,16 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
title: TextFormField(
onChanged: (value) => searchQuery.value = value,
autofocus: true,
decoration: InputDecoration.collapsed(
decoration: InputDecoration(
hintText: "${localizations.searchFieldLabel}...",
isDense: true,
filled: false,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
),
),
leading: IconButton(
@@ -179,7 +187,10 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
package.name,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(package.packageName),
subtitle: Text(
package.packageName,
style: Theme.of(context).textTheme.bodySmall,
),
value: selected,
onChanged: (value) async {
final List<String> newSelection;

View File

@@ -20,7 +20,7 @@ class Pref<T> with InfraLogger {
/// Updates the value asynchronously.
Future<void> update(T value) async {
loggy.debug("updating preference [$key] to [$value]");
loggy.debug("updating preference [$key]($T) to [$value]");
try {
if (mapTo != null && mapFrom != null) {
await prefs.setString(key, mapTo!(value));
@@ -45,10 +45,12 @@ class Pref<T> with InfraLogger {
T getValue() {
try {
loggy.debug("getting persisted preference [$key]");
loggy.debug("getting persisted preference [$key]($T)");
if (mapTo != null && mapFrom != null) {
final persisted = prefs.getString(key);
return persisted != null ? mapFrom!(persisted) : defaultValue;
} else if (T == List<String>) {
return prefs.getStringList(key) as T ?? defaultValue;
}
return prefs.get(key) as T? ?? defaultValue;
} catch (e) {