2022-09-26 13:51:18 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-27 15:43:52 +02:00
|
|
|
import 'package:provider/provider.dart';
|
2022-10-04 16:09:50 +02:00
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:flutter_web_browser/flutter_web_browser.dart';
|
2022-09-27 15:43:52 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
import 'package:adguard_home_manager/screens/settings/theme_modal.dart';
|
2022-10-10 01:26:33 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/server_info/server_info.dart';
|
2022-10-22 23:06:27 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/encryption/encryption.dart';
|
2022-10-10 01:26:33 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/access_settings/access_settings.dart';
|
2022-10-12 03:58:17 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/dhcp/dhcp.dart';
|
2022-09-27 15:43:52 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/section_label.dart';
|
2022-10-19 14:12:53 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/dns/dns.dart';
|
2022-10-15 14:47:32 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/dns_rewrites/dns_rewrites.dart';
|
2022-10-08 15:07:33 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/appbar.dart';
|
2022-09-27 18:06:49 +02:00
|
|
|
import 'package:adguard_home_manager/screens/servers/servers.dart';
|
2022-10-04 15:43:16 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/advanced_setings.dart';
|
|
|
|
import 'package:adguard_home_manager/screens/settings/general_settings.dart';
|
2022-09-27 15:43:52 +02:00
|
|
|
|
2022-10-22 23:06:27 +02:00
|
|
|
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
|
|
|
|
2022-10-04 16:09:50 +02:00
|
|
|
import 'package:adguard_home_manager/constants/strings.dart';
|
|
|
|
import 'package:adguard_home_manager/constants/urls.dart';
|
2022-09-27 18:06:49 +02:00
|
|
|
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
2022-09-27 15:43:52 +02:00
|
|
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
2022-09-26 13:51:18 +02:00
|
|
|
|
|
|
|
class Settings extends StatelessWidget {
|
|
|
|
const Settings({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-27 15:43:52 +02:00
|
|
|
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
2022-09-27 18:06:49 +02:00
|
|
|
final serversProvider = Provider.of<ServersProvider>(context);
|
2022-09-27 15:43:52 +02:00
|
|
|
|
|
|
|
final statusBarHeight = MediaQuery.of(context).viewInsets.top;
|
|
|
|
|
|
|
|
String getThemeString() {
|
|
|
|
switch (appConfigProvider.selectedThemeNumber) {
|
|
|
|
case 0:
|
|
|
|
return AppLocalizations.of(context)!.systemDefined;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
return AppLocalizations.of(context)!.light;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return AppLocalizations.of(context)!.dark;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void openThemeModal() {
|
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
|
|
|
isScrollControlled: true,
|
|
|
|
builder: (context) => ThemeModal(
|
|
|
|
statusBarHeight: statusBarHeight,
|
|
|
|
selectedTheme: appConfigProvider.selectedThemeNumber,
|
|
|
|
),
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-27 18:06:49 +02:00
|
|
|
void navigateServers() {
|
|
|
|
Future.delayed(const Duration(milliseconds: 0), (() {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(builder: (context) => const Servers())
|
|
|
|
);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2022-10-04 16:09:50 +02:00
|
|
|
void openWeb(String url) {
|
|
|
|
FlutterWebBrowser.openWebPage(
|
|
|
|
url: url,
|
|
|
|
customTabsOptions: const CustomTabsOptions(
|
|
|
|
instantAppsEnabled: true,
|
|
|
|
showTitle: true,
|
|
|
|
urlBarHidingEnabled: false,
|
|
|
|
),
|
|
|
|
safariVCOptions: const SafariViewControllerOptions(
|
|
|
|
barCollapsingEnabled: true,
|
|
|
|
dismissButtonStyle: SafariViewControllerDismissButtonStyle.close,
|
|
|
|
modalPresentationCapturesStatusBarAppearance: true,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-10-08 15:07:33 +02:00
|
|
|
return Scaffold(
|
|
|
|
appBar: const SettingsAppBar(),
|
|
|
|
body: ListView(
|
|
|
|
children: [
|
2022-10-09 01:43:09 +02:00
|
|
|
if (serversProvider.selectedServer != null) ...[
|
|
|
|
SectionLabel(label: AppLocalizations.of(context)!.serverSettings),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.lock_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.accessSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.accessSettingsDescription,
|
2022-10-09 01:43:09 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const AccessSettings()
|
|
|
|
)
|
2022-10-09 01:13:55 +02:00
|
|
|
)
|
2022-10-09 01:43:09 +02:00
|
|
|
},
|
|
|
|
),
|
2022-10-12 03:58:17 +02:00
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.install_desktop_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.dhcpSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.dhcpSettingsDescription,
|
2022-10-12 03:58:17 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const Dhcp()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2022-10-19 14:12:53 +02:00
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.dns_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.dnsSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.dnsSettingsDescription,
|
2022-10-19 14:12:53 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const DnsSettings()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2022-10-22 23:06:27 +02:00
|
|
|
CustomListTile(
|
|
|
|
icon: Icons.security_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.encryptionSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.encryptionSettingsDescription,
|
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const EncryptionSettings()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2022-10-15 14:47:32 +02:00
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.route_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.dnsRewrites,
|
|
|
|
subtitle: AppLocalizations.of(context)!.dnsRewritesDescription,
|
2022-10-15 14:47:32 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const DnsRewrites()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2022-10-09 01:43:09 +02:00
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.info_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.serverInformation,
|
|
|
|
subtitle: AppLocalizations.of(context)!.serverInformationDescription,
|
2022-10-09 01:43:09 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const ServerInformation()
|
|
|
|
)
|
2022-10-08 23:57:10 +02:00
|
|
|
)
|
2022-10-09 01:43:09 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
2022-10-08 15:07:33 +02:00
|
|
|
SectionLabel(label: AppLocalizations.of(context)!.appSettings),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.light_mode_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.theme,
|
|
|
|
subtitle: getThemeString(),
|
2022-10-08 15:07:33 +02:00
|
|
|
onTap: openThemeModal,
|
|
|
|
),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.storage_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.servers,
|
|
|
|
subtitle: serversProvider.selectedServer != null
|
2022-10-08 15:07:33 +02:00
|
|
|
? serversProvider.serverStatus.data != null
|
|
|
|
? "${AppLocalizations.of(context)!.connectedTo} ${serversProvider.selectedServer!.name}"
|
|
|
|
: "${AppLocalizations.of(context)!.selectedServer} ${serversProvider.selectedServer!.name}"
|
|
|
|
: AppLocalizations.of(context)!.noServerSelected,
|
|
|
|
onTap: navigateServers,
|
|
|
|
),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.settings,
|
|
|
|
title: AppLocalizations.of(context)!.generalSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.generalSettingsDescription,
|
2022-10-08 15:07:33 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const GeneralSettings()
|
|
|
|
)
|
2022-10-04 15:43:16 +02:00
|
|
|
)
|
2022-10-08 15:07:33 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
icon: Icons.build_outlined,
|
|
|
|
title: AppLocalizations.of(context)!.advancedSettings,
|
|
|
|
subtitle: AppLocalizations.of(context)!.advancedSetupDescription,
|
2022-10-08 15:07:33 +02:00
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const AdvancedSettings()
|
|
|
|
)
|
2022-09-30 02:24:49 +02:00
|
|
|
)
|
2022-10-08 15:07:33 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
SectionLabel(label: AppLocalizations.of(context)!.aboutApp),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
title: AppLocalizations.of(context)!.appVersion,
|
|
|
|
subtitle: appConfigProvider.getAppInfo!.version,
|
2022-10-08 15:07:33 +02:00
|
|
|
),
|
|
|
|
CustomListTile(
|
2022-10-21 02:06:53 +02:00
|
|
|
title: AppLocalizations.of(context)!.createdBy,
|
|
|
|
subtitle: Strings.createdBy,
|
2022-10-08 15:07:33 +02:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(15),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
onPressed: () => openWeb(Urls.playStore),
|
|
|
|
icon: SvgPicture.asset(
|
|
|
|
'assets/resources/google-play.svg',
|
|
|
|
color: Theme.of(context).textTheme.bodyText2!.color,
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
),
|
|
|
|
tooltip: AppLocalizations.of(context)!.visitGooglePlay,
|
2022-10-04 16:09:50 +02:00
|
|
|
),
|
2022-10-08 15:07:33 +02:00
|
|
|
IconButton(
|
|
|
|
onPressed: () => openWeb(Urls.gitHub),
|
|
|
|
icon: SvgPicture.asset(
|
|
|
|
'assets/resources/github.svg',
|
|
|
|
color: Theme.of(context).textTheme.bodyText2!.color,
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
),
|
|
|
|
tooltip: AppLocalizations.of(context)!.gitHub,
|
2022-10-04 16:09:50 +02:00
|
|
|
),
|
2022-10-08 15:07:33 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-09-27 15:43:52 +02:00
|
|
|
);
|
2022-09-26 13:51:18 +02:00
|
|
|
}
|
|
|
|
}
|