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';
|
2022-09-27 15:43:52 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.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-26 14:26:09 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/customization/customization.dart';
|
2022-10-12 03:58:17 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/dhcp/dhcp.dart';
|
2023-04-14 01:40:40 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/safe_search_settings.dart';
|
2022-10-25 21:12:00 +02:00
|
|
|
import 'package:adguard_home_manager/widgets/section_label.dart';
|
2023-04-07 16:48:58 +02:00
|
|
|
import 'package:adguard_home_manager/screens/settings/update_server/update.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-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';
|
2023-04-06 22:56:32 +02:00
|
|
|
import 'package:adguard_home_manager/functions/open_url.dart';
|
2023-04-14 01:40:40 +02:00
|
|
|
import 'package:adguard_home_manager/functions/compare_versions.dart';
|
2022-10-04 16:09:50 +02:00
|
|
|
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
|
|
|
|
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())
|
|
|
|
);
|
|
|
|
}));
|
2023-04-06 22:56:32 +02:00
|
|
|
}
|
2022-10-04 16:09:50 +02:00
|
|
|
|
2022-10-08 15:07:33 +02:00
|
|
|
return Scaffold(
|
2023-03-16 23:29:18 +01:00
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(AppLocalizations.of(context)!.settings),
|
|
|
|
centerTitle: false,
|
|
|
|
),
|
2022-10-08 15:07:33 +02:00
|
|
|
body: ListView(
|
|
|
|
children: [
|
2022-10-09 01:43:09 +02:00
|
|
|
if (serversProvider.selectedServer != null) ...[
|
|
|
|
SectionLabel(label: AppLocalizations.of(context)!.serverSettings),
|
2023-04-15 02:02:40 +02:00
|
|
|
if (serverVersionIsAhead(
|
2023-04-14 01:40:40 +02:00
|
|
|
currentVersion: serversProvider.serverStatus.data!.serverVersion,
|
|
|
|
referenceVersion: 'v0.107.28',
|
|
|
|
referenceVersionBeta: 'v0.108.0-b.33'
|
|
|
|
) == true) CustomListTile(
|
|
|
|
icon: Icons.search_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.safeSearch,
|
|
|
|
subtitle: AppLocalizations.of(context)!.safeSearchSettings,
|
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const SafeSearchSettingsScreen()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2022-10-09 01:43:09 +02:00
|
|
|
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()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2023-04-15 02:24:48 +02:00
|
|
|
if (serversProvider.updateAvailable.data != null && serversProvider.updateAvailable.data!.canAutoupdate == true) CustomListTile(
|
2023-04-06 22:56:32 +02:00
|
|
|
icon: Icons.system_update_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.updates,
|
|
|
|
subtitle: AppLocalizations.of(context)!.updatesDescription,
|
|
|
|
trailing: serversProvider.updateAvailable.data != null &&
|
|
|
|
serversProvider.updateAvailable.data!.updateAvailable != null &&
|
|
|
|
serversProvider.updateAvailable.data!.updateAvailable == true
|
|
|
|
? Container(
|
|
|
|
width: 10,
|
|
|
|
height: 10,
|
|
|
|
margin: const EdgeInsets.only(right: 12),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
color: Colors.red
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
onTap: () => {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => const UpdateScreen()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
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-26 14:26:09 +02:00
|
|
|
icon: Icons.palette_rounded,
|
|
|
|
title: AppLocalizations.of(context)!.customization,
|
|
|
|
subtitle: AppLocalizations.of(context)!.customizationDescription,
|
|
|
|
onTap: () => Navigator.push(context, MaterialPageRoute(
|
|
|
|
builder: (context) => const Customization()
|
|
|
|
))
|
2022-10-08 15:07:33 +02:00
|
|
|
),
|
|
|
|
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(
|
2023-04-06 22:56:32 +02:00
|
|
|
onPressed: () => openUrl(Urls.playStore),
|
2022-10-08 15:07:33 +02:00
|
|
|
icon: SvgPicture.asset(
|
|
|
|
'assets/resources/google-play.svg',
|
2022-11-04 22:56:00 +01:00
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
2022-10-08 15:07:33 +02:00
|
|
|
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(
|
2023-04-06 22:56:32 +02:00
|
|
|
onPressed: () => openUrl(Urls.gitHub),
|
2022-10-08 15:07:33 +02:00
|
|
|
icon: SvgPicture.asset(
|
|
|
|
'assets/resources/github.svg',
|
2022-11-04 22:56:00 +01:00
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
2022-10-08 15:07:33 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|