LoginRootView.swift 971 B

123456789101112131415161718192021222324252627282930
  1. import AuthenticationServices
  2. import SwiftUI
  3. extension Login {
  4. struct RootView: BaseView {
  5. @EnvironmentObject var viewModel: ViewModel<Provider>
  6. var body: some View {
  7. VStack {
  8. Text("FreeAPS").font(.largeTitle)
  9. Spacer()
  10. SignInWithAppleButton(.signIn) { request in
  11. request.requestedScopes = [.fullName, .email]
  12. }
  13. onCompletion: { result in
  14. switch result {
  15. case let .success(authorisation):
  16. viewModel.credentials = authorisation.credential as? ASAuthorizationAppleIDCredential
  17. case .failure:
  18. viewModel.credentials = nil
  19. }
  20. }
  21. .frame(width: 300, height: 50)
  22. .signInWithAppleButtonStyle(.whiteOutline)
  23. Spacer()
  24. }.padding()
  25. }
  26. }
  27. }