mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-07 01:06:39 +10:00
Add option for automatic zerohop adverts on posision change.
This commit is contained in:
@@ -4,6 +4,7 @@ class FeatureToggleRow extends StatefulWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final bool value;
|
||||
final bool enabled;
|
||||
final bool hasRefreshing;
|
||||
final bool isRefreshing;
|
||||
final ValueChanged<bool>? onChanged;
|
||||
@@ -15,6 +16,7 @@ class FeatureToggleRow extends StatefulWidget {
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.value,
|
||||
this.enabled = true,
|
||||
this.hasRefreshing = false,
|
||||
this.isRefreshing = false,
|
||||
this.onChanged,
|
||||
@@ -31,6 +33,13 @@ class _FeatureToggleRow extends State<FeatureToggleRow> {
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
final isEnabled = widget.enabled;
|
||||
final titleColor = isEnabled
|
||||
? scheme.onSurface
|
||||
: scheme.onSurfaceVariant.withValues(alpha: 0.7);
|
||||
final subtitleColor = isEnabled
|
||||
? scheme.onSurfaceVariant
|
||||
: scheme.onSurfaceVariant.withValues(alpha: 0.55);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
@@ -44,14 +53,13 @@ class _FeatureToggleRow extends State<FeatureToggleRow> {
|
||||
widget.title,
|
||||
style: textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
widget.subtitle,
|
||||
style: textTheme.bodySmall?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
style: textTheme.bodySmall?.copyWith(color: subtitleColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -60,7 +68,18 @@ class _FeatureToggleRow extends State<FeatureToggleRow> {
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Switch(value: widget.value, onChanged: widget.onChanged),
|
||||
Switch(
|
||||
value: widget.value,
|
||||
onChanged: isEnabled ? widget.onChanged : null,
|
||||
thumbColor: !isEnabled
|
||||
? WidgetStatePropertyAll<Color?>(scheme.onSurfaceVariant)
|
||||
: null,
|
||||
trackColor: !isEnabled
|
||||
? WidgetStatePropertyAll<Color?>(
|
||||
scheme.onSurfaceVariant.withValues(alpha: 0.35),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
if (widget.hasRefreshing) ...[
|
||||
const SizedBox(width: 4),
|
||||
widget.isRefreshing
|
||||
@@ -74,7 +93,7 @@ class _FeatureToggleRow extends State<FeatureToggleRow> {
|
||||
)
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.refresh, size: 18),
|
||||
onPressed: widget.onRefresh,
|
||||
onPressed: isEnabled ? widget.onRefresh : null,
|
||||
tooltip: widget.refreshTooltip,
|
||||
visualDensity: VisualDensity.compact,
|
||||
padding: EdgeInsets.zero,
|
||||
|
||||
Reference in New Issue
Block a user