mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 22:12:53 +00:00
Refactor code management modal
This commit is contained in:
parent
a8bd57904c
commit
79cbb1beae
7 changed files with 774 additions and 651 deletions
65
lib/screens/home/management_modal/small_switch.dart
Normal file
65
lib/screens/home/management_modal/small_switch.dart
Normal file
|
@ -0,0 +1,65 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class SmallSwitch extends StatelessWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final bool value;
|
||||
final void Function(bool) onChange;
|
||||
final bool disabled;
|
||||
|
||||
const SmallSwitch({
|
||||
Key? key,
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.value,
|
||||
required this.onChange,
|
||||
required this.disabled,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: disabled == false
|
||||
? () => onChange(!value)
|
||||
: null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 44,
|
||||
vertical: 8
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 24,
|
||||
color: Theme.of(context).listTileTheme.iconColor,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Switch(
|
||||
value: value,
|
||||
onChanged: disabled == false
|
||||
? onChange
|
||||
: null,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue