Consider tests for animations (#1779)

This commit is contained in:
Alfonso Grillo
2023-09-21 17:49:38 +02:00
committed by GitHub
parent 37afc8c253
commit bc1910e9bb
8 changed files with 30 additions and 12 deletions
@@ -102,7 +102,7 @@ struct ComposerToolbar: View {
.padding(4)
}
.disabled(context.viewState.sendButtonDisabled)
.animation(.linear(duration: 0.1), value: context.viewState.sendButtonDisabled)
.animation(.linear(duration: 0.1).disabledDuringTests(), value: context.viewState.sendButtonDisabled)
.keyboardShortcut(.return, modifiers: [.command])
}
@@ -167,7 +167,7 @@ struct HomeScreenRoomCellButtonStyle: ButtonStyle {
configuration.label
.background(isSelected ? Color.compound.bgSubtleSecondary : Color.compound.bgCanvasDefault)
.contentShape(Rectangle())
.animation(isSelected ? .none : .easeOut(duration: 0.1), value: isSelected)
.animation(isSelected ? .none : .easeOut(duration: 0.1).disabledDuringTests(), value: isSelected)
}
}
@@ -106,7 +106,7 @@ struct InviteUsersScreen: View {
}
.onChange(of: context.viewState.scrollToLastID) { lastAddedID in
guard let id = lastAddedID else { return }
withAnimation(.easeInOut) {
withElementAnimation(.easeInOut) {
scrollView.scrollTo(id)
}
}
@@ -31,7 +31,7 @@ struct LongPressWithFeedback: ViewModifier {
.shadow(color: .black.opacity(isLongPressing ? 0.1 : 0.0), radius: isLongPressing ? 3 : 0)
.scaleEffect(x: isLongPressing ? 1.05 : 1,
y: isLongPressing ? 1.05 : 1)
.animation(isLongPressing ? .spring(response: 0.5).delay(0.1) : .spring(response: 0.5),
.animation(.spring(response: 0.5).delay(isLongPressing ? 0.1 : 0).disabledDuringTests(),
value: isLongPressing)
// The minimum duration here doesn't actually invoke the perform block when elapsed (thus
// the implementation below) but it does cancel other system gestures e.g. swipe to reply
@@ -61,7 +61,7 @@ struct TimelineReactionsView: View {
.reactionLayoutItem(.addMore)
}
.environment(\.layoutDirection, reactionsLayoutDirection)
.animation(.easeInOut(duration: 0.1), value: reactions)
.animation(.easeInOut(duration: 0.1).disabledDuringTests(), value: reactions)
.padding(.leading, 4)
}
}