Skip to content

enhance: extract reusable CopyButton control with copy feedback - #2668

Merged
love-linger merged 3 commits into
sourcegit-scm:developfrom
JC-Chung:enhance/reusable-copy-button
Sep 1, 2026
Merged

enhance: extract reusable CopyButton control with copy feedback#2668
love-linger merged 3 commits into
sourcegit-scm:developfrom
JC-Chung:enhance/reusable-copy-button

Conversation

@JC-Chung

@JC-Chung JC-Chung commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What

Extracts the "copy + show checkmark for 1s" logic into a reusable
CopyButton control (src/Views/CopyButton.cs), and uses it in:

  • CommitBaseInfo (copy commit SHA)
  • LauncherPage (copy notification message)

Why

Both places previously implemented very similar copy-feedback logic
(a DispatcherTimer + two icons toggled by an IsCopied flag)
separately. CopyButton consolidates this into one control driven by
a CopyText property, so no changes to data models are needed.

Note

This overlaps with #2666, which adds the same copy-feedback UX to
LauncherPage via Notification.IsCopied. Left a comment there to
discuss which approach to land on.

Comment thread src/Views/CopyButton.cs Outdated
{
protected override Type StyleKeyOverride => typeof(Button);

public static readonly StyledProperty<string> CopyTextProperty =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CopyText is a per-instance-data. I suggest to use DirectProperty instead of StyledProperty for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Pushed two commits addressing this:

  1. fix: ...OnClick was setting IsCopied = true even when CopyText was empty, so it now returns early in that case. Also removed the now-redundant if (_resetTimer != null) check in OnUnloaded, since _resetTimer is always initialized in OnLoaded by the time OnUnloaded runs (same pattern as CommitBaseInfo's _iconResetTimer, which never null-checks it either).
  2. code_style: ... — switched CopyText to DirectProperty as suggested, since it's purely per-instance data with no styling/animation use case, matching the existing IsCopied property.

@love-linger love-linger self-assigned this Sep 1, 2026
@love-linger love-linger added the enhancement New feature or request label Sep 1, 2026
@love-linger
love-linger merged commit 0e83ccd into sourcegit-scm:develop Sep 1, 2026
14 checks passed
@JC-Chung
JC-Chung deleted the enhance/reusable-copy-button branch September 1, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants