surfstudio / ReactiveDataDisplayManager

MIT License
34 stars 13 forks source link

Modifier `.none` animation ambiguity #236

Closed dmitryd20 closed 11 months ago

dmitryd20 commented 1 year ago

Modifier protocol has various methods with optional Animation parameters. In its implementations Animation becomes either UITableView.RowAnimation or CollectionItemAnimation.

The problem appears when using UITableView modifiers with animation parameter .none. .none can be treated both as Optional.none and UITableView.RowAnimation.none. Following IDE warning:

Снимок экрана 2023-06-20 в 16 21 03

Even without ambiguity – it is not clear what should users choose if they need no animation - nil or .none.

Since UITableView.RowAnimation already has .none case, is it possible to make animation parameter non-optional? In UIColectionView modifiers it can still be optional.

NullIsOne commented 1 year ago

When we made animation parameter optional we solved an issue when you really need to disable all animations. We found that UITableView.RowAnimation.none is still animated change. So we added optional to resolve this issue. And also we added UIView.performWithoutAnimation to completely disable any animations inside performBatchUpdates call.

To resolve ambiguity you can simply use nil instead of none or concrete UITableView.RowAnimation.none if you need potentially animated change.

Ikeret commented 1 year ago

It's better to use enum for animation parameter:

enum AnimateOption {
    case animated(UITableView.RowAnimation)
    case none // without animation
}
NullIsOne commented 1 year ago

Such change is achievable only in 8.0, because its not backward compatible. We will think about it.