Skip to content
Permalink
Browse files Browse the repository at this point in the history
chore: release 1.1.0
  • Loading branch information
ndcg91 committed Oct 30, 2020
2 parents 140b877 + 3b65793 commit 2d1505d
Show file tree
Hide file tree
Showing 169 changed files with 5,359 additions and 1,989 deletions.
451 changes: 363 additions & 88 deletions RadarCovid.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
45 changes: 39 additions & 6 deletions RadarCovid/Application/AppDelegate.swift
Expand Up @@ -10,6 +10,7 @@
//
import UIKit
import Logging

@UIApplicationMain

Expand All @@ -18,28 +19,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

var injection: Injection = Injection()

private let logger = Logger(label: "AppDelegate")

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if JailBreakDetect.isJailbroken() {
exit(-1)
}

if Config.debug {
NetworkActivityLogger.shared.startLogging()
setupLog()
}

debugPrint("Current Environment: \(Config.environment)")
logger.info("Current Environment: \(Config.environment)")

let setupUseCase = injection.resolve(SetupUseCase.self)!

do {
try setupUseCase.initializeSDK()
} catch {
debugPrint("Error initializing DP3T \(error)")
logger.error("Error initializing DP3T \(error)")
}
UIApplication.shared.applicationIconBadgeNumber = 0

return true
}

func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsDirectory = paths[0]
return documentsDirectory
}

// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
Expand All @@ -58,4 +65,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return UIApplication.shared.delegate as? AppDelegate
}

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
}

private func setupLog() {
NetworkActivityLogger.shared.startLogging()

do {
let logFileURL = getDocumentsDirectory().appendingPathComponent("radarcovid.log")
let fileLogger = try FileLogging(to: logFileURL)

LoggingSystem.bootstrap { label in
var fileHandler = FileLogHandler(label: label, fileLogger: fileLogger)
fileHandler.logLevel = .debug
var stdHandler = StreamLogHandler.standardOutput(label: label)
stdHandler.logLevel = .debug
let handlers:[LogHandler] = [
fileHandler,
stdHandler
]
return MultiplexLogHandler(handlers)
}

} catch {
debugPrint("Error initializing log \(error)")
}
}
}
65 changes: 44 additions & 21 deletions RadarCovid/Application/AppRouter.swift
Expand Up @@ -28,31 +28,20 @@ public enum Routes {
case onBoarding
case home
case proximity
case myHealth
case myHealthStep0
case myHealthStep1
case myHealthStep2
case myHealthReported
case exposition
case highExposition
case positiveExposed
case activateCovid
case activatePush
case changeLanguage
}

class AppRouter: Router {

var proxymityVC: ProximityViewController?
var onBoardingVC: OnBoardingViewController?
var rootVC: RootViewController?
var tabBarController: TabBarController?
var myHealthVC: MyHealthViewController?
var myHealthReportedVC: MyHealthReportedViewController?
var expositionVC: ExpositionViewController?
var highExpositionVC: HighExpositionViewController?
var positiveExposedVC: PositiveExposedViewController?
var welcomeVC: WelcomeViewController?
var activateCovid: ActivateCovidNotificationViewController?
var activatePush: ActivatePushNotificationViewController?
var homeVC: HomeViewController?

var parentVC: UIViewController?

func route(to routeID: Routes, from context: UIViewController, parameters: Any?...) {
Expand All @@ -72,8 +61,12 @@ class AppRouter: Router {
routeToCovid(context)
case .activatePush:
routeToPush(context)
case .myHealth:
routeToMyHealth(context)
case .myHealthStep0:
routeToMyHealthStep0(context)
case .myHealthStep1:
routeToMyHealthStep1(context)
case .myHealthStep2:
routeToMyHealthStep2(context, codeString: parameters[0] as? String ?? "", dateNotificationPositive: parameters[1] as? Date)
case .myHealthReported:
routeToMyHealthReported(context)
case .exposition:
Expand All @@ -82,58 +75,89 @@ class AppRouter: Router {
routeToHighExposition(context, since: parameters[0] as? Date)
case .positiveExposed:
routeToPositiveExposed(context, since: parameters[0] as? Date)
case .changeLanguage:
routeToRootAndResetView(context)
}
}

private func routeToOnboarding(_ context: UIViewController) {
let onBoardingVC = AppDelegate.shared?.injection.resolve(OnBoardingViewController.self)!
context.navigationController?.pushViewController(onBoardingVC!, animated: true)
}

private func routeToRoot(_ context: UIViewController) {
let rootVC = AppDelegate.shared?.injection.resolve(RootViewController.self)!
loadViewAsRoot(navController: context as? UINavigationController, view: rootVC!)
}

private func routeToRootAndResetView(_ context: UIViewController) {
let rootVC = AppDelegate.shared?.injection.resolve(RootViewController.self)!
loadViewAsRoot(navController: context.navigationController, view: rootVC!)
}

private func routeToHome(_ context: UIViewController) {
let tabBarController = AppDelegate.shared?.injection.resolve(TabBarController.self)!
loadViewAsRoot(navController: context.navigationController, view: tabBarController!)
}

private func routeToProximity(_ context: UIViewController) {
let proxymityVC = AppDelegate.shared?.injection.resolve(ProximityViewController.self)!
context.navigationController?.pushViewController(proxymityVC!, animated: true)
}

private func routeToCovid(_ context: UIViewController) {
let activateCovid = AppDelegate.shared?.injection.resolve(ActivateCovidNotificationViewController.self)!
context.navigationController?.pushViewController(activateCovid!, animated: true)
}

private func routeToPush(_ context: UIViewController) {
let activatePush = AppDelegate.shared?.injection.resolve(ActivatePushNotificationViewController.self)!
context.navigationController?.pushViewController(activatePush!, animated: true)
}

private func routeToMyHealth(_ context: UIViewController) {
context.navigationController?.pushViewController(myHealthVC!, animated: true)
private func routeToMyHealthStep0(_ context: UIViewController) {
let myHealthStep0VC = AppDelegate.shared?.injection.resolve(MyHealthStep0ViewController.self)!
context.navigationController?.pushViewController(myHealthStep0VC!, animated: true)
}

private func routeToMyHealthStep1(_ context: UIViewController) {
let myHealthStep1VC = AppDelegate.shared?.injection.resolve(MyHealthStep1ViewController.self)!
context.navigationController?.pushViewController(myHealthStep1VC!, animated: true)
}

private func routeToMyHealthStep2(_ context: UIViewController, codeString: String, dateNotificationPositive: Date?) {
let myHealthStep2VC = AppDelegate.shared?.injection.resolve(MyHealthStep2ViewController.self)!
myHealthStep2VC?.codeString = codeString
myHealthStep2VC?.dateNotificationPositive = dateNotificationPositive
context.navigationController?.pushViewController(myHealthStep2VC!, animated: true)
}

private func routeToMyHealthReported(_ context: UIViewController) {
let myHealthReportedVC = AppDelegate.shared?.injection.resolve(MyHealthReportedViewController.self)!
context.navigationController?.pushViewController(myHealthReportedVC!, animated: true)
}

private func routeToExposition(_ context: UIViewController, lastCheck: Date?) {
let expositionVC = AppDelegate.shared?.injection.resolve(ExpositionViewController.self)!
expositionVC?.lastCheck = lastCheck
context.navigationController?.pushViewController(expositionVC!, animated: true)
}

private func routeToHighExposition(_ context: UIViewController, since: Date?) {
let highExpositionVC = AppDelegate.shared?.injection.resolve(HighExpositionViewController.self)!
highExpositionVC?.since = since
context.navigationController?.pushViewController(highExpositionVC!, animated: true)
}

private func routeToPositiveExposed(_ context: UIViewController, since: Date?) {
let positiveExposedVC = AppDelegate.shared?.injection.resolve(PositiveExposedViewController.self)!
positiveExposedVC?.since = since
context.navigationController?.pushViewController(positiveExposedVC!, animated: true)
}

private func routeToWelcome(_ context: UIViewController) {
loadViewAsRoot(navController: context.navigationController, view: welcomeVC!)
let welcomeVC = AppDelegate.shared!.injection.resolve(WelcomeViewController.self)!
loadViewAsRoot(navController: context.navigationController, view: welcomeVC)
}

private func loadViewAsRoot(navController: UINavigationController?, view: UIViewController, animated: Bool = false) {
Expand All @@ -144,7 +168,6 @@ class AppRouter: Router {

func popToRoot(from: UIViewController, animated: Bool) {
from.navigationController?.popToRootViewController(animated: animated)
homeVC?.viewWillAppear(animated)
parentVC = nil
}

Expand Down
71 changes: 46 additions & 25 deletions RadarCovid/Application/Injection.swift
Expand Up @@ -71,6 +71,10 @@ class Injection {
UserDefaultsPreferencesRepository()
}.inObjectScope(.container)

container.register(TermsAcceptedRepository.self) { _ in
TermsAcceptedRepository()
}.inObjectScope(.container)

container.register(SettingsRepository.self) { _ in
UserDefaultsSettingsRepository()
}.inObjectScope(.container)
Expand Down Expand Up @@ -101,8 +105,7 @@ class Injection {

container.register(ExpositionUseCase.self) { r in
ExpositionUseCase(notificationHandler: r.resolve(NotificationHandler.self)!,
expositionInfoRepository: r.resolve(ExpositionInfoRepository.self)!,
localizationUseCase: r.resolve(LocalizationUseCase.self)!)
expositionInfoRepository: r.resolve(ExpositionInfoRepository.self)!)
}.inObjectScope(.container)

container.register(RadarStatusUseCase.self) { r in
Expand Down Expand Up @@ -169,30 +172,18 @@ class Injection {

container.register(TabBarController.self) { r in
TabBarController(
localizationUseCase: r.resolve(LocalizationUseCase.self)!,
homeViewController: r.resolve(HomeViewController.self)!,
myDataViewController: r.resolve(MyDataViewController.self)!,
helpLineViewController: r.resolve(HelpLineViewController.self)!,
preferencesRepository: r.resolve(PreferencesRepository.self)!
settingViewController: r.resolve(SettingViewController.self)!,
preferencesRepository: r.resolve(PreferencesRepository.self)!,
localizationUseCase: r.resolve(LocalizationUseCase.self)!
)
}

container.register(AppRouter.self) { _ in
AppRouter()
}.initCompleted {r, appRouter in
appRouter.rootVC = r.resolve(RootViewController.self)!
appRouter.proxymityVC = r.resolve(ProximityViewController.self)!
appRouter.onBoardingVC = r.resolve(OnBoardingViewController.self)!
appRouter.tabBarController = r.resolve(TabBarController.self)!
appRouter.myHealthVC = r.resolve(MyHealthViewController.self)!
appRouter.myHealthReportedVC = r.resolve(MyHealthReportedViewController.self)!
appRouter.expositionVC = r.resolve(ExpositionViewController.self)!
appRouter.highExpositionVC = r.resolve(HighExpositionViewController.self)!
appRouter.positiveExposedVC = r.resolve(PositiveExposedViewController.self)!
appRouter.welcomeVC = r.resolve(WelcomeViewController.self)!
appRouter.activateCovid = r.resolve(ActivateCovidNotificationViewController.self)!
appRouter.activatePush = r.resolve(ActivatePushNotificationViewController.self)!
appRouter.homeVC = r.resolve(HomeViewController.self)!
}

container.register(ProximityViewController.self) { r in
Expand Down Expand Up @@ -238,6 +229,7 @@ class Injection {
homeVC?.router = r.resolve(AppRouter.self)!
homeVC?.viewModel = r.resolve(HomeViewModel.self)!
homeVC?.errorHandler = r.resolve(ErrorHandler.self)!
homeVC?.termsRepository = r.resolve(TermsAcceptedRepository.self)!
return homeVC!
}

Expand All @@ -249,6 +241,7 @@ class Injection {
homeVM.expositionCheckUseCase = route.resolve(ExpositionCheckUseCase.self)!
homeVM.syncUseCase = route.resolve(SyncUseCase.self)!
homeVM.onBoardingCompletedUseCase = route.resolve(OnboardingCompletedUseCase.self)!
homeVM.fakeRequestUseCase = route.resolve(FakeRequestUseCase.self)!
return homeVM
}

Expand All @@ -267,13 +260,35 @@ class Injection {
return helpVC!
}

container.register(MyHealthViewController.self) { route in
let myHealthVC = self.createViewController(
storyboard: "MyHealth",
viewId: "MyHealthViewController") as? MyHealthViewController
myHealthVC?.diagnosisCodeUseCase = route.resolve(DiagnosisCodeUseCase.self)!
myHealthVC?.router = route.resolve(AppRouter.self)!
return myHealthVC!
container.register(SettingViewController.self) { route in
let settingVC = SettingViewController()
settingVC.router = route.resolve(AppRouter.self)!
settingVC.viewModel = route.resolve(SettingViewModel.self)!
return settingVC
}

container.register(SettingViewModel.self) { route in
let settingVM = SettingViewModel(localesUseCase: route.resolve(LocalesUseCase.self)!)
return settingVM
}

container.register(MyHealthStep0ViewController.self) { route in
let myHealthStep0 = MyHealthStep0ViewController()
myHealthStep0.router = route.resolve(AppRouter.self)!
return myHealthStep0
}

container.register(MyHealthStep1ViewController.self) { route in
let myHealthStep1 = MyHealthStep1ViewController()
myHealthStep1.router = route.resolve(AppRouter.self)!
return myHealthStep1
}

container.register(MyHealthStep2ViewController.self) { route in
let myHealthStep2 = MyHealthStep2ViewController()
myHealthStep2.router = route.resolve(AppRouter.self)!
myHealthStep2.diagnosisCodeUseCase = route.resolve(DiagnosisCodeUseCase.self)!
return myHealthStep2
}

container.register(MyHealthReportedViewController.self) { route in
Expand All @@ -289,16 +304,22 @@ class Injection {
storyboard: "OnBoarding",
viewId: "OnBoardingViewController") as? OnBoardingViewController
onbVC?.router = route.resolve(AppRouter.self)!
onbVC?.termsRepository = route.resolve(TermsAcceptedRepository.self)!
return onbVC!
}

container.register(WelcomeViewController.self) { r in
let welcomeVC = WelcomeViewController()
welcomeVC.localizationRepository = r.resolve(LocalizationRepository.self)!
welcomeVC.viewModel = r.resolve(WelcomeViewModel.self)!
welcomeVC.router = r.resolve(AppRouter.self)!
return welcomeVC
}

container.register(WelcomeViewModel.self) { route in
let welcomeVM = WelcomeViewModel(localesUseCase: route.resolve(LocalesUseCase.self)!)
return welcomeVM
}

container.register(ActivateCovidNotificationViewController.self) { r in
let activateCovidVC = ActivateCovidNotificationViewController()
activateCovidVC.router = r.resolve(AppRouter.self)!
Expand Down

0 comments on commit 2d1505d

Please sign in to comment.