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( title: TextFormField(
onChanged: (value) => searchQuery.value = value, onChanged: (value) => searchQuery.value = value,
autofocus: true, autofocus: true,
decoration: InputDecoration.collapsed( decoration: InputDecoration(
hintText: "${localizations.searchFieldLabel}...", 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( leading: IconButton(
@@ -179,7 +187,10 @@ class PerAppProxyPage extends HookConsumerWidget with PresLogger {
package.name, package.name,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
subtitle: Text(package.packageName), subtitle: Text(
package.packageName,
style: Theme.of(context).textTheme.bodySmall,
),
value: selected, value: selected,
onChanged: (value) async { onChanged: (value) async {
final List<String> newSelection; final List<String> newSelection;

View File

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