Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
38ff84be
Unverified
Commit
38ff84be
authored
Sep 10, 2018
by
ConfusedVorlon
Committed by
GitHub
Sep 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support extensions (#1)
Use an extension safe Application.shared
parent
6dc1048c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
Sources/iOS/Application.swift
+19
-8
No files found.
Sources/iOS/Application.swift
View file @
38ff84be
...
@@ -31,9 +31,20 @@
...
@@ -31,9 +31,20 @@
import
UIKit
import
UIKit
public
struct
Application
{
public
struct
Application
{
public
static
var
shared
:
UIApplication
{
let
sharedSelector
=
NSSelectorFromString
(
"sharedApplication"
)
guard
UIApplication
.
responds
(
to
:
sharedSelector
)
else
{
fatalError
(
"[Material: Extensions cannot access Application]"
)
}
let
shared
=
UIApplication
.
perform
(
sharedSelector
)
return
shared
?
.
takeUnretainedValue
()
as!
UIApplication
}
/// An optional reference to the main UIWindow.
/// An optional reference to the main UIWindow.
public
static
var
keyWindow
:
UIWindow
?
{
public
static
var
keyWindow
:
UIWindow
?
{
return
UI
Application
.
shared
.
keyWindow
return
Application
.
shared
.
keyWindow
}
}
/// An optional reference to the top most view controller.
/// An optional reference to the top most view controller.
...
@@ -43,7 +54,7 @@ public struct Application {
...
@@ -43,7 +54,7 @@ public struct Application {
/// A boolean indicating if the device is in Landscape mode.
/// A boolean indicating if the device is in Landscape mode.
public
static
var
isLandscape
:
Bool
{
public
static
var
isLandscape
:
Bool
{
return
UI
Application
.
shared
.
statusBarOrientation
.
isLandscape
return
Application
.
shared
.
statusBarOrientation
.
isLandscape
}
}
/// A boolean indicating if the device is in Portrait mode.
/// A boolean indicating if the device is in Portrait mode.
...
@@ -53,26 +64,26 @@ public struct Application {
...
@@ -53,26 +64,26 @@ public struct Application {
/// The current UIInterfaceOrientation value.
/// The current UIInterfaceOrientation value.
public
static
var
orientation
:
UIInterfaceOrientation
{
public
static
var
orientation
:
UIInterfaceOrientation
{
return
UI
Application
.
shared
.
statusBarOrientation
return
Application
.
shared
.
statusBarOrientation
}
}
/// Retrieves the device status bar style.
/// Retrieves the device status bar style.
public
static
var
statusBarStyle
:
UIStatusBarStyle
{
public
static
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
get
{
return
UI
Application
.
shared
.
statusBarStyle
return
Application
.
shared
.
statusBarStyle
}
}
set
(
value
)
{
set
(
value
)
{
UI
Application
.
shared
.
statusBarStyle
=
value
Application
.
shared
.
statusBarStyle
=
value
}
}
}
}
/// Retrieves the device status bar hidden state.
/// Retrieves the device status bar hidden state.
public
static
var
isStatusBarHidden
:
Bool
{
public
static
var
isStatusBarHidden
:
Bool
{
get
{
get
{
return
UI
Application
.
shared
.
isStatusBarHidden
return
Application
.
shared
.
isStatusBarHidden
}
}
set
(
value
)
{
set
(
value
)
{
UI
Application
.
shared
.
isStatusBarHidden
=
value
Application
.
shared
.
isStatusBarHidden
=
value
}
}
}
}
...
@@ -86,6 +97,6 @@ public struct Application {
...
@@ -86,6 +97,6 @@ public struct Application {
/// A reference to the user interface layout direction.
/// A reference to the user interface layout direction.
public
static
var
userInterfaceLayoutDirection
:
UIUserInterfaceLayoutDirection
{
public
static
var
userInterfaceLayoutDirection
:
UIUserInterfaceLayoutDirection
{
return
UI
Application
.
shared
.
userInterfaceLayoutDirection
return
Application
.
shared
.
userInterfaceLayoutDirection
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment