mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 12:24:47 +00:00
Adapt ui to support text scale
This commit is contained in:
parent
bddfac7e72
commit
c9c960d1ee
23 changed files with 624 additions and 495 deletions
|
@ -9,17 +9,43 @@ class ServerStatusWidget extends StatelessWidget {
|
|||
final ServerStatus serverStatus;
|
||||
|
||||
const ServerStatusWidget({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.serverStatus,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Container(
|
||||
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(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.serverStatus,
|
||||
|
@ -30,40 +56,39 @@ class ServerStatusWidget extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
height: width > 700 ? 66 : 146,
|
||||
child: GridView(
|
||||
padding: const EdgeInsets.all(0),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: width > 700 ? 4 : 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
mainAxisExtent: 65
|
||||
),
|
||||
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
|
||||
),
|
||||
],
|
||||
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()
|
||||
),
|
||||
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
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue