Skip to content

Commit

Permalink
Dark mode analytics (#625)
Browse files Browse the repository at this point in the history
* Add analytics
  • Loading branch information
ivan-magda authored Jan 21, 2020
1 parent f7b3d59 commit 83aaddb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Stepic/Analytics/AnalyticsUserProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,17 @@ final class AnalyticsUserProperties: ABAnalyticsServiceProtocol {
func updateUserID() {
self.setUserID(to: AuthInfo.shared.userId)
}

func updateIsDarkModeEnabled() {
let isEnabled: Bool = {
if #available(iOS 13.0, *) {
if case .dark = UITraitCollection.current.userInterfaceStyle {
return true
}
}
return false
}()

self.setProperty(key: "is_night_mode_enabled", value: "\(isEnabled)")
}
}
5 changes: 5 additions & 0 deletions Stepic/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
AnalyticsHelper.sharedHelper.setupAnalytics()
AnalyticsUserProperties.shared.setApplicationID(id: Bundle.main.bundleIdentifier!)
AnalyticsUserProperties.shared.updateUserID()
AnalyticsUserProperties.shared.updateIsDarkModeEnabled()

NotificationsBadgesManager.shared.setup()

Expand Down Expand Up @@ -116,6 +117,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

self.branchService.setup(launchOptions: launchOptions)

if #available(iOS 13.0, *) {
self.window?.overrideUserInterfaceStyle = .light
}

return true
}

Expand Down
2 changes: 0 additions & 2 deletions Stepic/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>branch_key</key>
Expand Down

0 comments on commit 83aaddb

Please sign in to comment.