mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: support editing name when creating page (#3297)
This commit is contained in:
parent
f73d59fb57
commit
e8f124b97c
@ -279,6 +279,7 @@ extension CommonOperations on WidgetTester {
|
|||||||
// create a new page
|
// create a new page
|
||||||
await tapAddViewButton(name: parentName ?? gettingStarted);
|
await tapAddViewButton(name: parentName ?? gettingStarted);
|
||||||
await tapButtonWithName(layout.menuName);
|
await tapButtonWithName(layout.menuName);
|
||||||
|
await tapOKButton();
|
||||||
await pumpAndSettle();
|
await pumpAndSettle();
|
||||||
|
|
||||||
// hover on it and change it's name
|
// hover on it and change it's name
|
||||||
|
@ -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/sidebar/folder/folder_bloc.dart';
|
||||||
import 'package:appflowy/workspace/application/tabs/tabs_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/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:appflowy_backend/protobuf/flowy-folder2/view.pb.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';
|
||||||
@ -117,13 +118,22 @@ class _PersonalFolderHeaderState extends State<PersonalFolderHeader> {
|
|||||||
width: iconSize,
|
width: iconSize,
|
||||||
icon: const FlowySvg(FlowySvgs.add_s),
|
icon: const FlowySvg(FlowySvgs.add_s),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
NavigatorTextFieldDialog(
|
||||||
|
title: LocaleKeys.newPageText.tr(),
|
||||||
|
value: '',
|
||||||
|
confirm: (value) {
|
||||||
|
if (value.isNotEmpty) {
|
||||||
context.read<MenuBloc>().add(
|
context.read<MenuBloc>().add(
|
||||||
MenuEvent.createApp(
|
MenuEvent.createApp(
|
||||||
LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
value,
|
||||||
index: 0,
|
index: 0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
widget.onAdded();
|
widget.onAdded();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
).show(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -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_add_button.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/view/view_more_action_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/workspace/presentation/widgets/dialogs.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.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:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
|
||||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -350,14 +350,23 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
|
|||||||
createNewView,
|
createNewView,
|
||||||
) {
|
) {
|
||||||
if (createNewView) {
|
if (createNewView) {
|
||||||
|
NavigatorTextFieldDialog(
|
||||||
|
title: _convertLayoutToHintText(pluginBuilder.layoutType!),
|
||||||
|
value: LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
||||||
|
autoSelectAllText: true,
|
||||||
|
confirm: (value) {
|
||||||
|
if (value.isNotEmpty) {
|
||||||
context.read<ViewBloc>().add(
|
context.read<ViewBloc>().add(
|
||||||
ViewEvent.createView(
|
ViewEvent.createView(
|
||||||
name ?? LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
value,
|
||||||
pluginBuilder.layoutType!,
|
pluginBuilder.layoutType!,
|
||||||
openAfterCreated: openAfterCreated,
|
openAfterCreated: openAfterCreated,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
).show(context);
|
||||||
|
}
|
||||||
context.read<ViewBloc>().add(
|
context.read<ViewBloc>().add(
|
||||||
const ViewEvent.setIsExpanded(true),
|
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 {
|
class _DotIconWidget extends StatelessWidget {
|
||||||
|
@ -86,6 +86,10 @@
|
|||||||
},
|
},
|
||||||
"blankPageTitle": "Blank page",
|
"blankPageTitle": "Blank page",
|
||||||
"newPageText": "New page",
|
"newPageText": "New page",
|
||||||
|
"newDocumentText": "New document",
|
||||||
|
"newGridText": "New grid",
|
||||||
|
"newCalendarText": "New calendar",
|
||||||
|
"newBoardText": "New board",
|
||||||
"trash": {
|
"trash": {
|
||||||
"text": "Trash",
|
"text": "Trash",
|
||||||
"restoreAll": "Restore All",
|
"restoreAll": "Restore All",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user