2022-09-27 14:29:36 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
import 'package:adguard_home_manager/screens/home/status_box.dart';
|
|
|
|
|
|
|
|
import 'package:adguard_home_manager/models/server_status.dart';
|
|
|
|
|
2023-05-24 13:51:22 +02:00
|
|
|
class ServerStatusWidget extends StatelessWidget {
|
|
|
|
final ServerStatus serverStatus;
|
2022-09-27 14:29:36 +02:00
|
|
|
|
2023-05-24 13:51:22 +02:00
|
|
|
const ServerStatusWidget({
|
2023-11-29 11:56:28 +01:00
|
|
|
super.key,
|
2022-09-27 14:29:36 +02:00
|
|
|
required this.serverStatus,
|
2023-11-29 11:56:28 +01:00
|
|
|
});
|
2022-09-27 14:29:36 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-05-01 14:38:46 +02:00
|
|
|
final width = MediaQuery.of(context).size.width;
|
2023-11-29 11:56:28 +01:00
|
|
|
final textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
|
|
|
|
|
|
|
double boxSize() {
|
|
|
|
if (textScaleFactor < 1 || (textScaleFactor >= 1 && textScaleFactor < 1.15)) {
|
|
|
|
return 65;
|
|
|
|
}
|
|
|
|
else if (textScaleFactor >= 1.15 && textScaleFactor < 1.3) {
|
|
|
|
return 75;
|
|
|
|
}
|
|
|
|
else if (textScaleFactor >= 1.3 && textScaleFactor < 1.45) {
|
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
else if (textScaleFactor >= 1.45 && textScaleFactor < 1.6) {
|
|
|
|
return 85;
|
|
|
|
}
|
|
|
|
else if (textScaleFactor >= 1.6 && textScaleFactor < 1.85) {
|
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
else if (textScaleFactor >= 1.85) {
|
|
|
|
return 110;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 65;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
2023-05-20 22:57:38 +02:00
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
2022-09-27 14:29:36 +02:00
|
|
|
child: Column(
|
2023-11-29 11:56:28 +01:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
2022-09-27 14:29:36 +02:00
|
|
|
children: [
|
2023-05-21 02:03:33 +02:00
|
|
|
Text(
|
|
|
|
AppLocalizations.of(context)!.serverStatus,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context).colorScheme.onSurface
|
2022-09-27 14:29:36 +02:00
|
|
|
),
|
|
|
|
),
|
2023-05-21 02:03:33 +02:00
|
|
|
const SizedBox(height: 16),
|
2023-11-29 11:56:28 +01:00
|
|
|
GridView(
|
|
|
|
primary: false,
|
|
|
|
shrinkWrap: true,
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: width > 700 ? 4 : 2,
|
|
|
|
crossAxisSpacing: 10,
|
|
|
|
mainAxisSpacing: 10,
|
|
|
|
mainAxisExtent: boxSize()
|
2022-09-27 14:29:36 +02:00
|
|
|
),
|
2023-11-29 11:56:28 +01:00
|
|
|
children: [
|
|
|
|
StatusBox(
|
|
|
|
icon: Icons.filter_list_rounded,
|
|
|
|
label: AppLocalizations.of(context)!.ruleFilteringWidget,
|
|
|
|
isEnabled: serverStatus.filteringEnabled
|
|
|
|
),
|
|
|
|
StatusBox(
|
|
|
|
icon: Icons.vpn_lock_rounded,
|
|
|
|
label: AppLocalizations.of(context)!.safeBrowsingWidget,
|
|
|
|
isEnabled: serverStatus.safeBrowsingEnabled
|
|
|
|
),
|
|
|
|
StatusBox(
|
|
|
|
icon: Icons.block,
|
|
|
|
label: AppLocalizations.of(context)!.parentalFilteringWidget,
|
|
|
|
isEnabled: serverStatus.parentalControlEnabled
|
|
|
|
),
|
|
|
|
StatusBox(
|
|
|
|
icon: Icons.search_rounded,
|
|
|
|
label: AppLocalizations.of(context)!.safeSearchWidget,
|
|
|
|
isEnabled: serverStatus.safeSearchEnabled
|
|
|
|
),
|
|
|
|
],
|
2022-09-27 14:29:36 +02:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|