Skip to content

Commit

Permalink
feat: Demo app waits for experience
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziodemaria committed Nov 29, 2024
1 parent e15eeff commit ce4734b
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions ConfidenceDemoApp/ConfidenceDemoApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,46 @@ struct ContentView: View {
@EnvironmentObject var status: ExperimentationFlags
@AppStorage("loggedUser") private var loggedUser: String?

Check failure on line 7 in ConfidenceDemoApp/ConfidenceDemoApp/ContentView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Attributes Violation: Attributes with arguments or inside always_on_line_above must be on a new line instead of the same line (attributes)
@State var isLoggingOut: Bool = false
@State var loggedOut: Bool = false

private let color: Color
private let confidence: Confidence

init(confidence: Confidence) {
self.confidence = confidence
self.color = ContentView.getColor(color: confidence.getValue(key: "swift-demoapp.color", defaultValue: "Gray"))
}

var body: some View {
NavigationStack {
VStack {
Text("Hello World!")
.foregroundStyle(color)
}
.padding()
Button("Logout") {
loggedUser = nil
status.state = .loading
Task {
await confidence.removeContext(key: "user_id")
status.state = .ready
if (status.state == .loading && !isLoggingOut) {

Check failure on line 19 in ConfidenceDemoApp/ConfidenceDemoApp/ContentView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
VStack {
Spacer()
Text("Welcome \(loggedUser ?? "?")")
Text("We are preparing your experience...")
ProgressView()
Spacer()
}
} else {
VStack {
Text("Hello World!")
.font(.largeTitle)
.foregroundStyle(ContentView.getColor(color: confidence.getValue(key: "swift-demoapp.color", defaultValue: "Gray")))

Check failure on line 31 in ConfidenceDemoApp/ConfidenceDemoApp/ContentView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Line Length Violation: Line should be 120 characters or less; currently it has 140 characters (line_length)
}
.padding()
Button("Logout") {
isLoggingOut = true

loggedUser = nil
status.state = .loading
Task {
await confidence.removeContext(key: "user_id")
status.state = .ready
}
loggedUser = nil
loggedOut = true
}
.navigationDestination(isPresented: $loggedOut) {
LoginView(confidence: confidence)
}
loggedUser = nil
isLoggingOut = true
}
.navigationDestination(isPresented: $isLoggingOut) {
LoginView(confidence: confidence)
}
}
}
Expand Down

0 comments on commit ce4734b

Please sign in to comment.