Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added login and register capability in discovery for pre login exploration #202

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public struct SignInView: View {
if !viewModel.config.features.startupScreenEnabled {
Button(AuthLocalization.SignIn.registerBtn) {
viewModel.trackSignUpClicked()
viewModel.router.showRegisterScreen()
viewModel.router.showRegisterScreen(sourceScreen: viewModel.sourceScreen)
}.foregroundColor(Theme.Colors.accentColor)

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class SignInViewModel: ObservableObject {
@Published private(set) var isShowProgress = false
@Published private(set) var showError: Bool = false
@Published private(set) var showAlert: Bool = false
public var sourceScreen: LogistrationSourceScreen = .default

var errorMessage: String? {
didSet {
withAnimation {
Expand Down Expand Up @@ -77,7 +79,7 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(username: username, password: password)
analytics.setUserID("\(user.id)")
analytics.userLogin(method: .password)
router.showMainOrWhatsNewScreen()
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
} catch let error {
failure(error)
}
Expand Down Expand Up @@ -108,7 +110,7 @@ public class SignInViewModel: ObservableObject {
let user = try await interactor.login(externalToken: externalToken, backend: backend)
analytics.setUserID("\(user.id)")
analytics.userLogin(method: authMethod)
router.showMainOrWhatsNewScreen()
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
} catch let error {
failure(error, authMethod: authMethod)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class SignUpViewModel: ObservableObject {
@Published var scrollTo: Int?
@Published var showError: Bool = false
@Published var thirdPartyAuthSuccess: Bool = false
public var sourceScreen: LogistrationSourceScreen = .default

var errorMessage: String? {
didSet {
withAnimation {
Expand Down Expand Up @@ -114,7 +116,7 @@ public class SignUpViewModel: ObservableObject {
analytics.setUserID("\(user.id)")
analytics.registrationSuccess()
isShowProgress = false
router.showMainOrWhatsNewScreen()
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)

} catch let error {
isShowProgress = false
Expand Down Expand Up @@ -171,7 +173,7 @@ public class SignUpViewModel: ObservableObject {
analytics.setUserID("\(user.id)")
analytics.userLogin(method: authMethod)
isShowProgress = false
router.showMainOrWhatsNewScreen()
router.showMainOrWhatsNewScreen(sourceScreen: sourceScreen)
} catch {
update(fullName: response.name, email: response.email)
self.externalToken = response.token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ import Theme
public struct LogistrationBottomView: View {
@ObservedObject
private var viewModel: StartupViewModel
private var sourceScreen: LogistrationSourceScreen

@Environment(\.isHorizontal) private var isHorizontal

public init(viewModel: StartupViewModel) {
public init(viewModel: StartupViewModel, sourceScreen: LogistrationSourceScreen) {
self.viewModel = viewModel
self.sourceScreen = sourceScreen
}

public var body: some View {
VStack(alignment: .leading) {
HStack(spacing: 24) {
StyledButton(AuthLocalization.SignIn.registerBtn) {
viewModel.router.showRegisterScreen()
viewModel.router.showRegisterScreen(sourceScreen: sourceScreen)
viewModel.tracksignUpClicked()
}
.frame(maxWidth: .infinity)

StyledButton(
AuthLocalization.SignIn.logInTitle,
action: { viewModel.router.showLoginScreen() },
action: { viewModel.router.showLoginScreen(sourceScreen: sourceScreen) },
color: .white,
textColor: Theme.Colors.accentColor,
borderColor: Theme.Colors.textInputStroke
Expand All @@ -52,12 +54,12 @@ struct LogistrationBottomView_Previews: PreviewProvider {
router: AuthorizationRouterMock(),
analytics: AuthorizationAnalyticsMock()
)
LogistrationBottomView(viewModel: vm)
LogistrationBottomView(viewModel: vm, sourceScreen: .startup)
.preferredColorScheme(.light)
.previewDisplayName("StartupView Light")
.loadFonts()

LogistrationBottomView(viewModel: vm)
LogistrationBottomView(viewModel: vm, sourceScreen: .startup)
.preferredColorScheme(.dark)
.previewDisplayName("StartupView Dark")
.loadFonts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public struct StartupView: View {
.padding(.top, 1)
TextField(AuthLocalization.Startup.searchPlaceholder, text: $searchQuery, onCommit: {
if searchQuery.isEmpty { return }
viewModel.router.showDiscoveryScreen(searchQuery: searchQuery, fromStartupScreen: true)
viewModel.router.showDiscoveryScreen(
searchQuery: searchQuery,
sourceScreen: LogistrationSourceScreen.startup
)
})
.autocapitalization(.none)
.autocorrectionDisabled()
Expand All @@ -71,7 +74,10 @@ public struct StartupView: View {
)

Button {
viewModel.router.showDiscoveryScreen(searchQuery: searchQuery, fromStartupScreen: true)
viewModel.router.showDiscoveryScreen (
searchQuery: searchQuery,
sourceScreen: LogistrationSourceScreen.startup
)
} label: {
Text(AuthLocalization.Startup.exploreAllCourses)
.underline()
Expand All @@ -83,7 +89,7 @@ public struct StartupView: View {
}
.padding(.horizontal, isHorizontal ? 10 : 24)

LogistrationBottomView(viewModel: viewModel)
LogistrationBottomView(viewModel: viewModel, sourceScreen: .startup)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In various locations, we utilize LogistrationSourceScreen.startup, while here it employs .startup. It is necessary to ensure uniformity.

}
.padding(.top, 10)
.padding(.bottom, 2)
Expand Down
Loading
Loading