✅ Toggle switch with 2 icons
I’m trying to create a toggle like interaction between 2 icons.
Goal: When i press the 2nd icon, the 1st icon should return to default
Toggle switch icons.movThe setup:
1. Icon 1 (component) view model:
- Icon1 isActive (boolean)
- Icon1 isPressed (boolean)
- Use isPressed to run icon animation
2. Icon 2 (component) view model:
- Icon2 isActive (boolean)
- Icon2 isPressed (boolean)
- Use isPressed to run icon animation
3. Listener setup for both icon1:
- Pointer down:
- Set isPressed = true (to run pressed animation)
- Set Icon1 is Active = true
- Set Icon2 is Active = false
- Pointer up:
- Set isPressed = false (to run pressed animation)
- Release to Default animation:
- For icon1:
- When Icon2 isActive = true
4.Listener setup for both icon2:
Same but with inverted booleans
The i have put these 2 components together in another artboard. and created a new View model(Switch) to expose nested component view model properties