session-ios/SessionUIKit/Database/Migrations/_001_ThemePreferences.swift
Morgan Pretty ea32e407a9 Applied theming to a number of screens, some minor cleanup and bug fixes
Updated the HomeVC, SettingsVC and GlobalSearch UI to use theming
Removed the "fade view" gradients from the various screens
Added a simple log to the PagedDatabaseObserver to make debugging easier
Updated the FullConversationCell to also show the "read" state for messages
Updated the read receipt icons to use SFSymbols directly
Updated the PlaceholderIcon to use the PrimaryColour's as it's colour options
2022-08-12 17:28:00 +10:00

35 lines
1.3 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
/// This migration extracts an old theme preference from UserDefaults and saves it to the database as well as set the default for the other
/// theme preferences
enum _001_ThemePreferences: Migration {
static let target: TargetMigrations.Identifier = .uiKit
static let identifier: String = "ThemePreferences"
static let needsConfigSync: Bool = false
static let minExpectedRunDuration: TimeInterval = 0.1
static func migrate(_ db: Database) throws {
// Determine if the user was matching the system setting
let isMatchingSystemSetting: Bool = UserDefaults.standard.dictionaryRepresentation()
.keys
.contains("appMode")
// Set the default theme settings sccordingly
db[.themeMatchSystemDayNightCycle] = isMatchingSystemSetting
db[.theme] = (isMatchingSystemSetting ?
Theme.classicDark :
(UserDefaults.standard.integer(forKey: "appMode") == 0 ?
Theme.classicLight :
Theme.classicDark
)
)
db[.themePrimaryColor] = Theme.PrimaryColor.green
Storage.update(progress: 1, for: self, in: target) // In case this is the last migration
}
}