2022-09-27 14:29:36 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-26 15:22:50 +02:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
2022-09-27 14:29:36 +02:00
|
|
|
|
|
|
|
class StatusBox extends StatelessWidget {
|
|
|
|
final IconData icon;
|
|
|
|
final String label;
|
|
|
|
final bool isEnabled;
|
|
|
|
|
|
|
|
const StatusBox({
|
|
|
|
Key? key,
|
|
|
|
required this.icon,
|
|
|
|
required this.label,
|
|
|
|
required this.isEnabled
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-26 15:22:50 +02:00
|
|
|
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
|
|
|
|
2022-09-27 22:49:58 +02:00
|
|
|
return AnimatedContainer(
|
2022-09-27 14:29:36 +02:00
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
width: double.maxFinite,
|
|
|
|
height: double.maxFinite,
|
2022-09-27 22:49:58 +02:00
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
2022-09-27 14:29:36 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: isEnabled == true
|
2022-10-26 15:22:50 +02:00
|
|
|
? appConfigProvider.useThemeColorForStatus == true
|
|
|
|
? Theme.of(context).primaryColor
|
|
|
|
: Colors.green
|
|
|
|
: appConfigProvider.useThemeColorForStatus == true
|
|
|
|
? Colors.grey
|
|
|
|
: Colors.red,
|
2022-10-25 19:41:49 +02:00
|
|
|
borderRadius: BorderRadius.circular(16)
|
2022-09-27 14:29:36 +02:00
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
icon,
|
2022-10-26 15:22:50 +02:00
|
|
|
color: appConfigProvider.useThemeColorForStatus == true
|
|
|
|
? Theme.of(context).primaryColor.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
|
|
|
: Colors.grey.computeLuminance() > 0.5 ? Colors.black : Colors.white,
|
2022-09-27 14:29:36 +02:00
|
|
|
),
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
Text(
|
|
|
|
label,
|
2022-10-26 15:22:50 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: appConfigProvider.useThemeColorForStatus == true
|
|
|
|
? Theme.of(context).primaryColor.computeLuminance() > 0.5 ? Colors.black : Colors.white
|
|
|
|
: Colors.grey.computeLuminance() > 0.5 ? Colors.black : Colors.white,
|
2022-09-27 14:29:36 +02:00
|
|
|
fontWeight: FontWeight.w500
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|