feat: Per-contact path size selector in route editor

This commit is contained in:
Janez T
2026-03-17 08:55:37 +01:00
parent a76ee4f8f6
commit 464fc5e715

View File

@@ -164,7 +164,12 @@ class _ContactRouteDialogState extends State<ContactRouteDialog> {
} }
Future<void> _loadHashSizePreference() async { Future<void> _loadHashSizePreference() async {
final hashSize = await RouteHashPreferences.getHashSize(); // Use the contact's current path hash size if it has a path,
// otherwise fall back to the global preference.
final contactHashSize = widget.contact.hasPath
? widget.contact.pathHashSize
: null;
final hashSize = contactHashSize ?? await RouteHashPreferences.getHashSize();
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_selectedHashSize = hashSize; _selectedHashSize = hashSize;
@@ -594,7 +599,7 @@ class _ContactRouteDialogState extends State<ContactRouteDialog> {
? 'AABB,CCDD' ? 'AABB,CCDD'
: 'AABBCC,DDEEFF', : 'AABBCC,DDEEFF',
helperText: helperText:
'Comma-separated hops. Hash size follows global Settings. Colon form like AA:BB is also accepted.', 'Comma-separated hops using the selected path size. Colon form like AA:BB is also accepted.',
errorText: _errorText, errorText: _errorText,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
), ),
@@ -690,6 +695,32 @@ class _ContactRouteDialogState extends State<ContactRouteDialog> {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row(
children: [
Text(
'Path Size',
style: Theme.of(context).textTheme.labelLarge,
),
const Spacer(),
SegmentedButton<int>(
segments: [
for (final size in RouteHashPreferences.supportedSizes)
ButtonSegment<int>(
value: size,
label: Text('${size}B'),
),
],
selected: {_selectedHashSize},
onSelectionChanged: (selection) {
setState(() {
_selectedHashSize = selection.first;
_syncControllerFromSelectedHops();
});
},
),
],
),
const SizedBox(height: 12),
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,