Skip to content

feat(core): add APL component trait interfaces and composition pattern#137

Merged
ncipollina merged 2 commits intomainfrom
feat/apl-component-trait-interfaces
Mar 5, 2026
Merged

feat(core): add APL component trait interfaces and composition pattern#137
ncipollina merged 2 commits intomainfrom
feat/apl-component-trait-interfaces

Conversation

@ncipollina
Copy link
Collaborator

🚀 Pull Request

📋 Summary

Introduces a trait-based composition pattern for APL components to support multi-inheritance across the component hierarchy. Rather than duplicating properties across components, shared behaviour is now expressed via interfaces with sealed trait backing classes.

New trait interfaces & classes:

  • IMultiChildComponent / MultiChildComponentTraitData, FirstItem, Items, LastItem, OnChildrenChanged
  • IActionableComponent / ActionableComponentTraitOnBlur, OnFocus, HandleKeyDown, HandleKeyUp
  • ITouchableComponent / TouchableComponentTraitGestures, OnCancel, OnDown, OnUp, OnMove, OnPress

Refactored components (now implement interfaces via composition):

  • Container, GridSequence, Pager, SequenceIMultiChildComponent
  • ActionableComponentIActionableComponent
  • TouchComponentITouchableComponent

New component:

  • FlexSequence — scrollable flex-layout container implementing IMultiChildComponent

Additional property additions:

  • ScrollView: AllowForward, AllowBackwards
  • Text: OnTextLayout
  • Video: ScreenLock

All new interfaces and trait classes include full XML documentation.


✅ Checklist

  • My changes build cleanly
  • I've added/updated relevant tests
  • I've added/updated documentation or README
  • I've followed the coding style for this project
  • I've tested the changes locally (if applicable)

🧪 Related Issues or PRs

Closes #...


💬 Notes for Reviewers

  • The trait classes are sealed and [JsonIgnore]d — they exist purely as composition backing stores and never appear in serialized output.
  • RegisterTypeInfo<T>() on each trait class calls AlexaJsonOptions.RegisterTypeModifier so that custom JSON converters are applied regardless of which concrete component type is being serialized.
  • FlexSequence is registered in APLComponentConverter so it participates in polymorphic deserialization.
  • Property ordering in refactored components groups own properties first, then // IMultiChildComponent delegating properties — consistent with the pattern established in Container.

🤖 Generated with Claude Code

Introduces IMultiChildComponent, IActionableComponent, and ITouchableComponent
interfaces with corresponding sealed trait classes (MultiChildComponentTrait,
ActionableComponentTrait, TouchableComponentTrait) to support multi-inheritance
via composition. Refactors Container, GridSequence, Pager, Sequence,
ActionableComponent, and TouchComponent to implement these interfaces using
composition. Adds FlexSequence as a new scrollable flex-layout component.
Also adds missing properties to ScrollView (AllowForward, AllowBackwards),
Text (OnTextLayout), and Video (ScreenLock), and adds full XML documentation
to all new interfaces and trait classes.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

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

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: d7fde7915c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: Claude <noreply@anthropic.com>
@ncipollina ncipollina merged commit 46cf1b3 into main Mar 5, 2026
4 checks passed
@ncipollina ncipollina deleted the feat/apl-component-trait-interfaces branch March 5, 2026 15:24
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