Skip to content

Commit

Permalink
Remove anonymous login
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-amisha-i committed Jun 20, 2024
1 parent 447313e commit a075834
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Splito/UI/Onboard/OnboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ struct OnboardView: View {
GeometryReader { proxy in
TabView(selection: $viewModel.currentPageIndex) {
ForEach(0..<onboardItems.count, id: \.self) { index in
OnboardPageView(index: index, items: onboardItems, proxy: proxy, showLoader: viewModel.showLoader, onStartBtnTap: viewModel.loginAnonymous)
OnboardPageView(index: index, items: onboardItems, proxy: proxy,
onStartBtnTap: viewModel.handleGetStartedAction)
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
Expand Down Expand Up @@ -63,7 +64,6 @@ struct OnboardPageView: View {
var index: Int
var items: [OnboardItem]
let proxy: GeometryProxy
var showLoader: Bool

var onStartBtnTap: (() -> Void)

Expand Down Expand Up @@ -93,7 +93,7 @@ struct OnboardPageView: View {

VSpacer(70)

PrimaryButton(text: "Get Started", showLoader: showLoader) {
PrimaryButton(text: "Get Started") {
onStartBtnTap()
}
.opacity(index == (items.count - 1) ? 1 : 0)
Expand Down
23 changes: 3 additions & 20 deletions Splito/UI/Onboard/OnboardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

import Data
import BaseStyle
import FirebaseAuth
import Foundation

class OnboardViewModel: BaseViewModel, ObservableObject {

@Published var currentPageIndex = 0
@Published private(set) var showLoader = false

@Inject private var preference: SplitoPreference

Expand All @@ -23,23 +21,8 @@ class OnboardViewModel: BaseViewModel, ObservableObject {
self.router = router
}

func loginAnonymous() {
showLoader = true
FirebaseProvider.auth.signInAnonymously { [weak self] result, error in
guard let self = self else { return }
if error != nil {
self.showLoader = false
self.alert = .init(message: "Server error")
self.showAlert = true
} else if let result {
self.preference.isOnboardShown = result.user.isAnonymous
self.showLoader = false
router.updateRoot(root: .LoginView)
} else {
self.alert = .init(message: "Contact Support")
self.showLoader = false
self.showAlert = true
}
}
func handleGetStartedAction() {
preference.isOnboardShown = true
router.updateRoot(root: .LoginView)
}
}

0 comments on commit a075834

Please sign in to comment.