Skip to content

Conversation

@richardshiue
Copy link
Collaborator

@richardshiue richardshiue commented Jun 13, 2025

Screenshot 2025-06-13 at 10 56 44 AM

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 13, 2025

Reviewer's Guide

Introduces a new flexible text‐field dialog component (AFTextFieldDialog and its showAFTextFieldDialog API), replaces all legacy NavigatorTextFieldDialog usages across the UI and tests, refactors modal header styling to use DefaultTextStyle, and extends AFTextField to support maxLength enforcement.

Sequence diagram for the new rename dialog

sequenceDiagram
    actor User
    participant UI as Calling UI Component
    participant Func as showAFTextFieldDialog()
    participant Dialog as AFTextFieldDialog
    participant Navigator

    User->>UI: Clicks "Rename"
    UI->>Func: Calls with initial value and onConfirm callback
    Func->>Navigator: showDialog(builder: AFTextFieldDialog)
    activate Dialog
    Navigator-->>User: Displays rename dialog
    User->>Dialog: Enters new name
    User->>Dialog: Clicks "Confirm" button
    Dialog->>Dialog: handleConfirm()
    Dialog->>UI: Executes onConfirm(newName) callback
    Dialog->>Navigator: pop(newName)
    deactivate Dialog
Loading

Class diagram for the dialog refactoring

classDiagram
    direction LR

    class NavigatorTextFieldDialog {
        <<Removed>>
        +String value
        +String title
        +void Function(String, BuildContext) onConfirm
        +bool autoSelectAllText
        +int? maxLength
        +String? hintText
    }

    class CreateWorkspaceDialog {
        <<Removed>>
        +void Function(String) onConfirm
    }

    class AFTextFieldDialog {
        <<Added>>
        +String title
        +String initialValue
        +void Function(String)? onConfirm
        +bool selectAll
        +int? maxLength
        +String? hintText
        -TextEditingController textController
        +handleConfirm() void
    }

    class showAFTextFieldDialog {
        <<Function>>
        +showAFTextFieldDialog(context, title, initialValue, onConfirm) Future~String?~
    }

    class AFTextField {
        <<Modified>>
        +int? maxLength
    }

    class AFModalHeader {
        <<Modified>>
        +Widget leading
        +List~Widget~ trailing
    }

    CreateWorkspaceDialog --* NavigatorTextFieldDialog : uses
    showAFTextFieldDialog ..> AFTextFieldDialog : creates
    AFTextFieldDialog "1" *-- "1" AFTextField : uses
Loading

File-Level Changes

Change Details Files
Introduce a standalone AFTextFieldDialog and showAFTextFieldDialog API
  • Added showAFTextFieldDialog wrapper returning Future<String?>
  • Implemented AFTextFieldDialog StatefulWidget with controller setup, selection logic, confirm handling
  • Integrated locale_keys and easy_localization for cancel/confirm buttons
frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart
Replace legacy NavigatorTextFieldDialog with showAFTextFieldDialog
  • Removed NavigatorTextFieldDialog class and related imports
  • Imported dialog_v2.dart where dialogs were used
  • Replaced calls to NavigatorTextFieldDialog.show(...) with showAFTextFieldDialog(...)
  • Updated integration and unit tests to look for AFTextFieldDialog/AFTextField
frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialogs.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/favorites/favorite_more_actions.dart
frontend/appflowy_flutter/lib/features/shared_section/presentation/shared_section.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/sidebar_space_header.dart
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart
frontend/appflowy_flutter/lib/plugins/database/tab_bar/desktop/tab_bar_header.dart
frontend/appflowy_flutter/lib/integration_test/shared/common_operations.dart
frontend/appflowy_flutter/integration_test/desktop/cloud/sidebar/sidebar_rename_untitled_test.dart
Refactor AFModalHeader to apply default text style
  • Wrapped Row children in DefaultTextStyle to apply theme.textStyle.heading4.prominent
  • Removed manual style on title Text
frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/modal/modal.dart
Extend AFTextField to support maxLength enforcement
  • Added maxLength property and maxLengthEnforcement to AFTextField
  • Applied maxLength on the underlying TextField in decoration
frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @richardshiue - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart:112` </location>
<code_context>
+  required String title,
+  required String initialValue,
+  void Function(String)? onConfirm,
+  SimpleAFDialogAction? secondaryAction,
+  bool barrierDismissible = true,
+  bool selectAll = true,
</code_context>

<issue_to_address>
The `secondaryAction` parameter is declared but never used

Consider removing the unused `secondaryAction` parameter or implementing it in the dialog's footer, such as by adding a secondary button.
</issue_to_address>

### Comment 2
<location> `frontend/appflowy_flutter/packages/appflowy_ui/lib/src/component/textfield/textfield.dart:189` </location>
<code_context>
+                autoFocus: true,
+                size: AFTextFieldSize.m,
+                hintText: widget.hintText,
+                maxLength: widget.maxLength,
+                controller: textController,
+                onSubmitted: (_) {
</code_context>

<issue_to_address>
Adding `maxLength` will show a default counter below the field

If you don't want the default counter, set `counterText: ''` or use a custom `buildCounter` in the decoration.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
autofocus: widget.autoFocus ?? false,
maxLength: widget.maxLength,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Adding maxLength will show a default counter below the field

If you don't want the default counter, set counterText: '' or use a custom buildCounter in the decoration.

@richardshiue richardshiue force-pushed the refactor/rename-dialog branch 10 times, most recently from 4530781 to bf38ad3 Compare June 13, 2025 17:30
@richardshiue richardshiue force-pushed the refactor/rename-dialog branch from bf38ad3 to 30851db Compare June 14, 2025 03:24
@richardshiue richardshiue merged commit d4f9c71 into AppFlowy-IO:main Jun 16, 2025
31 of 33 checks passed
@richardshiue richardshiue deleted the refactor/rename-dialog branch June 16, 2025 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant