mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: the cursor will jump up when creating a new document on desktop. (#5269)
* fix: the cursor will jump up when creating a new document on desktop * fix: the titlbar flashes when switching to another page * fix: unit test * fix: default font family copy
This commit is contained in:
parent
b2c366f6ae
commit
9f44ae959a
@ -73,7 +73,7 @@ void main() {
|
|||||||
await tester.openSettingsPage(SettingsPage.files);
|
await tester.openSettingsPage(SettingsPage.files);
|
||||||
await tester.openSettingsPage(SettingsPage.appearance);
|
await tester.openSettingsPage(SettingsPage.appearance);
|
||||||
|
|
||||||
final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonkey);
|
final resetButton = find.byKey(ThemeFontFamilySetting.resetButtonKey);
|
||||||
await tester.tap(resetButton);
|
await tester.tap(resetButton);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ SPEC CHECKSUMS:
|
|||||||
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
|
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
|
||||||
flowy_infra_ui: 0455e1fa8c51885aa1437848e361e99419f34ebc
|
flowy_infra_ui: 0455e1fa8c51885aa1437848e361e99419f34ebc
|
||||||
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
|
||||||
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
|
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
|
||||||
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
|
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
|
||||||
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
|
image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425
|
||||||
integration_test: 13825b8a9334a850581300559b8839134b124670
|
integration_test: 13825b8a9334a850581300559b8839134b124670
|
||||||
@ -191,4 +191,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: d0d9b4ff572d8695c38eb3f9b490f55cdfc57eca
|
PODFILE CHECKSUM: d0d9b4ff572d8695c38eb3f9b490f55cdfc57eca
|
||||||
|
|
||||||
COCOAPODS: 1.11.3
|
COCOAPODS: 1.15.2
|
||||||
|
@ -106,12 +106,14 @@ class _FontSelectorState extends State<FontSelector> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final fontFamilyName = availableFonts[index - 1];
|
final fontFamilyName = availableFonts[index - 1];
|
||||||
final fontFamily = fontFamilyName != builtInFontFamily()
|
final usingDefaultFontFamily = fontFamilyName == builtInFontFamily();
|
||||||
|
final fontFamily = !usingDefaultFontFamily
|
||||||
? getGoogleFontSafely(fontFamilyName).fontFamily
|
? getGoogleFontSafely(fontFamilyName).fontFamily
|
||||||
: TextStyle(fontFamily: builtInFontFamily()).fontFamily;
|
: TextStyle(fontFamily: builtInFontFamily()).fontFamily;
|
||||||
return FlowyOptionTile.checkbox(
|
return FlowyOptionTile.checkbox(
|
||||||
// display the default font name if the font family name is empty
|
// display the default font name if the font family name is empty
|
||||||
text: fontFamilyName.isNotEmpty
|
// or using the default font family
|
||||||
|
text: fontFamilyName.isNotEmpty && !usingDefaultFontFamily
|
||||||
? fontFamilyName.parseFontFamilyName()
|
? fontFamilyName.parseFontFamilyName()
|
||||||
: LocaleKeys.settings_appearance_fontFamily_defaultFont.tr(),
|
: LocaleKeys.settings_appearance_fontFamily_defaultFont.tr(),
|
||||||
isSelected: widget.selectedFontFamilyName == fontFamilyName,
|
isSelected: widget.selectedFontFamilyName == fontFamilyName,
|
||||||
|
@ -4,6 +4,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
|
|||||||
import 'package:appflowy/mobile/presentation/setting/font/font_picker_screen.dart';
|
import 'package:appflowy/mobile/presentation/setting/font/font_picker_screen.dart';
|
||||||
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
||||||
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
||||||
|
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -21,13 +22,16 @@ class FontSetting extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final selectedFont = context.watch<AppearanceSettingsCubit>().state.font;
|
final selectedFont = context.watch<AppearanceSettingsCubit>().state.font;
|
||||||
|
final name = selectedFont == builtInFontFamily()
|
||||||
|
? LocaleKeys.settings_appearance_fontFamily_defaultFont.tr()
|
||||||
|
: selectedFont;
|
||||||
return MobileSettingItem(
|
return MobileSettingItem(
|
||||||
name: LocaleKeys.settings_appearance_fontFamily_label.tr(),
|
name: LocaleKeys.settings_appearance_fontFamily_label.tr(),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
FlowyText(
|
FlowyText(
|
||||||
selectedFont,
|
name,
|
||||||
color: theme.colorScheme.onSurface,
|
color: theme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
const Icon(Icons.chevron_right),
|
const Icon(Icons.chevron_right),
|
||||||
|
@ -89,7 +89,7 @@ class _DocumentCoverWidgetState extends State<DocumentCoverWidget> {
|
|||||||
bool get hasIcon => viewIcon.isNotEmpty;
|
bool get hasIcon => viewIcon.isNotEmpty;
|
||||||
bool get hasCover =>
|
bool get hasCover =>
|
||||||
coverType != CoverType.none ||
|
coverType != CoverType.none ||
|
||||||
cover?.type != PageStyleCoverImageType.none;
|
(cover != null && cover?.type != PageStyleCoverImageType.none);
|
||||||
|
|
||||||
String viewIcon = '';
|
String viewIcon = '';
|
||||||
PageStyleCover? cover;
|
PageStyleCover? cover;
|
||||||
|
@ -18,7 +18,7 @@ enum OpenAIRequestType {
|
|||||||
case OpenAIRequestType.textCompletion:
|
case OpenAIRequestType.textCompletion:
|
||||||
return Uri.parse('https://api.openai.com/v1/completions');
|
return Uri.parse('https://api.openai.com/v1/completions');
|
||||||
case OpenAIRequestType.textEdit:
|
case OpenAIRequestType.textEdit:
|
||||||
return Uri.parse('https://api.openai.com/v1/v1/chat/completions');
|
return Uri.parse('https://api.openai.com/v1/chat/completions');
|
||||||
case OpenAIRequestType.imageGenerations:
|
case OpenAIRequestType.imageGenerations:
|
||||||
return Uri.parse('https://api.openai.com/v1/images/generations');
|
return Uri.parse('https://api.openai.com/v1/images/generations');
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,11 @@ class _FontButton extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<DocumentPageStyleBloc, DocumentPageStyleState>(
|
return BlocBuilder<DocumentPageStyleBloc, DocumentPageStyleState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
String fontFamily = state.fontFamily ?? builtInFontFamily();
|
||||||
|
if (fontFamily == builtInFontFamily()) {
|
||||||
|
fontFamily =
|
||||||
|
LocaleKeys.settings_appearance_fontFamily_defaultFont.tr();
|
||||||
|
}
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => _showFontSelector(context),
|
onTap: () => _showFontSelector(context),
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
@ -177,7 +182,7 @@ class _FontButton extends StatelessWidget {
|
|||||||
const HSpace(16.0),
|
const HSpace(16.0),
|
||||||
FlowyText(LocaleKeys.titleBar_font.tr()),
|
FlowyText(LocaleKeys.titleBar_font.tr()),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
FlowyText(state.fontFamily ?? builtInFontFamily()),
|
FlowyText(fontFamily),
|
||||||
const HSpace(6.0),
|
const HSpace(6.0),
|
||||||
const FlowySvg(FlowySvgs.m_page_style_arrow_right_s),
|
const FlowySvg(FlowySvgs.m_page_style_arrow_right_s),
|
||||||
const HSpace(12.0),
|
const HSpace(12.0),
|
||||||
|
@ -24,7 +24,7 @@ class ThemeFontFamilySetting extends StatefulWidget {
|
|||||||
|
|
||||||
final String currentFontFamily;
|
final String currentFontFamily;
|
||||||
static Key textFieldKey = const Key('FontFamilyTextField');
|
static Key textFieldKey = const Key('FontFamilyTextField');
|
||||||
static Key resetButtonkey = const Key('FontFamilyResetButton');
|
static Key resetButtonKey = const Key('FontFamilyResetButton');
|
||||||
static Key popoverKey = const Key('FontFamilyPopover');
|
static Key popoverKey = const Key('FontFamilyPopover');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -36,7 +36,7 @@ class _ThemeFontFamilySettingState extends State<ThemeFontFamilySetting> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FlowySettingListTile(
|
return FlowySettingListTile(
|
||||||
label: LocaleKeys.settings_appearance_fontFamily_label.tr(),
|
label: LocaleKeys.settings_appearance_fontFamily_label.tr(),
|
||||||
resetButtonKey: ThemeFontFamilySetting.resetButtonkey,
|
resetButtonKey: ThemeFontFamilySetting.resetButtonKey,
|
||||||
onResetRequested: () {
|
onResetRequested: () {
|
||||||
context.read<AppearanceSettingsCubit>().resetFontFamily();
|
context.read<AppearanceSettingsCubit>().resetFontFamily();
|
||||||
context
|
context
|
||||||
|
@ -31,12 +31,14 @@ class ViewTitleBar extends StatefulWidget {
|
|||||||
|
|
||||||
class _ViewTitleBarState extends State<ViewTitleBar> {
|
class _ViewTitleBarState extends State<ViewTitleBar> {
|
||||||
late Future<List<ViewPB>> ancestors;
|
late Future<List<ViewPB>> ancestors;
|
||||||
|
late String viewId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_reloadAncestors();
|
viewId = widget.view.id;
|
||||||
|
_reloadAncestors(viewId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -44,7 +46,8 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
|
|||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
|
||||||
if (oldWidget.view.id != widget.view.id) {
|
if (oldWidget.view.id != widget.view.id) {
|
||||||
_reloadAncestors();
|
viewId = widget.view.id;
|
||||||
|
_reloadAncestors(viewId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +57,11 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
|
|||||||
future: ancestors,
|
future: ancestors,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final ancestors = snapshot.data;
|
final ancestors = snapshot.data;
|
||||||
if (ancestors == null) {
|
if (ancestors == null ||
|
||||||
|
snapshot.connectionState != ConnectionState.done) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
const maxWidth = WindowSizeManager.minWindowWidth - 200;
|
const maxWidth = WindowSizeManager.minWindowWidth / 2.0;
|
||||||
final replacement = Row(
|
final replacement = Row(
|
||||||
// refresh the view title bar when the ancestors changed
|
// refresh the view title bar when the ancestors changed
|
||||||
key: ValueKey(ancestors.hashCode),
|
key: ValueKey(ancestors.hashCode),
|
||||||
@ -73,7 +77,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
|
|||||||
key: ValueKey(ancestors.last),
|
key: ValueKey(ancestors.last),
|
||||||
view: ancestors.last,
|
view: ancestors.last,
|
||||||
maxTitleWidth: constraints.maxWidth,
|
maxTitleWidth: constraints.maxWidth,
|
||||||
onUpdated: () => setState(() => _reloadAncestors()),
|
onUpdated: () => setState(() => _reloadAncestors(viewId)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -129,7 +133,7 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
|
|||||||
behavior: i == views.length - 1
|
behavior: i == views.length - 1
|
||||||
? _ViewTitleBehavior.editable // only the last one is editable
|
? _ViewTitleBehavior.editable // only the last one is editable
|
||||||
: _ViewTitleBehavior.uneditable, // others are not editable
|
: _ViewTitleBehavior.uneditable, // others are not editable
|
||||||
onUpdated: () => setState(() => _reloadAncestors()),
|
onUpdated: () => setState(() => _reloadAncestors(viewId)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -144,8 +148,8 @@ class _ViewTitleBarState extends State<ViewTitleBar> {
|
|||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _reloadAncestors() {
|
void _reloadAncestors(String viewId) {
|
||||||
ancestors = ViewBackendService.getViewAncestors(widget.view.id)
|
ancestors = ViewBackendService.getViewAncestors(viewId)
|
||||||
.fold((s) => s.items, (f) => []);
|
.fold((s) => s.items, (f) => []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class TrashTestContext {
|
|||||||
section: ViewSectionPB.Public,
|
section: ViewSectionPB.Public,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await blocResponseFuture();
|
await blocResponseFuture(millisecond: 300);
|
||||||
|
|
||||||
viewBloc.add(
|
viewBloc.add(
|
||||||
const ViewEvent.createView(
|
const ViewEvent.createView(
|
||||||
@ -34,7 +34,7 @@ class TrashTestContext {
|
|||||||
section: ViewSectionPB.Public,
|
section: ViewSectionPB.Public,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await blocResponseFuture();
|
await blocResponseFuture(millisecond: 300);
|
||||||
|
|
||||||
viewBloc.add(
|
viewBloc.add(
|
||||||
const ViewEvent.createView(
|
const ViewEvent.createView(
|
||||||
@ -43,7 +43,7 @@ class TrashTestContext {
|
|||||||
section: ViewSectionPB.Public,
|
section: ViewSectionPB.Public,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await blocResponseFuture();
|
await blocResponseFuture(millisecond: 300);
|
||||||
|
|
||||||
allViews = [...viewBloc.state.view.childViews];
|
allViews = [...viewBloc.state.view.childViews];
|
||||||
assert(allViews.length == 3, 'but receive ${allViews.length}');
|
assert(allViews.length == 3, 'but receive ${allViews.length}');
|
||||||
|
@ -412,7 +412,7 @@
|
|||||||
"fontFamily": {
|
"fontFamily": {
|
||||||
"label": "Font Family",
|
"label": "Font Family",
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"defaultFont": "Default Font"
|
"defaultFont": "System"
|
||||||
},
|
},
|
||||||
"themeMode": {
|
"themeMode": {
|
||||||
"label": "Theme Mode",
|
"label": "Theme Mode",
|
||||||
|
Loading…
Reference in New Issue
Block a user