Source code for the WriteFreely SwiftUI app for iOS, iPadOS, and macOS
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

41 行
1.1 KiB

  1. import SwiftUI
  2. struct AccountView: View {
  3. @EnvironmentObject var model: WriteFreelyModel
  4. @EnvironmentObject var errorHandling: ErrorHandling
  5. var body: some View {
  6. if model.account.isLoggedIn {
  7. HStack {
  8. Spacer()
  9. AccountLogoutView()
  10. .withErrorHandling()
  11. Spacer()
  12. }
  13. .padding()
  14. } else {
  15. AccountLoginView()
  16. .withErrorHandling()
  17. .padding(.top)
  18. }
  19. EmptyView()
  20. .onChange(of: model.hasError) { value in
  21. if value {
  22. if let error = model.currentError {
  23. self.errorHandling.handle(error: error)
  24. } else {
  25. self.errorHandling.handle(error: AppError.genericError())
  26. }
  27. model.hasError = false
  28. }
  29. }
  30. }
  31. }
  32. struct AccountLogin_Previews: PreviewProvider {
  33. static var previews: some View {
  34. AccountView()
  35. .environmentObject(WriteFreelyModel())
  36. }
  37. }