diff --git a/.editorconfig b/.editorconfig index 80a3e35b..206f5ceb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,6 @@ max_line_length = 150 [*.md] trim_trailing_whitespace = false + +[*.json] +indent_size = 4 diff --git a/assets/translations/en.json b/assets/translations/en.json index c849e266..d5adf64d 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -2,6 +2,7 @@ "test": "en-test", "locale": "en", "basis": { + "app_name": "SelfPrivacy", "providers": "Providers", "providers_title": "Your Data Center", "select": "Select", @@ -59,8 +60,11 @@ }, "application_settings": { "title": "Application settings", + "system_dark_theme_title": "System default theme", + "system_dark_theme_description": "Use light or dark theme depending on system settings", "dark_theme_title": "Dark theme", "dark_theme_description": "Switch your application theme", + "dangerous_settings": "Dangerous settings", "reset_config_title": "Reset application config", "reset_config_description": "Reset api keys and root user", "delete_server_title": "Delete server", @@ -472,5 +476,19 @@ "root_name": "Cannot be 'root'", "length_not_equal": "Length is [], should be {}", "length_longer": "Length is [], should be shorter than or equal to {}" + }, + "support": { + "title": "SelfPrivacy Support" + }, + "developer_settings": { + "title": "Developer settings", + "subtitle": "These settings are for debugging only. Don't change them unless you know what you're doing.", + "server_setup": "Server setup", + "use_staging_acme": "Use staging ACME server", + "use_staging_acme_description": "Rebuild your app to change this value.", + "routing": "App routing", + "reset_onboarding": "Reset onboarding switch", + "reset_onboarding_description": "Reset onboarding switch to show onboarding screen again", + "cubit_statuses": "Cubit loading statuses" } } diff --git a/lib/config/bloc_config.dart b/lib/config/bloc_config.dart index 6c870f9e..381261fe 100644 --- a/lib/config/bloc_config.dart +++ b/lib/config/bloc_config.dart @@ -12,6 +12,7 @@ import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart'; import 'package:selfprivacy/logic/cubit/services/services_cubit.dart'; +import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart'; import 'package:selfprivacy/logic/cubit/users/users_cubit.dart'; import 'package:selfprivacy/logic/cubit/provider_volumes/provider_volume_cubit.dart'; @@ -23,7 +24,9 @@ class BlocAndProviderConfig extends StatelessWidget { @override Widget build(final BuildContext context) { const isDark = false; + const isAutoDark = true; final serverInstallationCubit = ServerInstallationCubit()..load(); + final supportSystemCubit = SupportSystemCubit(); final usersCubit = UsersCubit(serverInstallationCubit); final servicesCubit = ServicesCubit(serverInstallationCubit); final backupsCubit = BackupsCubit(serverInstallationCubit); @@ -41,9 +44,13 @@ class BlocAndProviderConfig extends StatelessWidget { BlocProvider( create: (final _) => AppSettingsCubit( isDarkModeOn: isDark, + isAutoDarkModeOn: isAutoDark, isOnboardingShowing: true, )..load(), ), + BlocProvider( + create: (final _) => supportSystemCubit, + ), BlocProvider( create: (final _) => serverInstallationCubit, lazy: false, diff --git a/lib/logic/cubit/support_system/support_system_cubit.dart b/lib/logic/cubit/support_system/support_system_cubit.dart new file mode 100644 index 00000000..b6250740 --- /dev/null +++ b/lib/logic/cubit/support_system/support_system_cubit.dart @@ -0,0 +1,19 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:flutter/material.dart'; + +part 'support_system_state.dart'; + +class SupportSystemCubit extends Cubit { + SupportSystemCubit() : super(const SupportSystemState('about')); + + void showArticle({ + required final String article, + final BuildContext? context, + }) { + emit(SupportSystemState(article)); + if (context != null) { + Scaffold.of(context).openEndDrawer(); + } + } +} diff --git a/lib/logic/cubit/support_system/support_system_state.dart b/lib/logic/cubit/support_system/support_system_state.dart new file mode 100644 index 00000000..0c3c3087 --- /dev/null +++ b/lib/logic/cubit/support_system/support_system_state.dart @@ -0,0 +1,12 @@ +part of 'support_system_cubit.dart'; + +class SupportSystemState extends Equatable { + const SupportSystemState( + this.currentArticle, + ); + + final String currentArticle; + + @override + List get props => [currentArticle]; +} diff --git a/lib/ui/components/support_drawer/support_drawer.dart b/lib/ui/components/support_drawer/support_drawer.dart new file mode 100644 index 00000000..7b4c5c2b --- /dev/null +++ b/lib/ui/components/support_drawer/support_drawer.dart @@ -0,0 +1,52 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart'; +import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; + +class SupportDrawer extends StatelessWidget { + const SupportDrawer({ + super.key, + }); + + @override + Widget build(final BuildContext context) { + final currentArticle = + context.watch().state.currentArticle; + return Drawer( + width: 440, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Row( + children: [ + const SizedBox(width: 8), + const Icon(Icons.help_outline), + const SizedBox(width: 16), + Text( + 'support.title'.tr(), + style: Theme.of(context).textTheme.titleLarge, + ), + const Spacer(), + IconButton( + onPressed: () => Scaffold.of(context).closeEndDrawer(), + icon: const Icon(Icons.chevron_right_outlined), + ), + ], + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.all(8.0), + child: BrandMarkdown( + fileName: currentArticle, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 39fcd88f..44d368aa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -390,14 +390,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_adaptive_scaffold: - dependency: "direct main" - description: - name: flutter_adaptive_scaffold - sha256: d5842a235ec810320c7e6dac282876d93bccf231201be6e684b016cd717c0576 - url: "https://pub.dev" - source: hosted - version: "0.1.0" flutter_bloc: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 5e12d900..0dd3f199 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,6 @@ dependencies: fl_chart: ^0.50.1 flutter: sdk: flutter - flutter_adaptive_scaffold: ^0.1.0 flutter_bloc: ^8.1.1 flutter_markdown: ^0.6.13+1 flutter_secure_storage: ^7.0.1 diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..f7cbc91a --- /dev/null +++ b/shell.nix @@ -0,0 +1,35 @@ +with (import { }); + +mkShell { + buildInputs = [ + at-spi2-core.dev + clang + cmake + dart + dbus.dev + flutter + gtk3 + libdatrie + libepoxy.dev + libselinux + libsepol + libthai + libxkbcommon + libsecret + ninja + pcre + pkg-config + util-linux.dev + xorg.libXdmcp + xorg.libXtst + xorg.libX11 + + glib + jsoncpp + libgcrypt + libgpg-error + ]; + shellHook = '' + export LD_LIBRARY_PATH=${libepoxy}/lib + ''; +}