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
f9d43a00
Unverified
Commit
f9d43a00
authored
Nov 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: issue-584: moved Device model to enum from Strings
parent
09ca9e30
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
27 deletions
+70
-27
Sources/iOS/Device.swift
+56
-27
Sources/iOS/Editor.swift
+14
-0
No files found.
Sources/iOS/Device.swift
View file @
f9d43a00
...
@@ -30,9 +30,38 @@
...
@@ -30,9 +30,38 @@
import
UIKit
import
UIKit
public
enum
DeviceModel
{
case
iPodTouch5
case
iPodTouch6
case
iPhone4
case
iPhone4s
case
iPhone5
case
iPhone5c
case
iPhone5s
case
iPhone6
case
iPhone6Plus
case
iPhone6s
case
iPhone6sPlus
case
iPhoneSE
case
iPad2
case
iPad3
case
iPad4
case
iPadAir
case
iPadAir2
case
iPadMini
case
iPadMini2
case
iPadMini3
case
iPadMini4
case
iPadProSmall
case
iPadProLarge
case
appleTV
case
simulator
case
unknown
}
public
struct
Device
{
public
struct
Device
{
/// Gets the model name for the device.
/// Gets the model name for the device.
public
static
var
model
:
String
{
public
static
var
model
:
DeviceModel
{
var
systemInfo
=
utsname
()
var
systemInfo
=
utsname
()
uname
(
&
systemInfo
)
uname
(
&
systemInfo
)
...
@@ -45,32 +74,32 @@ public struct Device {
...
@@ -45,32 +74,32 @@ public struct Device {
}
}
switch
identifier
{
switch
identifier
{
case
"iPod5,1"
:
return
"iPod Touch 5"
case
"iPod5,1"
:
return
.
iPodTouch5
case
"iPod7,1"
:
return
"iPod Touch 6"
case
"iPod7,1"
:
return
.
iPodTouch6
case
"iPhone3,1"
,
"iPhone3,2"
,
"iPhone3,3"
:
return
"iPhone 4"
case
"iPhone3,1"
,
"iPhone3,2"
,
"iPhone3,3"
:
return
.
iPhone4
case
"iPhone4,1"
:
return
"iPhone 4s"
case
"iPhone4,1"
:
return
.
iPhone4s
case
"iPhone5,1"
,
"iPhone5,2"
:
return
"iPhone 5"
case
"iPhone5,1"
,
"iPhone5,2"
:
return
.
iPhone5
case
"iPhone5,3"
,
"iPhone5,4"
:
return
"iPhone 5c"
case
"iPhone5,3"
,
"iPhone5,4"
:
return
.
iPhone5c
case
"iPhone6,1"
,
"iPhone6,2"
:
return
"iPhone 5s"
case
"iPhone6,1"
,
"iPhone6,2"
:
return
.
iPhone5s
case
"iPhone7,2"
:
return
"iPhone 6"
case
"iPhone7,2"
:
return
.
iPhone6
case
"iPhone7,1"
:
return
"iPhone 6 Plus"
case
"iPhone7,1"
:
return
.
iPhone6Plus
case
"iPhone8,1"
:
return
"iPhone 6s"
case
"iPhone8,1"
:
return
.
iPhone6s
case
"iPhone8,2"
:
return
"iPhone 6s Plus"
case
"iPhone8,2"
:
return
.
iPhone6sPlus
case
"iPhone8,4"
:
return
"iPhone SE"
case
"iPhone8,4"
:
return
.
iPhoneSE
case
"iPad2,1"
,
"iPad2,2"
,
"iPad2,3"
,
"iPad2,4"
:
return
"iPad 2"
case
"iPad2,1"
,
"iPad2,2"
,
"iPad2,3"
,
"iPad2,4"
:
return
.
iPad2
case
"iPad3,1"
,
"iPad3,2"
,
"iPad3,3"
:
return
"iPad 3"
case
"iPad3,1"
,
"iPad3,2"
,
"iPad3,3"
:
return
.
iPad3
case
"iPad3,4"
,
"iPad3,5"
,
"iPad3,6"
:
return
"iPad 4"
case
"iPad3,4"
,
"iPad3,5"
,
"iPad3,6"
:
return
.
iPad4
case
"iPad4,1"
,
"iPad4,2"
,
"iPad4,3"
:
return
"iPad Air"
case
"iPad4,1"
,
"iPad4,2"
,
"iPad4,3"
:
return
.
iPadAir
case
"iPad5,3"
,
"iPad5,4"
:
return
"iPad Air 2"
case
"iPad5,3"
,
"iPad5,4"
:
return
.
iPadAir2
case
"iPad2,5"
,
"iPad2,6"
,
"iPad2,7"
:
return
"iPad Mini"
case
"iPad2,5"
,
"iPad2,6"
,
"iPad2,7"
:
return
.
iPadMini
case
"iPad4,4"
,
"iPad4,5"
,
"iPad4,6"
:
return
"iPad Mini 2"
case
"iPad4,4"
,
"iPad4,5"
,
"iPad4,6"
:
return
.
iPadMini2
case
"iPad4,7"
,
"iPad4,8"
,
"iPad4,9"
:
return
"iPad Mini 3"
case
"iPad4,7"
,
"iPad4,8"
,
"iPad4,9"
:
return
.
iPadMini3
case
"iPad5,1"
,
"iPad5,2"
:
return
"iPad Mini 4"
case
"iPad5,1"
,
"iPad5,2"
:
return
.
iPadMini4
case
"iPad6,3"
,
"iPad6,4"
:
return
"iPad Pro 9.7-inch"
case
"iPad6,3"
,
"iPad6,4"
:
return
.
iPadProSmall
case
"iPad6,7"
,
"iPad6,8"
:
return
"iPad Pro 12.9-inch"
case
"iPad6,7"
,
"iPad6,8"
:
return
.
iPadProLarge
case
"AppleTV5,3"
:
return
"Apple TV"
case
"AppleTV5,3"
:
return
.
appleTV
case
"i386"
,
"x86_64"
:
return
"Simulator"
case
"i386"
,
"x86_64"
:
return
.
simulator
default
:
return
identifier
default
:
return
.
unknown
}
}
}
}
...
...
Sources/iOS/Editor.swift
View file @
f9d43a00
...
@@ -299,10 +299,12 @@ extension Editor {
...
@@ -299,10 +299,12 @@ extension Editor {
}
}
extension
Editor
:
TextStorageDelegate
{
extension
Editor
:
TextStorageDelegate
{
@objc
open
func
textStorage
(
textStorage
:
TextStorage
,
willProcessEditing
text
:
String
,
range
:
NSRange
)
{
open
func
textStorage
(
textStorage
:
TextStorage
,
willProcessEditing
text
:
String
,
range
:
NSRange
)
{
delegate
?
.
editor
?(
editor
:
self
,
willProcessEditing
:
textStorage
,
text
:
string
,
range
:
range
)
delegate
?
.
editor
?(
editor
:
self
,
willProcessEditing
:
textStorage
,
text
:
string
,
range
:
range
)
}
}
@objc
open
func
textStorage
(
textStorage
:
TextStorage
,
didProcessEditing
text
:
String
,
result
:
NSTextCheckingResult
?,
flags
:
NSRegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
{
open
func
textStorage
(
textStorage
:
TextStorage
,
didProcessEditing
text
:
String
,
result
:
NSTextCheckingResult
?,
flags
:
NSRegularExpression
.
MatchingFlags
,
stop
:
UnsafeMutablePointer
<
ObjCBool
>
)
{
guard
let
range
=
result
?
.
range
else
{
guard
let
range
=
result
?
.
range
else
{
return
return
...
@@ -313,30 +315,37 @@ extension Editor: TextStorageDelegate {
...
@@ -313,30 +315,37 @@ extension Editor: TextStorageDelegate {
}
}
extension
Editor
:
UITextViewDelegate
{
extension
Editor
:
UITextViewDelegate
{
@objc
open
func
textViewShouldBeginEditing
(
_
textView
:
UITextView
)
->
Bool
{
open
func
textViewShouldBeginEditing
(
_
textView
:
UITextView
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
shouldBeginEditing
:
textView
)
??
true
return
delegate
?
.
editor
?(
editor
:
self
,
shouldBeginEditing
:
textView
)
??
true
}
}
@objc
open
func
textViewShouldEndEditing
(
_
textView
:
UITextView
)
->
Bool
{
open
func
textViewShouldEndEditing
(
_
textView
:
UITextView
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
shouldEndEditing
:
textView
)
??
true
return
delegate
?
.
editor
?(
editor
:
self
,
shouldEndEditing
:
textView
)
??
true
}
}
@objc
open
func
textViewDidBeginEditing
(
_
textView
:
UITextView
)
{
open
func
textViewDidBeginEditing
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didBeginEditing
:
textView
)
delegate
?
.
editor
?(
editor
:
self
,
didBeginEditing
:
textView
)
}
}
@objc
open
func
textViewDidEndEditing
(
_
textView
:
UITextView
)
{
open
func
textViewDidEndEditing
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didEndEditing
:
textView
)
delegate
?
.
editor
?(
editor
:
self
,
didEndEditing
:
textView
)
}
}
@objc
open
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
open
func
textView
(
_
textView
:
UITextView
,
shouldChangeTextIn
range
:
NSRange
,
replacementText
text
:
String
)
->
Bool
{
return
delegate
?
.
editor
?(
editor
:
self
,
textView
:
textView
,
shouldChangeTextIn
:
range
,
replacementText
:
text
)
??
true
return
delegate
?
.
editor
?(
editor
:
self
,
textView
:
textView
,
shouldChangeTextIn
:
range
,
replacementText
:
text
)
??
true
}
}
@objc
open
func
textViewDidChange
(
_
textView
:
UITextView
)
{
open
func
textViewDidChange
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didChange
:
textView
)
delegate
?
.
editor
?(
editor
:
self
,
didChange
:
textView
)
}
}
@objc
open
func
textViewDidChangeSelection
(
_
textView
:
UITextView
)
{
open
func
textViewDidChangeSelection
(
_
textView
:
UITextView
)
{
delegate
?
.
editor
?(
editor
:
self
,
didChangeSelection
:
textView
)
delegate
?
.
editor
?(
editor
:
self
,
didChangeSelection
:
textView
)
}
}
...
@@ -345,10 +354,12 @@ extension Editor: UITextViewDelegate {
...
@@ -345,10 +354,12 @@ extension Editor: UITextViewDelegate {
/*
/*
@available(iOS, introduced: 8.0, deprecated: : 10.0)
@available(iOS, introduced: 8.0, deprecated: : 10.0)
extension Editor {
extension Editor {
@objc
open func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
open func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: URL, in: characterRange) ?? true
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: URL, in: characterRange) ?? true
}
}
@objc
open func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange) -> Bool {
open func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange) -> Bool {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: textAttachment, in: characterRange) ?? true
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: textAttachment, in: characterRange) ?? true
}
}
...
@@ -356,10 +367,13 @@ extension Editor {
...
@@ -356,10 +367,13 @@ extension Editor {
@available(iOS 10.0, *)
@available(iOS 10.0, *)
extension Editor {
extension Editor {
@objc
open func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
open func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: URL, in: characterRange, interaction: interaction) ?? true
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: URL, in: characterRange, interaction: interaction) ?? true
}
}
@objc
open func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
open func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: textAttachment, in: characterRange, interaction: interaction) ?? true
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: textAttachment, in: characterRange, interaction: interaction) ?? true
}
}
...
...
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