Merge branch 'spike/block2-derisking'

This commit is contained in:
vjrj 2026-07-10 11:24:40 +02:00
commit 8a55034118
12 changed files with 131 additions and 66 deletions

View file

@ -409,6 +409,7 @@ class _ConfigSheet extends StatefulWidget {
class _ConfigSheetState extends State<_ConfigSheet> {
final _area = TextEditingController();
final _servers = TextEditingController();
final Set<String> _selectedRelays = {};
bool _loading = true;
bool _locationBusy = false;
String? _locationError;
@ -421,13 +422,22 @@ class _ConfigSheetState extends State<_ConfigSheet> {
Future<void> _load() async {
_area.text = await widget.settings.areaGeohash();
_servers.text = (await widget.settings.relayUrls()).join('\n');
final current = await widget.settings.relayUrls();
final presetUrls = SocialSettings.presets.map((p) => p.url).toSet();
_selectedRelays
..clear()
..addAll(current.where(presetUrls.contains));
// Any relays that aren't presets go in the "add another" field.
_servers.text = current.where((u) => !presetUrls.contains(u)).join('\n');
if (mounted) setState(() => _loading = false);
}
Future<void> _save() async {
await widget.settings.setAreaGeohash(_area.text);
await widget.settings.setRelayUrls(_servers.text.split('\n'));
await widget.settings.setRelayUrls([
..._selectedRelays,
..._servers.text.split('\n'),
]);
if (mounted) Navigator.of(context).pop(true);
}
@ -523,9 +533,40 @@ class _ConfigSheetState extends State<_ConfigSheet> {
style: const TextStyle(color: Color(0xFFB3261E), fontSize: 12),
),
),
const SizedBox(height: 8),
// The technical web address lives under progressive disclosure
// most people won't have one, and jargon shouldn't greet them.
const SizedBox(height: 16),
// Pick from a short list of shared servers pre-selected so it
// works out of the box; no jargon-y blank field to puzzle over.
Text(
t.market.serversLabel,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: seedOnSurface,
),
),
Text(
t.market.serversHelp,
style: const TextStyle(color: seedMuted, fontSize: 12, height: 1.3),
),
for (final preset in SocialSettings.presets)
CheckboxListTile(
key: Key('market.relay.${preset.name}'),
contentPadding: EdgeInsets.zero,
dense: true,
controlAffinity: ListTileControlAffinity.leading,
value: _selectedRelays.contains(preset.url),
title: Text(preset.name),
subtitle: Text(preset.url,
style: const TextStyle(fontSize: 11, color: seedMuted)),
onChanged: (checked) => setState(() {
if (checked ?? false) {
_selectedRelays.add(preset.url);
} else {
_selectedRelays.remove(preset.url);
}
}),
),
// A rarely-needed escape hatch for a community's own server.
Theme(
data: Theme.of(context)
.copyWith(dividerColor: Colors.transparent),
@ -535,21 +576,16 @@ class _ConfigSheetState extends State<_ConfigSheet> {
childrenPadding: const EdgeInsets.only(bottom: 8),
title: Text(
t.market.serversAdvanced,
style: const TextStyle(
fontSize: 14,
color: seedOnSurface,
),
style: const TextStyle(fontSize: 13, color: seedMuted),
),
children: [
TextField(
key: const Key('market.servers'),
controller: _servers,
minLines: 2,
maxLines: 4,
decoration: InputDecoration(
labelText: t.market.serversLabel,
helperText: t.market.serversHelp,
helperMaxLines: 4,
minLines: 1,
maxLines: 3,
decoration: const InputDecoration(
hintText: 'wss://…',
),
),
],