mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Introduce an AppMediator which will:
- combine multiple services to handle app wide requests - remove direct UIApplication access from everywhere - fix #2703 by combining UIApplication.applicationState with the WindowManager's main window appearance - leave the door open for more app control in the future (especiall for the mac)
This commit is contained in:
committed by
Stefan Ceriu
parent
bdacea10a2
commit
9a172df7fd
+10
-10
@@ -16,21 +16,21 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
extension ApplicationMock {
|
||||
static var `default`: ApplicationProtocol {
|
||||
ApplicationMock(withState: .active,
|
||||
extension AppMediatorMock {
|
||||
static var `default`: AppMediatorProtocol {
|
||||
AppMediatorMock(withState: .active,
|
||||
backgroundTimeRemaining: 10,
|
||||
allowTasks: true)
|
||||
}
|
||||
|
||||
static var mockBroken: ApplicationProtocol {
|
||||
ApplicationMock(withState: .inactive,
|
||||
|
||||
static var mockBroken: AppMediatorProtocol {
|
||||
AppMediatorMock(withState: .inactive,
|
||||
backgroundTimeRemaining: 0,
|
||||
allowTasks: false)
|
||||
}
|
||||
|
||||
static var mockAboutToSuspend: ApplicationProtocol {
|
||||
ApplicationMock(withState: .background,
|
||||
|
||||
static var mockAboutToSuspend: AppMediatorProtocol {
|
||||
AppMediatorMock(withState: .background,
|
||||
backgroundTimeRemaining: 2,
|
||||
allowTasks: false)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ extension ApplicationMock {
|
||||
allowTasks: Bool) {
|
||||
self.init()
|
||||
|
||||
underlyingApplicationState = applicationState
|
||||
underlyingAppState = applicationState
|
||||
underlyingBackgroundTimeRemaining = backgroundTimeRemaining
|
||||
|
||||
beginBackgroundTaskWithNameExpirationHandlerClosure = { _, handler in
|
||||
@@ -747,17 +747,17 @@ class AppLockServiceMock: AppLockServiceProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
class ApplicationMock: ApplicationProtocol {
|
||||
class AppMediatorMock: AppMediatorProtocol {
|
||||
var backgroundTimeRemaining: TimeInterval {
|
||||
get { return underlyingBackgroundTimeRemaining }
|
||||
set(value) { underlyingBackgroundTimeRemaining = value }
|
||||
}
|
||||
var underlyingBackgroundTimeRemaining: TimeInterval!
|
||||
var applicationState: UIApplication.State {
|
||||
get { return underlyingApplicationState }
|
||||
set(value) { underlyingApplicationState = value }
|
||||
var appState: UIApplication.State {
|
||||
get { return underlyingAppState }
|
||||
set(value) { underlyingAppState = value }
|
||||
}
|
||||
var underlyingApplicationState: UIApplication.State!
|
||||
var underlyingAppState: UIApplication.State!
|
||||
|
||||
//MARK: - beginBackgroundTask
|
||||
|
||||
|
||||
Reference in New Issue
Block a user