feat: support editing name when creating page (#3297)

This commit is contained in:
Lucas.Xu 2023-08-30 22:16:12 +08:00 committed by GitHub
parent f73d59fb57
commit e8f124b97c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 15 deletions

View File

@ -279,6 +279,7 @@ extension CommonOperations on WidgetTester {
// create a new page
await tapAddViewButton(name: parentName ?? gettingStarted);
await tapButtonWithName(layout.menuName);
await tapOKButton();
await pumpAndSettle();
// hover on it and change it's name

View File

@ -5,6 +5,7 @@ import 'package:appflowy/workspace/application/menu/menu_bloc.dart';
import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
@ -117,13 +118,22 @@ class _PersonalFolderHeaderState extends State<PersonalFolderHeader> {
width: iconSize,
icon: const FlowySvg(FlowySvgs.add_s),
onPressed: () {
context.read<MenuBloc>().add(
MenuEvent.createApp(
LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
index: 0,
),
);
widget.onAdded();
NavigatorTextFieldDialog(
title: LocaleKeys.newPageText.tr(),
value: '',
confirm: (value) {
if (value.isNotEmpty) {
context.read<MenuBloc>().add(
MenuEvent.createApp(
value,
index: 0,
),
);
widget.onAdded();
}
},
).show(context);
},
),
]

View File

@ -12,9 +12,9 @@ import 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.
import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart';
import 'package:appflowy/workspace/presentation/home/menu/view/view_more_action_button.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -350,13 +350,22 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
createNewView,
) {
if (createNewView) {
context.read<ViewBloc>().add(
ViewEvent.createView(
name ?? LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
pluginBuilder.layoutType!,
openAfterCreated: openAfterCreated,
),
);
NavigatorTextFieldDialog(
title: _convertLayoutToHintText(pluginBuilder.layoutType!),
value: LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
autoSelectAllText: true,
confirm: (value) {
if (value.isNotEmpty) {
context.read<ViewBloc>().add(
ViewEvent.createView(
value,
pluginBuilder.layoutType!,
openAfterCreated: openAfterCreated,
),
);
}
},
).show(context);
}
context.read<ViewBloc>().add(
const ViewEvent.setIsExpanded(true),
@ -408,6 +417,20 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
),
);
}
String _convertLayoutToHintText(ViewLayoutPB layout) {
switch (layout) {
case ViewLayoutPB.Document:
return LocaleKeys.newDocumentText.tr();
case ViewLayoutPB.Grid:
return LocaleKeys.newGridText.tr();
case ViewLayoutPB.Board:
return LocaleKeys.newBoardText.tr();
case ViewLayoutPB.Calendar:
return LocaleKeys.newCalendarText.tr();
}
return LocaleKeys.newPageText.tr();
}
}
class _DotIconWidget extends StatelessWidget {

View File

@ -86,6 +86,10 @@
},
"blankPageTitle": "Blank page",
"newPageText": "New page",
"newDocumentText": "New document",
"newGridText": "New grid",
"newCalendarText": "New calendar",
"newBoardText": "New board",
"trash": {
"text": "Trash",
"restoreAll": "Restore All",