Skip to content

Commit

Permalink
chore: making feature configureable via config
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Nov 19, 2023
1 parent d44be0c commit 05e346b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
40 changes: 27 additions & 13 deletions Authorization/Authorization/Presentation/Login/SignInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import Core
import Swinject

public struct SignInView: View {

Expand All @@ -30,17 +31,20 @@ public struct SignInView: View {
.edgesIgnoringSafeArea(.top)
}.frame(maxWidth: .infinity, maxHeight: 200)

VStack {
Button(action: { viewModel.router.back() }, label: {
CoreAssets.arrowLeft.swiftUIImage.renderingMode(.template)
.backButtonStyle(color: .white)
})
.foregroundColor(Theme.Colors.styledButtonText)
.padding(.leading, isHorizontal ? 48 : 0)
.padding(.top, 11)

}.frame(maxWidth: .infinity, alignment: .topLeading)
.padding(.top, isHorizontal ? 20 : 0)
let config = Container.shared.resolve(Config.self)!
if config.startupScreenEnabled {
VStack {
Button(action: { viewModel.router.back() }, label: {
CoreAssets.arrowLeft.swiftUIImage.renderingMode(.template)
.backButtonStyle(color: .white)
})
.foregroundColor(Theme.Colors.styledButtonText)
.padding(.leading, isHorizontal ? 48 : 0)
.padding(.top, 11)

}.frame(maxWidth: .infinity, alignment: .topLeading)
.padding(.top, isHorizontal ? 20 : 0)
}

VStack(alignment: .center) {
CoreAssets.appLogo.swiftUIImage
Expand Down Expand Up @@ -95,12 +99,22 @@ public struct SignInView: View {
.stroke(lineWidth: 1)
.fill(Theme.Colors.textInputStroke)
)

HStack {
if !config.startupScreenEnabled {
Button(AuthLocalization.SignIn.registerBtn) {
viewModel.trackSignUpClicked()
viewModel.router.showRegisterScreen()
}.foregroundColor(Theme.Colors.accentColor)

Spacer()
}

Button(AuthLocalization.SignIn.forgotPassBtn) {
viewModel.trackForgotPasswordClicked()
viewModel.router.showForgotPasswordScreen()
}.foregroundColor(Theme.Colors.accentColor)
.padding(.top, 0)
.padding(.top, 0)
}

if viewModel.isShowProgress {
HStack(alignment: .center) {
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Configuration/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Config {
"itms-apps://itunes.apple.com/app/id\(appStoreId)?mt=8"
}
public let whatsNewEnabled: Bool = false
public let startupScreenEnabled: Bool = false

public init(baseURL: String, oAuthClientId: String) {
guard let url = URL(string: baseURL) else {
Expand Down
17 changes: 13 additions & 4 deletions OpenEdX/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ class RouteController: UIViewController {
}

private func showStartupScreen() {
let controller = UIHostingController(
rootView: StartupView(viewModel: diContainer.resolve(StartupViewModel.self)!))
navigation.viewControllers = [controller]
present(navigation, animated: false)
let config = Container.shared.resolve(Config.self)!
if config.startupScreenEnabled {
let controller = UIHostingController(
rootView: StartupView(viewModel: diContainer.resolve(StartupViewModel.self)!))
navigation.viewControllers = [controller]
present(navigation, animated: false)
} else {
let controller = UIHostingController(
rootView: SignInView(viewModel: diContainer.resolve(SignInViewModel.self)!)
)
navigation.viewControllers = [controller]
present(navigation, animated: false)
}
}

private func showMainOrWhatsNewScreen() {
Expand Down
14 changes: 10 additions & 4 deletions OpenEdX/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ public class Router: AuthorizationRouter,
}

public func showStartupScreen() {
let view = StartupView(viewModel: Container.shared.resolve(StartupViewModel.self)!)

let controller = UIHostingController(rootView: view)
navigationController.setViewControllers([controller], animated: true)
let config = Container.shared.resolve(Config.self)!
if config.startupScreenEnabled {
let view = StartupView(viewModel: Container.shared.resolve(StartupViewModel.self)!)
let controller = UIHostingController(rootView: view)
navigationController.setViewControllers([controller], animated: true)
} else {
let view = SignInView(viewModel: Container.shared.resolve(SignInViewModel.self)!)
let controller = UIHostingController(rootView: view)
navigationController.setViewControllers([controller], animated: false)
}
}

public func presentAlert(
Expand Down

0 comments on commit 05e346b

Please sign in to comment.