mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix UI Tests for OnboardingScreen, BugReportScreen, ServerSelectionScreen, and UserSessionFlows. (#549)
* Fix OnboardingScreen UI Tests Disable the swipe tests for now as there is only a single page. * Fix BugReportScreen UI Tests. Use snapshots more and remove manual validation method. * Fix ServerSelectionScreen UI Tests. * Fix SessionVerificationScreen UI Tests. * Fix UserSessionFlows UI Tests
This commit is contained in:
@@ -34,31 +34,10 @@ enum OnboardingViewModelAction {
|
||||
}
|
||||
|
||||
struct OnboardingViewState: BindableState {
|
||||
/// The colours of the background gradient shown behind the 4 pages.
|
||||
private let gradientColors = [
|
||||
Color(red: 0.95, green: 0.98, blue: 0.96),
|
||||
Color(red: 0.89, green: 0.96, blue: 0.97),
|
||||
Color(red: 0.95, green: 0.89, blue: 0.97),
|
||||
Color(red: 0.81, green: 0.95, blue: 0.91),
|
||||
Color(red: 0.95, green: 0.98, blue: 0.96)
|
||||
]
|
||||
|
||||
/// An array containing all content of the carousel pages
|
||||
let content: [OnboardingPageContent]
|
||||
var bindings: OnboardingBindings
|
||||
|
||||
/// The background gradient for all 4 pages and the hidden page at the start of the carousel.
|
||||
var backgroundGradient: Gradient {
|
||||
if Tests.isRunningUITests {
|
||||
return Gradient(colors: [.white])
|
||||
}
|
||||
// Include the extra stop for the hidden page at the start of the carousel.
|
||||
// (The last color is the right-hand stop, but we need the left-hand stop,
|
||||
// so take the last but one color from the array).
|
||||
let hiddenPageColor = gradientColors[gradientColors.count - 2]
|
||||
return Gradient(colors: [hiddenPageColor] + gradientColors)
|
||||
}
|
||||
|
||||
init() {
|
||||
content = [
|
||||
OnboardingPageContent(title: ElementL10n.ftueAuthCarouselWelcomeTitle.tinting(".", color: .element.accent),
|
||||
|
||||
@@ -21,6 +21,8 @@ import SwiftUI
|
||||
struct OnboardingBackgroundView: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
var isAnimated = true
|
||||
|
||||
@State private var factor = 0.0
|
||||
@State private var isReversed = false
|
||||
|
||||
@@ -39,6 +41,8 @@ struct OnboardingBackgroundView: View {
|
||||
}
|
||||
.frame(width: geometry.size.width, height: geometry.size.height)
|
||||
.onReceive(timer) { _ in
|
||||
guard isAnimated else { return }
|
||||
|
||||
if isReversed {
|
||||
guard factor > 0 else {
|
||||
isReversed = false
|
||||
|
||||
@@ -19,7 +19,6 @@ import SwiftUI
|
||||
|
||||
/// The screen shown at the beginning of the onboarding flow.
|
||||
struct OnboardingScreen: View {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
@Environment(\.layoutDirection) private var layoutDirection
|
||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||
|
||||
@@ -35,7 +34,8 @@ struct OnboardingScreen: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
OnboardingBackgroundView()
|
||||
OnboardingBackgroundView(isAnimated: !Tests.isRunningUITests)
|
||||
|
||||
GeometryReader { geometry in
|
||||
ZStack {
|
||||
VStack(alignment: .leading) {
|
||||
@@ -99,19 +99,6 @@ struct OnboardingScreen: View {
|
||||
.readableFrame()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
/// The view's background, showing a gradient in light mode and a solid colour in dark mode.
|
||||
var background: some View {
|
||||
if colorScheme == .light {
|
||||
LinearGradient(gradient: context.viewState.backgroundGradient,
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing)
|
||||
.flipsForRightToLeftLayoutDirection(true)
|
||||
} else {
|
||||
Color.element.background
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Animation
|
||||
|
||||
/// Starts the animation timer for an automatic carousel effect.
|
||||
|
||||
Reference in New Issue
Block a user