Skip to content

feat(Collapse-Bar): 添加折叠/展开动画#3081

Merged
LuLu-ling merged 3 commits into
devfrom
feat/MyCollapseBar-Animation
Jun 8, 2026
Merged

feat(Collapse-Bar): 添加折叠/展开动画#3081
LuLu-ling merged 3 commits into
devfrom
feat/MyCollapseBar-Animation

Conversation

@LuLu-ling

@LuLu-ling LuLu-ling commented Jun 8, 2026

Copy link
Copy Markdown
Member

Generated by deepseek-v4-pro

Summary by Sourcery

为 MyCollapseBar 添加基于高度的折叠/展开动画行为,并使其与父级卡片动画的集成更加顺畅。

New Features:

  • 为 MyCollapseBar 引入基于高度的折叠和展开动画,同时保持三角形旋转效果。

Enhancements:

  • 在 MyCollapseBar 中处理父级 MyCard 动画的抑制与恢复,以防止在切换过程中出现布局跳动。
  • 通过将折叠行为内联到 MyCollapseBar 中,并移除外部切换处理器和额外的边距配置,简化依赖栏的设置。
Original summary in English

Summary by Sourcery

Add animated height-based collapse/expand behavior to MyCollapseBar and integrate it more cleanly with parent card animations.

New Features:

  • Introduce height-based collapse and expand animations for MyCollapseBar while preserving triangle rotation.

Enhancements:

  • Handle suppression and restoration of parent MyCard animations within MyCollapseBar to prevent layout jumps during toggling.
  • Simplify dependency bar setup by inlining collapse behavior into MyCollapseBar and removing the external toggle handler and extra margin configuration.

@LuLu-ling LuLu-ling requested a review from a team June 8, 2026 11:29
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Jun 8, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 8, 2026

Copy link
Copy Markdown

审查者指南

为 MyCollapseBar 实现基于高度的动画折叠/展开行为,包括协调的三角形旋转和对父级 MyCard 动画的抑制,并通过删除外部 toggled 逻辑和依赖条的边距,简化依赖折叠处理。

MyCollapseBar 折叠/展开动画的时序图

sequenceDiagram
    actor User
    participant MyCollapseBar
    participant ModAnimation
    participant MyCard

    User->>MyCollapseBar: header MouseLeftButtonUp
    MyCollapseBar->>MyCollapseBar: IsCollapsed setter
    alt value == true (collapse)
        MyCollapseBar->>ModAnimation: AniStart (triangle rotation)
        MyCollapseBar->>MyCollapseBar: CollapseWithAnimation()
        MyCollapseBar->>ModAnimation: AniStop(MyCollapseBar Height uuid)
        MyCollapseBar->>MyCollapseBar: SilenceParentCard(this)
        MyCollapseBar-->>MyCard: UseAnimation = false
        MyCollapseBar->>ModAnimation: AniStart(AaHeight, AaCode)
        ModAnimation-->>MyCollapseBar: AaCode callback
        MyCollapseBar->>MyCollapseBar: _contentPanel.Visibility = Collapsed
        MyCollapseBar->>MyCollapseBar: RestoreParentCard(state)
        MyCollapseBar-->>MyCard: UseAnimation = original
    else value == false (expand)
        MyCollapseBar->>ModAnimation: AniStart (triangle rotation)
        MyCollapseBar->>MyCollapseBar: ExpandWithAnimation()
        MyCollapseBar->>ModAnimation: AniStop(MyCollapseBar Height uuid)
        MyCollapseBar->>MyCollapseBar: SilenceParentCard(this)
        MyCollapseBar-->>MyCard: UseAnimation = false
        MyCollapseBar->>MyCollapseBar: _contentPanel.Visibility = Visible
        MyCollapseBar->>MyCollapseBar: Measure, DesiredSize
        MyCollapseBar->>ModAnimation: AniStart(AaHeight, AaCode)
        ModAnimation-->>MyCollapseBar: AaCode callback
        MyCollapseBar->>MyCollapseBar: Height = NaN
        MyCollapseBar->>MyCollapseBar: RestoreParentCard(state)
        MyCollapseBar-->>MyCard: UseAnimation = original
    end
Loading

文件级变更

变更 详情 文件
为 MyCollapseBar 添加基于高度的动画折叠/展开行为,同时保留三角形旋转和标题布局。
  • 引入 HeaderHeight 常量,并将其复用为标题 Grid 的高度。
  • 重构 IsCollapsed,使其使用自动属性的后备字段,保留三角形旋转动画,并在加载后将内容可见性变更委托给新的动画辅助方法。
  • 实现 CollapseWithAnimation 和 ExpandWithAnimation,在切换内容可见性的同时对控件 Height 进行动画,并在结束后将 Height 恢复为 Auto。
  • 为展开操作测量 DesiredSize 以计算目标高度,并使用带平滑缓动的 ModAnimation 实现平滑过渡。
  • 添加 SilenceParentCard 和 RestoreParentCard 辅助方法,以在折叠/展开动画期间临时禁用最近的 MyCard 祖先上的 UseAnimation。
Plain Craft Launcher 2/Controls/MyCollapseBar.cs
简化依赖折叠条集成,因为 MyCollapseBar 现在在内部管理其父卡片的动画和布局。
  • 从依赖的 MyCollapseBar 实例中移除自定义底部边距,改为依赖默认间距。
  • 停止将依赖条订阅到 Toggled 处理程序,并移除手动抑制 MyCard 动画和强制调整大小的 _DependencyBarToggled 方法。
Plain Craft Launcher 2/Modules/Minecraft/ModComp.cs

技巧与命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 在审查评论下回复,要求 Sourcery 从该评论创建一个 issue。你也可以在审查评论中回复 @sourcery-ai issue 来从该评论创建一个 issue。
  • 生成 pull request 标题: 在 pull request 标题中的任意位置写上 @sourcery-ai 来随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中的任意位置写上 @sourcery-ai summary,在你需要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide 来随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,以关闭所有现有的 Sourcery 审查。特别适用于你想从一个新的审查开始的场景——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

前往你的 dashboard 来:

  • 启用或禁用审查特性,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Implements animated height-based collapse/expand behavior for MyCollapseBar, including coordinated triangle rotation and suppression of parent MyCard animations, and simplifies dependency collapse handling by removing external toggled logic and margin from dependency bars.

Sequence diagram for MyCollapseBar collapse/expand animation

sequenceDiagram
    actor User
    participant MyCollapseBar
    participant ModAnimation
    participant MyCard

    User->>MyCollapseBar: header MouseLeftButtonUp
    MyCollapseBar->>MyCollapseBar: IsCollapsed setter
    alt value == true (collapse)
        MyCollapseBar->>ModAnimation: AniStart (triangle rotation)
        MyCollapseBar->>MyCollapseBar: CollapseWithAnimation()
        MyCollapseBar->>ModAnimation: AniStop(MyCollapseBar Height uuid)
        MyCollapseBar->>MyCollapseBar: SilenceParentCard(this)
        MyCollapseBar-->>MyCard: UseAnimation = false
        MyCollapseBar->>ModAnimation: AniStart(AaHeight, AaCode)
        ModAnimation-->>MyCollapseBar: AaCode callback
        MyCollapseBar->>MyCollapseBar: _contentPanel.Visibility = Collapsed
        MyCollapseBar->>MyCollapseBar: RestoreParentCard(state)
        MyCollapseBar-->>MyCard: UseAnimation = original
    else value == false (expand)
        MyCollapseBar->>ModAnimation: AniStart (triangle rotation)
        MyCollapseBar->>MyCollapseBar: ExpandWithAnimation()
        MyCollapseBar->>ModAnimation: AniStop(MyCollapseBar Height uuid)
        MyCollapseBar->>MyCollapseBar: SilenceParentCard(this)
        MyCollapseBar-->>MyCard: UseAnimation = false
        MyCollapseBar->>MyCollapseBar: _contentPanel.Visibility = Visible
        MyCollapseBar->>MyCollapseBar: Measure, DesiredSize
        MyCollapseBar->>ModAnimation: AniStart(AaHeight, AaCode)
        ModAnimation-->>MyCollapseBar: AaCode callback
        MyCollapseBar->>MyCollapseBar: Height = NaN
        MyCollapseBar->>MyCollapseBar: RestoreParentCard(state)
        MyCollapseBar-->>MyCard: UseAnimation = original
    end
Loading

File-Level Changes

Change Details Files
Add animated height-based collapse/expand behavior to MyCollapseBar while preserving triangle rotation and header layout.
  • Introduce a HeaderHeight constant and reuse it for the header Grid height.
  • Refactor IsCollapsed to use an auto-property backing field, keep triangle rotation animation, and delegate content visibility changes to new animation helpers when loaded.
  • Implement CollapseWithAnimation and ExpandWithAnimation to animate the control Height while toggling content visibility and restoring Height to Auto afterward.
  • Measure DesiredSize for expansion to compute target height and use ModAnimation with fluent easing for smooth transitions.
  • Add SilenceParentCard and RestoreParentCard helpers to temporarily disable UseAnimation on the nearest MyCard ancestor during collapse/expand animations.
Plain Craft Launcher 2/Controls/MyCollapseBar.cs
Simplify dependency collapse bar integration now that MyCollapseBar internally manages its parent card animations and layout.
  • Remove custom bottom margin from dependency MyCollapseBar instances to rely on default spacing.
  • Stop subscribing dependency bars to a Toggled handler and remove the _DependencyBarToggled method that manually suppressed MyCard animations and forced resize.
Plain Craft Launcher 2/Modules/Minecraft/ModComp.cs

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0317a33944

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Plain Craft Launcher 2/Controls/MyCollapseBar.cs

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些总体反馈:

  • IsCollapsed 自动属性现在在 setter 中依赖 C# 的 field 关键字(并移除了 _isCollapsed 后备字段);请确认项目的 LangVersion 足够高,并且在所有目标上保持一致以支持这种语法,或者为了更广泛的兼容性退回到显式后备字段的写法。
  • CollapseWithAnimationExpandWithAnimation 中,高度差值以及对 ActualHeight/DesiredSize 的假设,在控件处于布局中途或受到约束时(例如嵌套在其他动画或固定高度的容器中)可能会表现异常;建议在 ActualHeight <= HeaderHeight 时做保护,或者通过更保守的重新测量来避免负值/零长度的动画范围。
面向 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- `IsCollapsed` 自动属性现在在 setter 中依赖 C# 的 `field` 关键字(并移除了 `_isCollapsed` 后备字段);请确认项目的 LangVersion 足够高,并且在所有目标上保持一致以支持这种语法,或者为了更广泛的兼容性退回到显式后备字段的写法。
-`CollapseWithAnimation``ExpandWithAnimation` 中,高度差值以及对 `ActualHeight`/`DesiredSize` 的假设,在控件处于布局中途或受到约束时(例如嵌套在其他动画或固定高度的容器中)可能会表现异常;建议在 `ActualHeight <= HeaderHeight` 时做保护,或者通过更保守的重新测量来避免负值/零长度的动画范围。

Sourcery 对开源项目免费 —— 如果你觉得我们的代码审查有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈来改进后续的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • The IsCollapsed auto-property now relies on the C# field keyword in the setter (and removed the _isCollapsed backing field); verify the project’s LangVersion is high enough and consistent across targets to support this syntax, or fall back to an explicit backing field for broader compatibility.
  • In CollapseWithAnimation and ExpandWithAnimation, the height deltas and ActualHeight/DesiredSize assumptions could misbehave if the control is mid-layout or constrained (e.g., inside other animations or fixed-height containers); consider guarding against ActualHeight <= HeaderHeight or re-measuring more defensively to avoid negative/zero animation ranges.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `IsCollapsed` auto-property now relies on the C# `field` keyword in the setter (and removed the `_isCollapsed` backing field); verify the project’s LangVersion is high enough and consistent across targets to support this syntax, or fall back to an explicit backing field for broader compatibility.
- In `CollapseWithAnimation` and `ExpandWithAnimation`, the height deltas and `ActualHeight`/`DesiredSize` assumptions could misbehave if the control is mid-layout or constrained (e.g., inside other animations or fixed-height containers); consider guarding against `ActualHeight <= HeaderHeight` or re-measuring more defensively to avoid negative/zero animation ranges.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b0633951a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Plain Craft Launcher 2/Controls/MyCollapseBar.cs
@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Jun 8, 2026
@LuLu-ling LuLu-ling merged commit ea7d958 into dev Jun 8, 2026
3 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels Jun 8, 2026
@LuLu-ling LuLu-ling deleted the feat/MyCollapseBar-Animation branch June 8, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L PR 大小评估:大型 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants