mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-11 16:08:04 +00:00
chore: remove rename dialog logic (#6906)
This commit is contained in:
parent
e7491e5182
commit
d9bc97e012
@ -49,6 +49,7 @@ class KVKeys {
|
|||||||
/// {'SidebarFolderCategoryType.value': true}
|
/// {'SidebarFolderCategoryType.value': true}
|
||||||
static const String expandedFolders = 'expandedFolders';
|
static const String expandedFolders = 'expandedFolders';
|
||||||
|
|
||||||
|
/// @deprecated in version 0.7.6
|
||||||
/// The key for saving if showing the rename dialog when creating a new file
|
/// The key for saving if showing the rename dialog when creating a new file
|
||||||
///
|
///
|
||||||
/// The value is a boolean string.
|
/// The value is a boolean string.
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
||||||
import 'package:appflowy/workspace/application/menu/sidebar_sections_bloc.dart';
|
import 'package:appflowy/workspace/application/menu/sidebar_sections_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/application/user/user_workspace_bloc.dart';
|
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/_folder_header.dart';
|
import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/_folder_header.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.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_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.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';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -78,10 +75,6 @@ class _SectionFolderState extends State<SectionFolder> {
|
|||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
context.read<FolderBloc>().add(const FolderEvent.expandOrUnExpand()),
|
context.read<FolderBloc>().add(const FolderEvent.expandOrUnExpand()),
|
||||||
onAdded: () {
|
onAdded: () {
|
||||||
createViewAndShowRenameDialogIfNeeded(
|
|
||||||
context,
|
|
||||||
LocaleKeys.newPageText.tr(),
|
|
||||||
(_, __) {
|
|
||||||
context.read<SidebarSectionsBloc>().add(
|
context.read<SidebarSectionsBloc>().add(
|
||||||
SidebarSectionsEvent.createRootViewInSection(
|
SidebarSectionsEvent.createRootViewInSection(
|
||||||
name: '',
|
name: '',
|
||||||
@ -95,8 +88,6 @@ class _SectionFolderState extends State<SectionFolder> {
|
|||||||
.add(const FolderEvent.expandOrUnExpand(isExpanded: true));
|
.add(const FolderEvent.expandOrUnExpand(isExpanded: true));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<Widget> _buildViews(
|
Iterable<Widget> _buildViews(
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
import 'package:appflowy/core/config/kv.dart';
|
|
||||||
import 'package:appflowy/core/config/kv_keys.dart';
|
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
||||||
import 'package:appflowy/startup/startup.dart';
|
|
||||||
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
/// Creates a new view and shows the rename dialog if needed.
|
|
||||||
///
|
|
||||||
/// If the user has enabled the setting to show the rename dialog when creating a new view,
|
|
||||||
/// this function will show the rename dialog.
|
|
||||||
///
|
|
||||||
/// Otherwise, it will just create the view with default name.
|
|
||||||
Future<void> createViewAndShowRenameDialogIfNeeded(
|
|
||||||
BuildContext context,
|
|
||||||
String dialogTitle,
|
|
||||||
void Function(String viewName, BuildContext context) createView,
|
|
||||||
) async {
|
|
||||||
final value = await getIt<KeyValueStorage>().getWithFormat(
|
|
||||||
KVKeys.showRenameDialogWhenCreatingNewFile,
|
|
||||||
(value) => bool.parse(value),
|
|
||||||
);
|
|
||||||
final showRenameDialog = value ?? false;
|
|
||||||
final defaultName = LocaleKeys.menuAppHeader_defaultNewPageName.tr();
|
|
||||||
if (context.mounted && showRenameDialog) {
|
|
||||||
await NavigatorTextFieldDialog(
|
|
||||||
title: dialogTitle,
|
|
||||||
value: defaultName,
|
|
||||||
autoSelectAllText: true,
|
|
||||||
onConfirm: createView,
|
|
||||||
).show(context);
|
|
||||||
} else if (context.mounted) {
|
|
||||||
createView(defaultName, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,7 +5,6 @@ import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart';
|
|||||||
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
|
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/hotkeys.dart';
|
import 'package:appflowy/workspace/presentation/home/hotkeys.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart';
|
|
||||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
import 'package:appflowy_backend/protobuf/flowy-folder/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';
|
||||||
@ -57,13 +56,8 @@ class _SidebarNewPageButtonState extends State<SidebarNewPageButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _createNewPage() async {
|
Future<void> _createNewPage() async {
|
||||||
return createViewAndShowRenameDialogIfNeeded(
|
|
||||||
context,
|
|
||||||
LocaleKeys.newPageText.tr(),
|
|
||||||
(_, __) {
|
|
||||||
// if the workspace is collaborative, create the view in the private section by default.
|
// if the workspace is collaborative, create the view in the private section by default.
|
||||||
final section =
|
final section = context.read<UserWorkspaceBloc>().state.isCollabWorkspaceOn
|
||||||
context.read<UserWorkspaceBloc>().state.isCollabWorkspaceOn
|
|
||||||
? ViewSectionPB.Private
|
? ViewSectionPB.Private
|
||||||
: ViewSectionPB.Public;
|
: ViewSectionPB.Public;
|
||||||
final spaceState = context.read<SpaceBloc>().state;
|
final spaceState = context.read<SpaceBloc>().state;
|
||||||
@ -85,7 +79,5 @@ class _SidebarNewPageButtonState extends State<SidebarNewPageButton> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import 'package:appflowy/workspace/application/view/prelude.dart';
|
|||||||
import 'package:appflowy/workspace/application/view/view_ext.dart';
|
import 'package:appflowy/workspace/application/view/view_ext.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
import 'package:appflowy/workspace/presentation/home/home_sizes.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
|
import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart';
|
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart';
|
import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.dart';
|
import 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.dart';
|
||||||
import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart';
|
import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart';
|
||||||
@ -692,15 +691,10 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
|
|||||||
) {
|
) {
|
||||||
final viewBloc = context.read<ViewBloc>();
|
final viewBloc = context.read<ViewBloc>();
|
||||||
|
|
||||||
if (createNewView) {
|
|
||||||
createViewAndShowRenameDialogIfNeeded(
|
|
||||||
context,
|
|
||||||
_convertLayoutToHintText(pluginBuilder.layoutType!),
|
|
||||||
(viewName, _) {
|
|
||||||
// the name of new document should be empty
|
// the name of new document should be empty
|
||||||
if (pluginBuilder.layoutType == ViewLayoutPB.Document) {
|
final viewName = pluginBuilder.layoutType != ViewLayoutPB.Document
|
||||||
viewName = '';
|
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
|
||||||
}
|
: '';
|
||||||
viewBloc.add(
|
viewBloc.add(
|
||||||
ViewEvent.createView(
|
ViewEvent.createView(
|
||||||
viewName,
|
viewName,
|
||||||
@ -709,9 +703,6 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
|
|||||||
section: widget.spaceType.toViewSectionPB,
|
section: widget.spaceType.toViewSectionPB,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
viewBloc.add(const ViewEvent.setIsExpanded(true));
|
viewBloc.add(const ViewEvent.setIsExpanded(true));
|
||||||
}
|
}
|
||||||
@ -815,22 +806,6 @@ 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();
|
|
||||||
case ViewLayoutPB.Chat:
|
|
||||||
return LocaleKeys.chat_newChat.tr();
|
|
||||||
}
|
|
||||||
return LocaleKeys.newPageText.tr();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DotIconWidget extends StatelessWidget {
|
class _DotIconWidget extends StatelessWidget {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user