Skip to content

Commit

Permalink
fix: rename untitled view
Browse files Browse the repository at this point in the history
  • Loading branch information
Xazin committed Nov 14, 2024
1 parent 555d08e commit f482d37
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ class TabBarItemButton extends StatelessWidget {
case TabBarViewAction.rename:
NavigatorTextFieldDialog(
title: LocaleKeys.menuAppHeader_renameDialog.tr(),
value: view.name,
value: view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: view.name,
onConfirm: (newValue, _) {
context.read<DatabaseTabBarBloc>().add(
DatabaseTabBarEvent.renameView(view.id, newValue),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class FavoriteMoreActions extends StatelessWidget {
NavigatorTextFieldDialog(
title: LocaleKeys.disclosureAction_rename.tr(),
autoSelectAllText: true,
value: view.name,
value: view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: view.name,
maxLength: 256,
onConfirm: (newValue, _) {
// can not use bloc here because it has been disposed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Future<void> createViewAndShowRenameDialogIfNeeded(
if (context.mounted && showRenameDialog) {
await NavigatorTextFieldDialog(
title: dialogTitle,
value: defaultName,
value: defaultName.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: defaultName,
autoSelectAllText: true,
onConfirm: createView,
).show(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
NavigatorTextFieldDialog(
title: LocaleKeys.disclosureAction_rename.tr(),
autoSelectAllText: true,
value: widget.view.name,
value: widget.view.name.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: widget.view.name,
maxLength: 256,
onConfirm: (newValue, _) {
context.read<ViewBloc>().add(ViewEvent.rename(newValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class _NavigatorTextFieldDialogState extends State<NavigatorTextFieldDialog> {
@override
void initState() {
super.initState();
newValue = widget.value;
newValue = widget.value.isEmpty
? LocaleKeys.menuAppHeader_defaultNewPageName.tr()
: widget.value;
controller.text = newValue;
if (widget.autoSelectAllText) {
controller.selection = TextSelection(
Expand Down

0 comments on commit f482d37

Please sign in to comment.