adguard-home-manager/lib/screens/home/status_box.dart

62 lines
1.9 KiB
Dart
Raw Normal View History

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
2023-01-25 20:51:23 +01:00
? Theme.of(context).colorScheme.primary
2022-10-26 15:22:50 +02:00
: 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
2023-01-25 20:51:23 +01:00
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
2022-10-26 15:22:50 +02:00
: Colors.grey.computeLuminance() > 0.5 ? Colors.black : Colors.white,
2022-09-27 14:29:36 +02:00
),
const SizedBox(width: 12),
2023-05-01 14:38:46 +02:00
Flexible(
child: Text(
label,
style: TextStyle(
color: appConfigProvider.useThemeColorForStatus == true
? Theme.of(context).colorScheme.primary.computeLuminance() > 0.5 ? Colors.black : Colors.white
: Colors.grey.computeLuminance() > 0.5 ? Colors.black : Colors.white,
fontWeight: FontWeight.w500
),
2022-09-27 14:29:36 +02:00
),
)
],
),
);
}
}