Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Dynamically Load Themes in AppFlowy #2670

Merged
merged 92 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
8a1e713
feat: dynamic theme plugin (init)
a-wallen May 31, 2023
a9baa2e
feat: provide fallback color if plugin becomes out of date (transparent)
a-wallen Jun 1, 2023
254749d
feat: use applicationDocumentsDirectory to store plugins
a-wallen Jun 1, 2023
5ed6b75
chore: remove json files
a-wallen Jun 2, 2023
33bc14d
fix: add toJson to resolve analyzer errors
a-wallen Jun 2, 2023
17041ac
fix: analyzer (unused imports)
a-wallen Jun 2, 2023
1b7c83a
feat: add code generation scripts for freezed files (call recursively…
a-wallen Jun 2, 2023
b57a725
fix: revert changes to dry generation
a-wallen Jun 3, 2023
b638279
feat: call directly into script
a-wallen Jun 3, 2023
f1d0829
refactor: scripts try to be stateless :)
a-wallen Jun 3, 2023
d638a69
fix: path to code generation in toml
a-wallen Jun 3, 2023
2498668
fix: generate script permissions
a-wallen Jun 3, 2023
b719e48
fix: path not correct in generate.sh
a-wallen Jun 3, 2023
5e0d6b4
feat: modify execution permissions before executing scripts
a-wallen Jun 3, 2023
088f8c4
chore: switch order of build_runner and easy_localizations
a-wallen Jun 3, 2023
bc39342
fix: fs is not valid duckscript cmd
a-wallen Jun 3, 2023
ed76458
chore: clean build_runner before executing
a-wallen Jun 3, 2023
efe7735
chore: upgrade freezed and build_runner attempt to resolve InvalidTyp…
a-wallen Jun 3, 2023
57e2c95
fix: use exec cmd.exe to chmod
a-wallen Jun 3, 2023
743f7cd
feat: add task to generate all files
a-wallen Jun 4, 2023
2555a3b
chore: remove redundant task (Code Gen)
a-wallen Jun 4, 2023
8689ce3
chore: remove json_annoation to dev_dependencies
a-wallen Jun 4, 2023
c9a11fb
fix: dropped & between commands
a-wallen Jun 4, 2023
b1f34f8
chore: rename file and class to FlowyDynamicPlugin
a-wallen Jun 4, 2023
b5d559b
fix: dependency hell
a-wallen Jun 4, 2023
3b2c68b
fix: json annotation in colorscheme
a-wallen Jun 5, 2023
71404d1
fix: analyzer warnings
a-wallen Jun 5, 2023
10b745f
fix: duckscript runner for code generator
a-wallen Jun 5, 2023
3bab2b4
fix: try without setting file permissions
a-wallen Jun 6, 2023
60be3de
chore: move file picker to infra
a-wallen Jun 7, 2023
e876e12
chore: restructure project directory
a-wallen Jun 7, 2023
5ae8318
feat: add BLoC components for consumers
a-wallen Jun 7, 2023
90192a1
chore: update dependencies in pubspec.yaml file
a-wallen Jun 7, 2023
34c7bef
fix: file picker imports
a-wallen Jun 7, 2023
4c0b111
feat: add new translations for features
a-wallen Jun 7, 2023
8d31d19
feat: add new widgets to render upload
a-wallen Jun 7, 2023
faadf29
fix: import
a-wallen Jun 7, 2023
b999503
feat: add text overflow
a-wallen Jun 7, 2023
4d45ef6
feat: use animated switcher
a-wallen Jun 7, 2023
43c3971
chore: export FileType
a-wallen Jun 7, 2023
f851808
fix: directory was not created, only files were copied
a-wallen Jun 7, 2023
85ec244
chore: separate some logic
a-wallen Jun 7, 2023
9e383ca
feat: add saveFile to FilePickerService
a-wallen Jun 7, 2023
be70da3
fix: analyzer error with unused imports
a-wallen Jun 7, 2023
1f59733
feat: add translations for uploading
a-wallen Jun 9, 2023
83edcd2
feat: add builtins property to apptheme
a-wallen Jun 9, 2023
616aaba
feat: add theme preview widget
a-wallen Jun 9, 2023
107b9a2
fix: upload widgets need to fill whole space and account for overflow
a-wallen Jun 9, 2023
5f43e1a
refactor: do not watch file system for changes
a-wallen Jun 9, 2023
92c850e
feat: add deletion confirmation dialog
a-wallen Jun 9, 2023
981857c
feat: add form factor resolution for dyanmic layout
a-wallen Jun 9, 2023
0b8b242
feat: trigger rebuild only when plugins are loaded
a-wallen Jun 9, 2023
4f497da
feat: make all methods static
a-wallen Jun 12, 2023
540b2d6
chore: remove TODO comment, requires further design
a-wallen Jun 12, 2023
7d2135c
chore: move models to subfolder
a-wallen Jun 12, 2023
cfcdc74
fix: references to plugin service instance
a-wallen Jun 12, 2023
91c0893
fix: rebase errors
a-wallen Jun 12, 2023
9ae0173
fix: more rebasing errors
a-wallen Jun 13, 2023
8fdac25
feat: remove multiple themes from one plugin
a-wallen Jun 13, 2023
2f779cc
refactor: use pattern to resolve widget in settings_appearance_view
a-wallen Jun 13, 2023
e0e1035
refactor: remove commented code
a-wallen Jun 13, 2023
2017712
feat: add translations
a-wallen Jun 15, 2023
32e27a7
fix: import error
a-wallen Jun 15, 2023
d922875
refactor: separate concerns a bit more
a-wallen Jun 15, 2023
5ab3a9f
fix: bug in toJson serialization code
a-wallen Jun 15, 2023
3c62728
feat: add package to use represent memory files
a-wallen Jun 15, 2023
f250480
fix: analyzer warnings
a-wallen Jun 15, 2023
ff3f5ef
chore: add translation
a-wallen Jun 15, 2023
69abb16
chore: remove unused exceptions
a-wallen Jun 15, 2023
1ea3d3d
chore: use join
a-wallen Jun 15, 2023
ec89f1d
chore: add documentation
a-wallen Jun 15, 2023
97f29df
feat: add tests on theme
a-wallen Jun 15, 2023
5efa4d8
fix: fix scripts for macOS
hyj1204 Jun 20, 2023
090ae92
feat: use appFlowyDocumentDirectory
a-wallen Jun 20, 2023
5eecac5
fix: remove unused import
a-wallen Jun 20, 2023
88af707
fix: imports
a-wallen Jun 20, 2023
7f6780b
feat: allow plugin service to be passed
a-wallen Jun 20, 2023
d2f792f
fix: theme tests
a-wallen Jun 20, 2023
e4bcef9
feat: separate themes by built-in and plugin
a-wallen Jun 24, 2023
7484598
fix: rebase change name of appFlowyDocumentDirectory
a-wallen Jun 24, 2023
86d1f82
chore: add test to check that initial state falls back to initial theme
a-wallen Jun 24, 2023
01892ab
chore: theme upload preview widget
a-wallen Jun 24, 2023
8e67e9c
chore: rename to brightness setting
a-wallen Jun 29, 2023
411f341
refactor: appearance for settings appearance view
a-wallen Jun 29, 2023
b6db9e7
feat: change show dialog api and use it
a-wallen Jun 29, 2023
dc7b41a
fix: handle plugin compilation exception when incorrect format supplied
a-wallen Jun 29, 2023
b63f363
fix: style of theme upload
a-wallen Jun 29, 2023
549581c
fix: always change state so that ui updates
a-wallen Jun 29, 2023
96f968c
chore: style of loading widget
a-wallen Jun 29, 2023
50ad2ce
fix: analyzer errors
a-wallen Jun 29, 2023
9dfd443
feat: add learn more button to documentation
a-wallen Jun 30, 2023
b3b99a5
Merge branch 'main' into dynamic_theme_plugin
appflowy Jul 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions frontend/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,39 @@
{
"label": "AF: Generate Freezed Files",
"type": "shell",
"command": "dart run build_runner build -d",
"command": "sh ./scripts/code_generation/freezed/generate_freezed.sh",
"options": {
"cwd": "${workspaceFolder}/appflowy_flutter"
}
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
},
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d",
"/c",
".\\scripts\\code_generation\\freezed\\generate_freezed.cmd"
]
}
}
},
},
{
"label": "AF: Generate Language Files",
"type": "shell",
"command": "sh ./scripts/generate_language_files.sh",
"command": "sh ./scripts/code_generation/language_files/generate_language_files.sh",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/d",
"/c",
".\\scripts\\generate_language_files.cmd"
".\\scripts\\code_generation\\language_files\\generate_language_files.cmd"
]
}
}
Expand Down
14 changes: 13 additions & 1 deletion frontend/appflowy_flutter/assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,19 @@
"dark": "Dark Mode",
"system": "Adapt to System"
},
"theme": "Theme"
"themeUpload": {
"button": "Upload",
"description": "Upload your own AppFlowy theme using the button below.",
"failure": "The theme that was uploaded had an invalid format.",
"loading": "Please wait while we validate and upload your theme...",
"uploadSuccess": "Your theme was uploaded successfully",
"deletionFailure": "Failed to delete the theme. Try to delete it manually.",
"filePickerDialogTitle": "Choose a .flowy_plugin file",
"urlUploadFailure": "Failed to open url: {}"
},
"theme": "Theme",
"builtInsLabel": "Built-in Themes",
"pluginsLabel": "Plugins"
},
"files": {
"copy": "Copy",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:file_picker/file_picker.dart' as fp;
import 'package:flowy_infra/file_picker/file_picker_service.dart';

class MockFilePicker implements FilePickerService {
MockFilePicker({
Expand All @@ -21,7 +20,7 @@ class MockFilePicker implements FilePickerService {
String? dialogTitle,
String? fileName,
String? initialDirectory,
fp.FileType type = fp.FileType.any,
FileType type = FileType.any,
List<String>? allowedExtensions,
bool lockParentWindow = false,
}) {
Expand All @@ -32,18 +31,17 @@ class MockFilePicker implements FilePickerService {
Future<FilePickerResult?> pickFiles({
String? dialogTitle,
String? initialDirectory,
fp.FileType type = fp.FileType.any,
FileType type = FileType.any,
List<String>? allowedExtensions,
Function(fp.FilePickerStatus p1)? onFileLoading,
Function(FilePickerStatus p1)? onFileLoading,
bool allowCompression = true,
bool allowMultiple = false,
bool withData = false,
bool withReadStream = false,
bool lockParentWindow = false,
}) {
final platformFiles = mockPaths
.map((e) => fp.PlatformFile(path: e, name: '', size: 0))
.toList();
final platformFiles =
mockPaths.map((e) => PlatformFile(path: e, name: '', size: 0)).toList();
return Future.value(
FilePickerResult(
platformFiles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy/plugins/document/presentation/export_page_widget.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/base64_string.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:appflowy_backend/protobuf/flowy-document2/protobuf.dart'
hide DocumentEvent;
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void showLinkToPageMenu(
linkToPageMenuEntry.remove();
} on FlowyError catch (e) {
Dialogs.show(
FlowyErrorPage.message(
child: FlowyErrorPage.message(
e.msg,
howToFix: LocaleKeys.errorDialog_howToFixFallback.tr(),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'dart:io';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:file_picker/file_picker.dart' as fp;

import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
Expand Down Expand Up @@ -121,7 +120,7 @@ class CoverImagePickerBloc
final result = await getIt<FilePickerService>().pickFiles(
dialogTitle: LocaleKeys.document_plugins_cover_addLocalImage.tr(),
allowMultiple: false,
type: fp.FileType.image,
type: FileType.image,
allowedExtensions: allowedExtensions,
);
if (result != null && result.files.isNotEmpty) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io';

import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/workspace/application/settings/settings_location_cubit.dart';
import 'package:appflowy/workspace/application/settings/application_data_storage.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
import 'package:flowy_infra/uuid.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/plugins/document/application/share_bloc.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy/workspace/presentation/home/toast.dart';
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:appflowy_backend/protobuf/flowy-document2/entities.pb.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
Expand Down
4 changes: 2 additions & 2 deletions frontend/appflowy_flutter/lib/startup/deps_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import 'package:appflowy/user/application/auth/auth_service.dart';
import 'package:appflowy/user/application/auth/supabase_auth_service.dart';
import 'package:appflowy/user/application/user_listener.dart';
import 'package:appflowy/user/application/user_service.dart';
import 'package:appflowy/util/file_picker/file_picker_impl.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:flowy_infra/file_picker/file_picker_impl.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:appflowy/plugins/document/application/prelude.dart';
import 'package:appflowy/workspace/application/user/prelude.dart';
import 'package:appflowy/workspace/application/workspace/prelude.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:io';

import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class AppearanceSettingsCubit extends Cubit<AppearanceSettingsState> {

/// Update selected theme in the user's settings and emit an updated state
/// with the AppTheme named [themeName].
void setTheme(String themeName) {
Future<void> setTheme(String themeName) async {
_setting.theme = themeName;
_saveAppearanceSettings();
emit(state.copyWith(appTheme: AppTheme.fromName(themeName)));
emit(state.copyWith(appTheme: await AppTheme.fromName(themeName)));
}

/// Update the theme mode in the user's settings and emit an updated state.
Expand Down Expand Up @@ -182,7 +182,7 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
double menuOffset,
) {
return AppearanceSettingsState(
appTheme: AppTheme.fromName(themeName),
appTheme: AppTheme.fallback,
a-wallen marked this conversation as resolved.
Show resolved Hide resolved
font: font,
monospaceFont: monospaceFont,
themeMode: _themeModeFromPB(themeModePB),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import 'dart:typed_data';
import 'package:appflowy/plugins/document/application/document_data_pb_extension.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/migration/editor_migration.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/file_picker/file_picker_service.dart';
import 'package:appflowy/workspace/application/settings/share/import_service.dart';
import 'package:appflowy/workspace/presentation/home/menu/app/header/import/import_type.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/container.dart';
import 'package:flutter/material.dart';
Expand Down
Loading