Added the "logOut" closure to the initialiser of the ProfileView view.

This commit is contained in:
Javier Cicchelli 2022-12-03 11:45:54 +01:00
parent 330d790394
commit 2e8b65d828
2 changed files with 12 additions and 4 deletions

View File

@ -17,7 +17,7 @@ struct ContentView: View {
BrowseView()
}
.sheet(isPresented: .constant(true)) {
ProfileView()
ProfileView {}
}
}
}

View File

@ -10,9 +10,15 @@ import SwiftUI
public struct ProfileView: View {
// MARK: Properties
private let logOut: () -> Void
// MARK: Initialisers
public init() {}
public init(logOut: @escaping () -> Void) {
self.logOut = logOut
}
// MARK: Body
@ -111,7 +117,7 @@ public struct ProfileView: View {
Section {
Button {
// TODO: Log out the existing user.
logOut()
} label: {
Text(
"profile.button.log_out.text",
@ -143,6 +149,8 @@ private extension Image {
struct ProfileView_Previews: PreviewProvider {
static var previews: some View {
ProfileView()
ProfileView {
// closure for log out action.
}
}
}