adguard-home-manager/lib/screens/clients/client/settings_tile.dart

63 lines
No EOL
1.8 KiB
Dart

import 'package:flutter/material.dart';
class SettingsTile extends StatelessWidget {
final String label;
final bool? value;
final void Function(bool)? onChange;
final bool useGlobalSettingsFiltering;
const SettingsTile({
super.key,
required this.label,
required this.value,
this.onChange,
required this.useGlobalSettingsFiltering
});
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: onChange != null
? value != null ? () => onChange!(!value!) : null
: null,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
label,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
useGlobalSettingsFiltering == false
? Switch(
value: value!,
onChanged: onChange,
)
: Padding(
padding: const EdgeInsets.symmetric(
vertical: 14,
horizontal: 12
),
child: Text(
"Global",
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
)
],
),
),
),
);
}
}