mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 14:02:48 +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
|
@ -14,14 +14,14 @@ class HomeChart extends StatelessWidget {
|
|||
final int hoursInterval;
|
||||
|
||||
const HomeChart({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.data,
|
||||
required this.label,
|
||||
required this.primaryValue,
|
||||
required this.secondaryValue,
|
||||
required this.color,
|
||||
required this.hoursInterval
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -15,12 +15,12 @@ class MainSwitch extends StatelessWidget {
|
|||
final Animation<double> animation;
|
||||
|
||||
const MainSwitch({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.expandableController,
|
||||
required this.updateBlocking,
|
||||
required this.disableWithCountdown,
|
||||
required this.animation,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -88,12 +88,11 @@ class _TopRow extends StatelessWidget {
|
|||
final Animation<double> animation;
|
||||
|
||||
const _TopRow({
|
||||
Key? key,
|
||||
required this.legacyMode,
|
||||
required this.expandableController,
|
||||
required this.updateBlocking,
|
||||
required this.animation,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -102,9 +101,9 @@ class _TopRow extends StatelessWidget {
|
|||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
if (legacyMode == false) ...[
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
RotationTransition(
|
||||
turns: animation,
|
||||
child: Icon(
|
||||
|
@ -116,26 +115,30 @@ class _TopRow extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.allProtections,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.allProtections,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
if (statusProvider.serverStatus!.timeGeneralDisabled > 0) ...[
|
||||
const SizedBox(height: 2),
|
||||
if (statusProvider.currentDeadline != null) Text(
|
||||
"${AppLocalizations.of(context)!.remainingTime}: ${formatRemainingSeconds(statusProvider.remainingTime)}"
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
if (statusProvider.serverStatus!.timeGeneralDisabled > 0) ...[
|
||||
const SizedBox(height: 2),
|
||||
if (statusProvider.currentDeadline != null) Text(
|
||||
"${AppLocalizations.of(context)!.remainingTime}: ${formatRemainingSeconds(statusProvider.remainingTime)}"
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Switch(
|
||||
value: statusProvider.serverStatus!.generalEnabled,
|
||||
onChanged: statusProvider.protectionsManagementProcess.contains('general') == false
|
||||
|
@ -145,7 +148,7 @@ class _TopRow extends StatelessWidget {
|
|||
}
|
||||
updateBlocking(
|
||||
value: value,
|
||||
filter: legacyMode == true ? 'general_legacy' : 'general'
|
||||
filter: 'general'
|
||||
);
|
||||
} : null,
|
||||
)
|
||||
|
@ -158,9 +161,8 @@ class _BottomRow extends StatefulWidget {
|
|||
final void Function(int) disableWithCountdown;
|
||||
|
||||
const _BottomRow({
|
||||
Key? key,
|
||||
required this.disableWithCountdown,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
State<_BottomRow> createState() => _BottomRowState();
|
||||
|
@ -173,8 +175,12 @@ class _BottomRowState extends State<_BottomRow> {
|
|||
Widget build(BuildContext context) {
|
||||
final statusProvider = Provider.of<StatusProvider>(context);
|
||||
|
||||
final textScale = MediaQuery.of(context).textScaleFactor;
|
||||
|
||||
return Container(
|
||||
height: Platform.isMacOS || Platform.isLinux || Platform.isWindows ? 50 : 40,
|
||||
height: Platform.isMacOS || Platform.isLinux || Platform.isWindows
|
||||
? 50 * textScale
|
||||
: 40 * textScale,
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
child: Scrollbar(
|
||||
controller: _chipsScrollController,
|
||||
|
|
|
@ -181,12 +181,11 @@ class _Modal extends StatelessWidget {
|
|||
final Animation<double> animation;
|
||||
|
||||
const _Modal({
|
||||
Key? key,
|
||||
required this.expandableController,
|
||||
required this.updateBlocking,
|
||||
required this.disableWithCountdown,
|
||||
required this.animation,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -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
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
@ -9,11 +9,11 @@ class StatusBox extends StatelessWidget {
|
|||
final bool isEnabled;
|
||||
|
||||
const StatusBox({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.isEnabled
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue