CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tns-platform-declarations

Platform-specific TypeScript declarations for NativeScript for accessing native objects

84

1.23x
Overview
Eval results
Files

task.mdevals/scenario-3/

Custom Animation Manager

Build a simple animation manager for a mobile application that handles custom view transitions with configurable duration and easing.

Requirements

Create an animation manager that can:

  1. Transition Configuration: Accept configuration for a transition including:

    • Duration in milliseconds
    • Target view properties to animate
    • Interpolator type for easing (e.g., accelerate, decelerate, linear)
  2. Animation Execution: Execute the configured transition and handle:

    • Starting the animation sequence
    • Canceling ongoing animations if needed
    • Completion callbacks
  3. Multiple Property Animations: Support animating multiple properties simultaneously:

    • Alpha (opacity) changes
    • Translation (position) changes
    • Scale transformations
  4. Performance Monitoring: Track basic animation performance:

    • Record start and end timestamps
    • Calculate total animation duration
    • Return performance metrics after completion

Implementation Details

  • Create a TransitionConfig interface/class to hold transition parameters (duration, properties to animate, interpolator type)
  • Create an AnimationManager class with methods to:
    • Start an animation with the provided configuration
    • Cancel an ongoing animation
    • Return performance metrics (start time, end time, duration)
  • Use async/await patterns where appropriate for completion handling
  • The solution should work specifically with Android platform widgets

Dependencies { .dependencies }

tns-platform-declarations { .dependency }

Provides NativeScript platform declarations for accessing Android widgets and animation APIs.

Test Cases { .tests }

Test 1: Basic Fade Animation @test

File: animation-manager.test.ts

Test: Create a fade-in animation that changes alpha from 0 to 1 over 300ms with linear interpolation. Verify the animation completes successfully.

Expected: Animation should complete and return success status with performance metrics showing duration close to 300ms.

Test 2: Combined Transform Animation @test

File: animation-manager.test.ts

Test: Create an animation that simultaneously changes alpha from 0 to 1 and translates a view by 100 pixels vertically over 500ms. Verify both properties animate together.

Expected: Both alpha and translation animations should execute simultaneously and complete after approximately 500ms.

Test 3: Animation Cancellation @test

File: animation-manager.test.ts

Test: Start an animation with 1000ms duration, then cancel it after 200ms. Verify the animation stops and cleanup occurs properly.

Expected: Animation should be canceled before completion, returning a canceled status rather than a completed status.

Install with Tessl CLI

npx tessl i tessl/npm-tns-platform-declarations

tile.json