-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathErrorScreen.swift
More file actions
67 lines (60 loc) · 2.63 KB
/
Copy pathErrorScreen.swift
File metadata and controls
67 lines (60 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import SwiftUI
/// Displays a full-screen error state with a title, description, and action button.
///
/// Colours, typography, and sizing are all resolved from the active
/// ``Auth0Theme``, so the screen matches any custom theme injected with
/// ``SwiftUI/View/auth0Theme(_:)``.
struct ErrorScreen: View {
@Environment(\.auth0Theme) private var theme
/// The view model providing error copy and button callbacks.
let viewModel: ErrorScreenViewModel
var body: some View {
ZStack(alignment: .topLeading) {
VStack {
Spacer()
VStack(spacing: theme.spacing.sm) {
Text(viewModel.title)
.multilineTextAlignment(.center)
.auth0TextStyle(theme.typography.displayMedium)
.foregroundStyle(theme.colors.text.bold)
Text(viewModel.subTitle)
.auth0TextStyle(theme.typography.label)
.onTapGesture {
viewModel.handleTextTap()
}
Button {
viewModel.handleButtonClick()
} label: {
Text(viewModel.buttonTitle)
.foregroundStyle(theme.colors.text.onPrimary)
.auth0TextStyle(theme.typography.label)
.frame(maxWidth: .infinity)
}
.frame(height: theme.sizes.buttonHeight)
.background(theme.colors.background.primary)
.cornerRadius(theme.radius.button)
.overlay(
RoundedRectangle(cornerRadius: theme.radius.button)
.stroke(theme.colors.background.primary, lineWidth: 2)
)
}
Spacer()
}.padding()
if viewModel.onDismiss != nil {
Button {
viewModel.handleDismiss()
} label: {
Image(systemName: "xmark")
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(theme.colors.text.bold)
.frame(width: 30, height: 30)
.background(theme.colors.background.layerTop)
.clipShape(Circle())
.shadow(color: Color.black.opacity(0.12), radius: 4, x: 0, y: 2)
}
.padding(theme.spacing.md)
}
}
.background(theme.colors.background.layerBase.ignoresSafeArea())
}
}