Skip to content

Custom Toggle #149

@sieunju

Description

@sieunju

Title: [Feature] CustomSwitchView — Apple-style toggle switch

Labels: enhancement, view


Summary

Add a CustomSwitchView to the view module that replicates the smooth, minimal toggle switch seen in iOS/macOS — satisfying the library's core concept of zero external dependencies.


Design Reference

iOS UISwitch behavior:

  • Rounded pill-shaped track (thumb + track)
  • Thumb slides left ↔ right with spring-like animation
  • Track color transitions smoothly (e.g., gray → green)
  • Supports tap and drag-to-toggle gestures

Expected API

<hmju.widget.view.CustomSwitchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:switchChecked="true"
app:trackColorOn="@color/green"
app:trackColorOff="@color/gray"
app:thumbColor="@color/white"
app:animationDuration="250" />

switchView.setOnCheckedChangeListener { isChecked -> }
switchView.isChecked = true


Acceptance Criteria

  • Thumb slide animation with configurable duration
  • Track color transition animation on toggle
  • Drag gesture support (partial drag → snap to nearest state)
  • isChecked property + setOnCheckedChangeListener
  • XML attrs: trackColorOn, trackColorOff, thumbColor, animationDuration
  • Example screen added to app module
  • No external library dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions