Added open web admin panel

This commit is contained in:
Juan Gilsanz Polo 2022-10-04 15:59:01 +02:00
parent 786b14e9ba
commit 427b87ba55
5 changed files with 39 additions and 2 deletions

View file

@ -166,5 +166,6 @@
"generalSettings": "General settings",
"generalSettingsDescription": "Various different settings",
"hideZeroValues": "Hide zero values",
"hideZeroValuesDescription": "On homescreen, hide blocks with zero value"
"hideZeroValuesDescription": "On homescreen, hide blocks with zero value",
"webAdminPanel": "Web admin. panel"
}

View file

@ -166,5 +166,6 @@
"generalSettings": "Ajustes generales",
"generalSettingsDescription": "Varios ajustes generales",
"hideZeroValues": "Oculta valores a cero",
"hideZeroValuesDescription": "En la pantalla de inicio, oculta bloqueos con valor cero"
"hideZeroValuesDescription": "En la pantalla de inicio, oculta bloqueos con valor cero",
"webAdminPanel": "Panel de admin. web"
}

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:adguard_home_manager/screens/servers/servers.dart';
@ -24,6 +25,22 @@ class HomeAppBar extends StatelessWidget with PreferredSizeWidget {
}));
}
void openWebAdminPanel() {
FlutterWebBrowser.openWebPage(
url: "${server.connectionMethod}://${server.domain}${server.path ?? ""}${server.port != null ? ':${server.port}' : ""}",
customTabsOptions: const CustomTabsOptions(
instantAppsEnabled: true,
showTitle: true,
urlBarHidingEnabled: false,
),
safariVCOptions: const SafariViewControllerOptions(
barCollapsingEnabled: true,
dismissButtonStyle: SafariViewControllerDismissButtonStyle.close,
modalPresentationCapturesStatusBarAppearance: true,
)
);
}
return AppBar(
toolbarHeight: 70,
title: Padding(
@ -80,6 +97,16 @@ class HomeAppBar extends StatelessWidget with PreferredSizeWidget {
Text(AppLocalizations.of(context)!.servers)
],
),
),
if (serversProvider.serverStatus.loadStatus == 1) PopupMenuItem(
onTap: openWebAdminPanel,
child: Row(
children: [
const Icon(Icons.web_rounded),
const SizedBox(width: 10),
Text(AppLocalizations.of(context)!.webAdminPanel)
],
),
)
]
)

View file

@ -226,6 +226,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_browser:
dependency: "direct main"
description:
name: flutter_web_browser
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.1"
flutter_web_plugins:
dependency: transitive
description: flutter

View file

@ -45,6 +45,7 @@ dependencies:
uuid: ^3.0.6
expandable: ^5.0.1
fl_chart: ^0.55.2
flutter_web_browser: ^0.17.1
dev_dependencies:
flutter_test: