Skip to content

feat: add LineBreakMode to NiceButton with orientation-aware wrapping#32

Merged
nord- merged 14 commits into
masterfrom
feat/nicebutton-linebreak-mode
Jun 11, 2026
Merged

feat: add LineBreakMode to NiceButton with orientation-aware wrapping#32
nord- merged 14 commits into
masterfrom
feat/nicebutton-linebreak-mode

Conversation

@nord-

@nord- nord- commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Closes #31

Changes

  • New nullable LineBreakMode BindableProperty (null = auto: WordWrap for Vertical, TailTruncation for Horizontal)
  • Explicit value always wins regardless of Orientation
  • RebuildContent() uses a Star text column + Fill whenever text is present, so a width-constrained button actually limits the label — it then wraps (WordWrap) or ellipsizes (TailTruncation). An Auto column would measure the label at infinite width, so truncation never engaged and icons were pushed out of view.
  • NiceButtonLayoutManager.Measure uses a two-pass strategy for any text content (gated on HasTextContent): natural measure first (Star acts as Auto at infinity → button hugs short text), bounded re-measure only when content overflows
  • Icon-only buttons skip the extra pass; no layout mutations during measure
  • Demo app: new ButtonsPage (flyout menu entry) with all NiceButton variants plus 10 LineBreakMode smoke-test scenarios in a two-column grid
  • README property table updated

Verification

Manual smoke test on Android emulator: all 10 scenarios pass — hug (S1/S6), ellipsis (S2/S4), wrap without edge clipping (S3/S5), icon + ellipsis (S7/S8), icon + wrap (S9/S10). No regressions on full-width buttons.

Copilot AI review requested due to automatic review settings June 10, 2026 18:24
@nord- nord- added enhancement New feature or request minor labels Jun 10, 2026

Copilot AI 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.

Pull request overview

Adds configurable, orientation-aware text wrapping to NiceButton by introducing a nullable LineBreakMode API and updating the button’s grid layout + measurement strategy so WordWrap can actually take effect under constrained widths.

Changes:

  • Introduces nullable LineBreakMode (null = auto-resolve based on Orientation) and computes EffectiveLineBreakMode.
  • Updates RebuildContent() to set grid column sizing (Star vs Auto) and _contentHost.HorizontalOptions (Fill vs Center) based on whether text wrapping is active.
  • Updates NiceButtonLayoutManager.Measure() to use a two-pass measurement strategy when wrapping is enabled.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents the new LineBreakMode property in the public API table.
NiceEntry/NiceButtonLayoutManager.cs Adds two-pass measurement to support wrapping while preserving “hug content” sizing when possible.
NiceEntry/NiceButton.cs Adds LineBreakMode BindableProperty + effective mode logic; rebuilds layout to enable wrapping.
docs/superpowers/specs/2026-06-10-nicebutton-linebreak-design.md Design spec describing the API + layout/measurement approach.
docs/superpowers/plans/2026-06-10-nicebutton-linebreak-mode.md Implementation plan and validation checklist for the change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread NiceEntry/NiceButton.cs
Comment thread NiceEntry/NiceButton.cs Outdated
Comment thread NiceEntryDemoApp/ButtonsPage.xaml.cs
Comment thread NiceEntry/NiceButton.cs Outdated
Comment thread NiceEntry/NiceButton.cs Outdated
Comment thread NiceEntry/NiceButton.cs Outdated
Comment thread NiceEntry/NiceButton.cs Outdated
Rickard Nord added 2 commits June 11, 2026 10:01
Address PR #32 review: revert the content grid to Auto columns with a
centered host so a stretched button keeps icon and text together, and
have NiceButtonLayoutManager cap the text label MaximumWidthRequest at
the leftover width so WordWrap/TailTruncation still engage. Also derive
HasTextContent from Text, give LineBreakMode a lightweight changed
handler, invalidate measure when content is cleared, and drop the dead
using and vestigial textColumnWidth local.
IsButtonEnabled and NiceButtonTapped moved to ButtonsViewModel; the
MainPage copies were no longer referenced by any XAML.
@nord- nord- merged commit 96844f8 into master Jun 11, 2026
1 check passed
@nord- nord- deleted the feat/nicebutton-linebreak-mode branch June 11, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set linebreak mode on NiceButton label to support multi-line text

2 participants