mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 20:30:35 +00:00
Added log details modal clients
This commit is contained in:
parent
2cb5061141
commit
9b2f5f7aba
4 changed files with 108 additions and 29 deletions
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/screens/logs/log_tile.dart';
|
import 'package:adguard_home_manager/screens/logs/log_tile.dart';
|
||||||
|
import 'package:adguard_home_manager/screens/logs/log_details_screen.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/models/logs.dart';
|
import 'package:adguard_home_manager/models/logs.dart';
|
||||||
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
|
@ -163,9 +164,14 @@ class _LogsListClientState extends State<LogsListClient> {
|
||||||
log: logsData!.data[index],
|
log: logsData!.data[index],
|
||||||
index: index,
|
index: index,
|
||||||
length: logsData!.data.length,
|
length: logsData!.data.length,
|
||||||
onLogTap: (log) {
|
useAlwaysNormalTile: true,
|
||||||
|
onLogTap: (log) => showDialog(
|
||||||
}
|
context: context,
|
||||||
|
builder: (context) => LogDetailsScreen(
|
||||||
|
log: log,
|
||||||
|
dialog: true
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,12 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
|
|
||||||
class LogDetailsScreen extends StatelessWidget {
|
class LogDetailsScreen extends StatelessWidget {
|
||||||
final Log log;
|
final Log log;
|
||||||
|
final bool dialog;
|
||||||
|
|
||||||
const LogDetailsScreen({
|
const LogDetailsScreen({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.log
|
required this.log,
|
||||||
|
required this.dialog
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -105,25 +107,8 @@ class LogDetailsScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
Widget content() {
|
||||||
appBar: AppBar(
|
return ListView(
|
||||||
title: Text(AppLocalizations.of(context)!.logDetails),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () => blockUnblock(log, getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true ? 'unblock' : 'block'),
|
|
||||||
icon: Icon(
|
|
||||||
getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
|
||||||
? Icons.check_circle_rounded
|
|
||||||
: Icons.block
|
|
||||||
),
|
|
||||||
tooltip: getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
|
||||||
? AppLocalizations.of(context)!.unblockDomain
|
|
||||||
: AppLocalizations.of(context)!.blockDomain,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: ListView(
|
|
||||||
children: [
|
children: [
|
||||||
SectionLabel(label: AppLocalizations.of(context)!.status),
|
SectionLabel(label: AppLocalizations.of(context)!.status),
|
||||||
LogListTile(
|
LogListTile(
|
||||||
|
@ -247,7 +232,87 @@ class LogDetailsScreen extends StatelessWidget {
|
||||||
)).toList()
|
)).toList()
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dialog) {
|
||||||
|
return Dialog(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 500
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
icon: const Icon(Icons.clear_rounded)
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.logDetails,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => blockUnblock(log, getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true ? 'unblock' : 'block'),
|
||||||
|
icon: Icon(
|
||||||
|
getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
||||||
|
? Icons.check_circle_rounded
|
||||||
|
: Icons.block
|
||||||
|
),
|
||||||
|
tooltip: getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
||||||
|
? AppLocalizations.of(context)!.unblockDomain
|
||||||
|
: AppLocalizations.of(context)!.blockDomain,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: content(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context)!.logDetails),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => blockUnblock(log, getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true ? 'unblock' : 'block'),
|
||||||
|
icon: Icon(
|
||||||
|
getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
||||||
|
? Icons.check_circle_rounded
|
||||||
|
: Icons.block
|
||||||
|
),
|
||||||
|
tooltip: getFilteredStatus(context, appConfigProvider, log.reason, true)['filtered'] == true
|
||||||
|
? AppLocalizations.of(context)!.unblockDomain
|
||||||
|
: AppLocalizations.of(context)!.blockDomain,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: content()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ class LogTile extends StatelessWidget {
|
||||||
final int index;
|
final int index;
|
||||||
final bool? isLogSelected;
|
final bool? isLogSelected;
|
||||||
final void Function(Log) onLogTap;
|
final void Function(Log) onLogTap;
|
||||||
|
final bool? useAlwaysNormalTile;
|
||||||
|
|
||||||
const LogTile({
|
const LogTile({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -27,7 +28,8 @@ class LogTile extends StatelessWidget {
|
||||||
required this.length,
|
required this.length,
|
||||||
required this.index,
|
required this.index,
|
||||||
this.isLogSelected,
|
this.isLogSelected,
|
||||||
required this.onLogTap
|
required this.onLogTap,
|
||||||
|
this.useAlwaysNormalTile
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -100,7 +102,7 @@ class LogTile extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > 1100) {
|
if (width > 1100 && !(useAlwaysNormalTile == true)) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Material(
|
child: Material(
|
||||||
|
|
|
@ -343,7 +343,10 @@ class _LogsWidgetState extends State<LogsWidget> {
|
||||||
onLogTap: (log) {
|
onLogTap: (log) {
|
||||||
if (width <= 1100) {
|
if (width <= 1100) {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) => LogDetailsScreen(log: log)
|
builder: (context) => LogDetailsScreen(
|
||||||
|
log: log,
|
||||||
|
dialog: false,
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
setState(() => selectedLog = log);
|
setState(() => selectedLog = log);
|
||||||
|
@ -604,7 +607,10 @@ class _LogsWidgetState extends State<LogsWidget> {
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: selectedLog != null
|
child: selectedLog != null
|
||||||
? LogDetailsScreen(log: selectedLog!)
|
? LogDetailsScreen(
|
||||||
|
log: selectedLog!,
|
||||||
|
dialog: false,
|
||||||
|
)
|
||||||
: const SizedBox()
|
: const SizedBox()
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue