【发布时间】:2020-10-05 04:30:57
【问题描述】:
我正在尝试在我的列表视图中设置一个按钮,以允许用户从设备上退出其帐户。我关注了有关设置登录和注销的视频,我对这些很有信心,但我不确定自己做错了什么。
这是我的代码:
struct SettingsAccountView: View {
@EnvironmentObject var session: SessionStore
func getUser() {
session.listen()
}
var body: some View {
List {
Section {
Button(action: {
print("Change USER email")
}) {
SettingsCell(title: "Change Email", imgName: "envelope.fill", clr: Color("Waterfall"))
}
Button(action: {
print("Change USER password")
}) {
SettingsCell(title: "Change Password", imgName: "eye.slash.fill", clr: Color("Waterfall"))
}
Button(action: {
print("Change USER Photo")
}) {
SettingsCell(title: "Change Profile Photo", imgName: "camera.rotate", clr: Color("Waterfall"))
}
}
Section {
Button(action: session.signOut) {
print("SignOut")
}) {
SettingsCell(title: "Sign Out", imgName: "person.crop.circle.badge.xmark", clr: .red)
}
Button(action: {
print("Delete MY Account")
}) {
SettingsCell(title: "Delete My Account", imgName: "trash.circle", clr: .red)
}
}
}.listStyle(GroupedListStyle())
.environment(\.horizontalSizeClass, .regular)
.navigationBarTitle("Account", displayMode: .inline)
}
}
struct SettingsAccountView_Previews: PreviewProvider {
static var previews: some View {
SettingsAccountView()
}
}
【问题讨论】:
标签: swift firebase firebase-authentication swiftui swiftui-list