Skip to main content

Loading indicator

SecureLoadingView and .secureLoadingOverlay are optional library components that display an animated loading indicator during payment processing. When bound to ComgateSecureSession, the overlay shows and hides automatically based on payment state.

Tip

The component is optional — the payment proceeds correctly without it. Its sole purpose is visual feedback for the user.

Structure

The library offers two loading-indicator variants:

  • SecureLoadingView — an inline view you can place anywhere in the SwiftUI hierarchy (e.g. centered on the screen).
  • .secureLoadingOverlay(...) — a view modifier that shows the indicator as a floating panel above the entire screen with a dimmed background.

The indicator consists of two visual elements:

  • Animated spinner — a circular spinner with a smoothly rotating arc above a static track
  • Text label — optional text below the spinner; the default is automatically derived from the session language

SecureLoadingView

Inline indicator for custom placement:

import SwiftUI
import ComgateSDK

VStack {
Spacer()
SecureLoadingView(text: "Processing payment…")
Spacer()
}

Initializer

public init(text: String? = nil, style: LoadingStyle = .indicator)
ParameterTypeDescription
textString?Optional text below the spinner. nil hides the label.
styleLoadingStyleStyle struct. Default: .indicator.

SecureLoadingOverlay (modifier)

SecureLoadingOverlay is a view modifier you apply to a parent view to show a floating indicator over it. The library provides two variants:

Manual control

struct ContentView: View {
@State private var isLoading = false

var body: some View {
ZStack { /* ... */ }
.secureLoadingOverlay(
isVisible: isLoading,
text: "Processing payment…"
)
}
}
ParameterTypeDescription
isVisibleBoolShows/hides the overlay.
textString?Optional text.
styleLoadingStyleStyle struct. Default: .overlay.

Automatic session binding

Recommended variant — the overlay shows and hides automatically based on session.isProcessingPayment:

struct ContentView: View {
@ObservedObject var session: ComgateSecureSession

var body: some View {
ZStack { /* ... */ }
.secureLoadingOverlay(session: session)
}
}
ParameterTypeDescription
sessionComgateSecureSessionSession whose isProcessingPayment the overlay observes.
textString?Optional text. When nil, session.translation.loadingProcessingText is used.
styleLoadingStyleStyle struct. Default: .overlay.
isLoadingEnabledBoolWhen false, the overlay does not appear even during processing. Default: true.

With the auto-bound variant, the overlay appears as soon as payment processing starts (session.processPayment(...) or session.processApplePayPayment(...)) and hides once a terminal result arrives.

Information

To temporarily disable the automatic behavior, pass isLoadingEnabled: false. Manual display via secureLoadingOverlay(isVisible:) remains independent.

LoadingStyle

Styling is done with the LoadingStyle struct.

Properties

PropertyTypeDefaultDescription
spinnerColorColor#4287F5Color of the rotating arc.
trackColorColor#E0E0E0Color of the static spinner track.
strokeWidthCGFloat4Stroke width of the arc and track in points.
spinnerSizeCGFloat48Spinner diameter in points.
textColorColor#666666Label text color.
textSizeCGFloat14Label text size in points.
textGapCGFloat8Gap between the spinner and the label in points.
textFontNameString?nilCustom font name.
backgroundColorColor.whiteBackground color of the card (overlay panel).
cornerRadiusCGFloat12Card corner radius in points.
paddingHorizontalCGFloat16Card horizontal padding.
paddingVerticalCGFloat20Card vertical padding.
dimAmountCGFloat0.0Opacity of the dim layer (0–1).

Presets

PresetDescription
LoadingStyle.indicatorFor inline use (SecureLoadingView). Default.
LoadingStyle.overlayFor the overlay variant. Larger padding, corner radius 16.

Example

let style = LoadingStyle(
spinnerColor: Color(red: 0.10, green: 0.47, blue: 0.91),
trackColor: Color(red: 0.85, green: 0.92, blue: 1.00),
strokeWidth: 4,
spinnerSize: 52,
backgroundColor: .white,
cornerRadius: 16,
paddingHorizontal: 28,
paddingVertical: 28,
dimAmount: 0.5
)

ContentView()
.secureLoadingOverlay(session: session, style: style)

Label translation

The default text below the spinner in the auto-bound variant is automatically derived from the chosen session language via Translation.loadingProcessingText. To set custom text, pass the text parameter:

ContentView()
.secureLoadingOverlay(
session: session,
text: "Processing your payment, please wait…"
)