buildVisibilitySection function
Builds the visibility section of settings.
Implementation
Widget buildVisibilitySection({
required bool showLocalPlaces,
required bool showEncryptedPlaces,
required bool hideAllMarkers,
required bool isLoadingEncrypted,
required bool isLoggedIn,
required void Function(bool) onShowLocalChanged,
required Function(bool) onShowEncryptedChanged, // Can be async
required void Function(bool) onHideAllMarkersChanged,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Visibility',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
),
const SizedBox(height: 8),
SwitchListTile(
title: const Text('Hide All Markers'),
subtitle: const Text('Hide all place markers on the map'),
value: hideAllMarkers,
onChanged: onHideAllMarkersChanged,
secondary: Icon(
hideAllMarkers ? Icons.visibility_off : Icons.place,
color: hideAllMarkers ? Colors.red : Colors.blue,
),
),
const SizedBox(height: 8),
SwitchListTile(
title: const Text('Show Example Locations'),
subtitle: const Text('Display canned examples on map'),
value: showLocalPlaces,
onChanged: hideAllMarkers ? null : onShowLocalChanged,
secondary: Icon(
showLocalPlaces ? Icons.visibility : Icons.visibility_off,
color: showLocalPlaces ? Colors.green : Colors.grey,
),
),
// Only show encrypted places option when logged in.
if (isLoggedIn) ...[
const SizedBox(height: 8),
SwitchListTile(
title: const Text('Show Encrypted Places'),
subtitle: Text(
isLoadingEncrypted
? 'Loading encrypted data...'
: 'Display encrypted places (requires key)',
),
value: showEncryptedPlaces,
onChanged: (isLoadingEncrypted || hideAllMarkers)
? null
: onShowEncryptedChanged,
secondary: isLoadingEncrypted
? const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Icon(
showEncryptedPlaces ? Icons.lock_open : Icons.lock,
color: showEncryptedPlaces ? Colors.purple : Colors.grey,
),
),
],
],
);
}