From 2e8b65d8282c269b737c2dad5400ba80b11d3ba8 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 11:45:54 +0100 Subject: [PATCH] Added the "logOut" closure to the initialiser of the ProfileView view. --- BeReal/ContentView.swift | 2 +- Modules/Sources/Profile/UI/Views/ProfileView.swift | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/BeReal/ContentView.swift b/BeReal/ContentView.swift index ae915c9..12650bb 100644 --- a/BeReal/ContentView.swift +++ b/BeReal/ContentView.swift @@ -17,7 +17,7 @@ struct ContentView: View { BrowseView() } .sheet(isPresented: .constant(true)) { - ProfileView() + ProfileView {} } } } diff --git a/Modules/Sources/Profile/UI/Views/ProfileView.swift b/Modules/Sources/Profile/UI/Views/ProfileView.swift index 3539b30..3794647 100644 --- a/Modules/Sources/Profile/UI/Views/ProfileView.swift +++ b/Modules/Sources/Profile/UI/Views/ProfileView.swift @@ -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. + } } }