openedx / openedx/openedx-app-ios

[iOS] Remove `withAnimation` blocks from view models

Open
#277 1 comment 0 reactions 1 assignee View on GitHub

@forgotvas is already working on this.

Since Mar 12, 2024.

code health
Dominant language
Swift
Stars
31
Forks
32
PR merge metrics
No merged PRs in 30d

Description

(not a priority for now)
it's bad practice to use withAnimation block inside view model, better to use animation modifier in that case, something like .animation(.default, value: showError)

Originally posted by @forgotvas in https://github.com/openedx/openedx-app-ios/pull/276#discussion_r1479652718

In SwiftUI, it is generally recommended to keep the view model separate from the animation logic. The view model’s primary responsibility is to manage the state and business logic of your application, while the animation logic is typically handled within the views themselves.
Instead of using withAnimation inside the view model, a common approach is to expose properties in the view model that represent the state to be animated.
Need to remove withAnimation blocks from view models. All animations should be described inside view.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.