feat: editor theme improvement (#2307)

* chore: make editor style adapt to theme data and add toolbar color

* chore: link to local path

* chore: add pop up menu style

* chore: link to editor main branch

* chore: reset editor path

* chore: upgrade appflowy_editor

---------

Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Yijing Huang
2023-04-21 06:26:55 -05:00
committed by GitHub
parent 40e266f5ce
commit d804e3ed6d
10 changed files with 110 additions and 67 deletions

View File

@ -1,32 +1,63 @@
import 'package:appflowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart'; import 'package:appflowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
EditorStyle customEditorTheme(BuildContext context) { EditorStyle customEditorTheme(BuildContext context) {
final documentStyle = context.watch<DocumentAppearanceCubit>().state; final documentStyle = context.watch<DocumentAppearanceCubit>().state;
var editorStyle = Theme.of(context).brightness == Brightness.dark final theme = Theme.of(context);
? EditorStyle.dark
: EditorStyle.light; var editorStyle = EditorStyle(
editorStyle = editorStyle.copyWith( // Editor styles
padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 0), padding: const EdgeInsets.symmetric(horizontal: 100),
textStyle: editorStyle.textStyle?.copyWith( backgroundColor: theme.colorScheme.surface,
cursorColor: theme.colorScheme.primary,
// Text styles
textPadding: const EdgeInsets.symmetric(vertical: 8.0),
textStyle: TextStyle(
fontFamily: 'poppins', fontFamily: 'poppins',
fontSize: documentStyle.fontSize, fontSize: documentStyle.fontSize,
color: theme.colorScheme.onBackground,
), ),
placeholderTextStyle: editorStyle.placeholderTextStyle?.copyWith( selectionColor: theme.colorScheme.tertiary.withOpacity(0.2),
fontFamily: 'poppins', // Selection menu
fontSize: documentStyle.fontSize, selectionMenuBackgroundColor: theme.cardColor,
), selectionMenuItemTextColor: theme.iconTheme.color,
bold: editorStyle.bold?.copyWith( selectionMenuItemIconColor: theme.colorScheme.onBackground,
fontWeight: FontWeight.w600, selectionMenuItemSelectedIconColor: theme.colorScheme.onSurface,
selectionMenuItemSelectedTextColor: theme.colorScheme.onSurface,
selectionMenuItemSelectedColor: theme.hoverColor,
// Toolbar and its item's style
toolbarColor: theme.colorScheme.onTertiary,
toolbarElevation: 0,
lineHeight: 1.5,
placeholderTextStyle:
TextStyle(fontSize: documentStyle.fontSize, color: theme.hintColor),
bold: const TextStyle(
fontFamily: 'poppins-Bold', fontFamily: 'poppins-Bold',
fontWeight: FontWeight.w600,
), ),
backgroundColor: Theme.of(context).colorScheme.surface, italic: const TextStyle(fontStyle: FontStyle.italic),
selectionMenuBackgroundColor: Theme.of(context).cardColor, underline: const TextStyle(decoration: TextDecoration.underline),
selectionMenuItemSelectedIconColor: Theme.of(context).colorScheme.onSurface, strikethrough: const TextStyle(decoration: TextDecoration.lineThrough),
selectionMenuItemSelectedTextColor: Theme.of(context).colorScheme.onSurface, href: TextStyle(
color: theme.colorScheme.primary,
decoration: TextDecoration.underline,
),
highlightColorHex: '0x6000BCF0',
code: GoogleFonts.robotoMono(
textStyle: TextStyle(
fontSize: documentStyle.fontSize,
fontWeight: FontWeight.normal,
color: Colors.red,
backgroundColor: theme.colorScheme.inverseSurface,
),
),
popupMenuFGColor: theme.iconTheme.color,
popupMenuHoverColor: theme.colorScheme.tertiaryContainer,
); );
return editorStyle; return editorStyle;
} }

View File

@ -5,7 +5,7 @@ import 'package:appflowy/plugins/document/presentation/plugins/cover/change_cove
import 'package:appflowy/plugins/document/presentation/plugins/cover/emoji_popover.dart'; import 'package:appflowy/plugins/document/presentation/plugins/cover/emoji_popover.dart';
import 'package:appflowy/plugins/document/presentation/plugins/cover/icon_widget.dart'; import 'package:appflowy/plugins/document/presentation/plugins/cover/icon_widget.dart';
import 'package:appflowy/workspace/presentation/widgets/emoji_picker/emoji_picker.dart'; import 'package:appflowy/workspace/presentation/widgets/emoji_picker/emoji_picker.dart';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart' hide FlowySvg;
import 'package:appflowy_popover/appflowy_popover.dart'; import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/image.dart';

View File

@ -4,7 +4,6 @@ import 'package:appflowy/workspace/presentation/widgets/emoji_picker/src/default
import 'package:appflowy/workspace/presentation/widgets/emoji_picker/src/emoji_view_state.dart'; import 'package:appflowy/workspace/presentation/widgets/emoji_picker/src/emoji_view_state.dart';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart';
import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

View File

@ -225,6 +225,8 @@ class AppearanceSettingsState with _$AppearanceSettingsState {
secondaryContainer: theme.selector, secondaryContainer: theme.selector,
onSecondaryContainer: theme.topbarBg, onSecondaryContainer: theme.topbarBg,
tertiary: theme.shader7, tertiary: theme.shader7,
// Editor: toolbarColor
onTertiary: theme.toolbarColor,
tertiaryContainer: theme.questionBubbleBG, tertiaryContainer: theme.questionBubbleBG,
background: theme.surface, background: theme.surface,
onBackground: theme.text, onBackground: theme.text,

View File

@ -74,6 +74,8 @@ abstract class FlowyColorScheme {
final Color hoverFG; final Color hoverFG;
final Color questionBubbleBG; final Color questionBubbleBG;
final Color progressBarBGcolor; final Color progressBarBGcolor;
//editor toolbar BG color
final Color toolbarColor;
const FlowyColorScheme({ const FlowyColorScheme({
required this.surface, required this.surface,
@ -120,6 +122,7 @@ abstract class FlowyColorScheme {
required this.hoverFG, required this.hoverFG,
required this.questionBubbleBG, required this.questionBubbleBG,
required this.progressBarBGcolor, required this.progressBarBGcolor,
required this.toolbarColor,
}); });
factory FlowyColorScheme.builtIn(String themeName, Brightness brightness) { factory FlowyColorScheme.builtIn(String themeName, Brightness brightness) {

View File

@ -20,6 +20,7 @@ const _darkShader3 = Color(0xff363D49);
const _darkShader5 = Color(0xffBBC3CD); const _darkShader5 = Color(0xffBBC3CD);
const _darkShader6 = Color(0xffF2F2F2); const _darkShader6 = Color(0xffF2F2F2);
const _darkMain1 = Color(0xffe21f74); const _darkMain1 = Color(0xffe21f74);
const _darkInput = Color(0xff282E3A);
class DandelionColorScheme extends FlowyColorScheme { class DandelionColorScheme extends FlowyColorScheme {
const DandelionColorScheme.light() const DandelionColorScheme.light()
@ -68,53 +69,54 @@ class DandelionColorScheme extends FlowyColorScheme {
hoverFG: _lightShader1, hoverFG: _lightShader1,
questionBubbleBG: _lightSelector, questionBubbleBG: _lightSelector,
progressBarBGcolor: _lightTint9, progressBarBGcolor: _lightTint9,
toolbarColor: _lightShader1,
); );
const DandelionColorScheme.dark() const DandelionColorScheme.dark()
: super( : super(
surface: const Color(0xff292929), surface: const Color(0xff292929),
hover: const Color(0xff1f1f1f), hover: const Color(0xff1f1f1f),
selector: const Color(0xff333333), selector: const Color(0xff333333),
red: const Color(0xfffb006d), red: const Color(0xfffb006d),
yellow: const Color(0xffffd667), yellow: const Color(0xffffd667),
green: const Color(0xff66cf80), green: const Color(0xff66cf80),
shader1: _white, shader1: _white,
shader2: _darkShader2, shader2: _darkShader2,
shader3: const Color(0xff828282), shader3: const Color(0xff828282),
shader4: const Color(0xffbdbdbd), shader4: const Color(0xffbdbdbd),
shader5: _darkShader5, shader5: _darkShader5,
shader6: _darkShader6, shader6: _darkShader6,
shader7: _white, shader7: _white,
bg1: const Color(0xFFD5A200), bg1: const Color(0xFFD5A200),
bg2: _black, bg2: _black,
bg3: const Color(0xff4f4f4f), bg3: const Color(0xff4f4f4f),
bg4: const Color(0xff2c144b), bg4: const Color(0xff2c144b),
tint1: const Color(0xff8738F5), tint1: const Color(0xff8738F5),
tint2: const Color(0xffE6336E), tint2: const Color(0xffE6336E),
tint3: const Color(0xffFF2D9E), tint3: const Color(0xffFF2D9E),
tint4: const Color(0xffE9973E), tint4: const Color(0xffE9973E),
tint5: const Color(0xffFBF000), tint5: const Color(0xffFBF000),
tint6: const Color(0xffC0F000), tint6: const Color(0xffC0F000),
tint7: const Color(0xff15F74E), tint7: const Color(0xff15F74E),
tint8: const Color(0xff00F0E2), tint8: const Color(0xff00F0E2),
tint9: const Color(0xff00BCF0), tint9: const Color(0xff00BCF0),
main1: _darkMain1, main1: _darkMain1,
main2: const Color(0xffe0196f), main2: const Color(0xffe0196f),
shadow: _black, shadow: _black,
sidebarBg: const Color(0xff232B38), sidebarBg: const Color(0xff232B38),
divider: _darkShader3, divider: _darkShader3,
topbarBg: _darkShader1, topbarBg: _darkShader1,
icon: _darkShader5, icon: _darkShader5,
text: _darkShader5, text: _darkShader5,
input: const Color(0xff282E3A), input: _darkInput,
hint: _darkShader5, hint: _darkShader5,
primary: _darkMain1, primary: _darkMain1,
onPrimary: _darkShader1, onPrimary: _darkShader1,
hoverBG1: _darkMain1, hoverBG1: _darkMain1,
hoverBG2: _darkMain1, hoverBG2: _darkMain1,
hoverBG3: _darkShader3, hoverBG3: _darkShader3,
hoverFG: _darkShader1, hoverFG: _darkShader1,
questionBubbleBG: _darkShader3, questionBubbleBG: _darkShader3,
progressBarBGcolor: _darkShader3, progressBarBGcolor: _darkShader3,
); toolbarColor: _darkInput);
} }

View File

@ -18,6 +18,7 @@ const _darkShader3 = Color(0xff363D49);
const _darkShader5 = Color(0xffBBC3CD); const _darkShader5 = Color(0xffBBC3CD);
const _darkShader6 = Color(0xffF2F2F2); const _darkShader6 = Color(0xffF2F2F2);
const _darkMain1 = Color(0xff00BCF0); const _darkMain1 = Color(0xff00BCF0);
const _darkInput = Color(0xff282E3A);
class DefaultColorScheme extends FlowyColorScheme { class DefaultColorScheme extends FlowyColorScheme {
const DefaultColorScheme.light() const DefaultColorScheme.light()
@ -66,6 +67,7 @@ class DefaultColorScheme extends FlowyColorScheme {
questionBubbleBG: _lightSelector, questionBubbleBG: _lightSelector,
hoverBG3: _lightShader6, hoverBG3: _lightShader6,
progressBarBGcolor: _lightTint9, progressBarBGcolor: _lightTint9,
toolbarColor: _lightShader1,
); );
const DefaultColorScheme.dark() const DefaultColorScheme.dark()
@ -104,7 +106,7 @@ class DefaultColorScheme extends FlowyColorScheme {
topbarBg: _darkShader1, topbarBg: _darkShader1,
icon: _darkShader5, icon: _darkShader5,
text: _darkShader5, text: _darkShader5,
input: const Color(0xff282E3A), input: _darkInput,
hint: _darkShader5, hint: _darkShader5,
primary: _darkMain1, primary: _darkMain1,
onPrimary: _darkShader1, onPrimary: _darkShader1,
@ -114,5 +116,6 @@ class DefaultColorScheme extends FlowyColorScheme {
hoverFG: _darkShader1, hoverFG: _darkShader1,
questionBubbleBG: _darkShader3, questionBubbleBG: _darkShader3,
progressBarBGcolor: _darkShader3, progressBarBGcolor: _darkShader3,
toolbarColor: _darkInput,
); );
} }

View File

@ -21,6 +21,7 @@ const _darkShader3 = Color(0xff363D49);
const _darkShader5 = Color(0xffBBC3CD); const _darkShader5 = Color(0xffBBC3CD);
const _darkShader6 = Color(0xffF2F2F2); const _darkShader6 = Color(0xffF2F2F2);
const _darkMain1 = Color(0xffA652FB); const _darkMain1 = Color(0xffA652FB);
const _darkInput = Color(0xff282E3A);
class LavenderColorScheme extends FlowyColorScheme { class LavenderColorScheme extends FlowyColorScheme {
const LavenderColorScheme.light() const LavenderColorScheme.light()
@ -69,6 +70,7 @@ class LavenderColorScheme extends FlowyColorScheme {
hoverFG: _lightShader1, hoverFG: _lightShader1,
questionBubbleBG: _lightSelector, questionBubbleBG: _lightSelector,
progressBarBGcolor: _lightTint9, progressBarBGcolor: _lightTint9,
toolbarColor: _lightShader1,
); );
const LavenderColorScheme.dark() const LavenderColorScheme.dark()
@ -117,5 +119,6 @@ class LavenderColorScheme extends FlowyColorScheme {
hoverFG: _darkShader1, hoverFG: _darkShader1,
questionBubbleBG: _darkShader3, questionBubbleBG: _darkShader3,
progressBarBGcolor: _darkShader3, progressBarBGcolor: _darkShader3,
toolbarColor: _darkInput,
); );
} }

View File

@ -45,10 +45,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: appflowy_editor name: appflowy_editor
sha256: "0768e7aee78c67c6ddd2ee8cbaa182848c9d94a98d495bd415ff0059b491ac08" sha256: a1dbca3d7d33f4669f1d44bfa1e06b6646f46726c219921b8a59d9ee22bf252d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.1.5" version: "0.1.9"
appflowy_popover: appflowy_popover:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -42,7 +42,7 @@ dependencies:
git: git:
url: https://github.com/AppFlowy-IO/appflowy-board.git url: https://github.com/AppFlowy-IO/appflowy-board.git
ref: a183c57 ref: a183c57
appflowy_editor: ^0.1.5 appflowy_editor: "^0.1.9"
appflowy_popover: appflowy_popover:
path: packages/appflowy_popover path: packages/appflowy_popover