Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
d3979724
Unverified
Commit
d3979724
authored
Jan 18, 2022
by
Roman Sedaikin
Committed by
GitHub
Jan 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added feature to define particular gestures to be used in UIView. (#454)
parent
084c17ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
9 deletions
+36
-9
App.ios.kt
.../src/iosMain/kotlin/org/jetbrains/skiko/sample/App.ios.kt
+2
-1
SkiaLayer.ios.kt
...o/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
+27
-7
SkikoViewController.kt
...iosMain/kotlin/org/jetbrains/skiko/SkikoViewController.kt
+7
-1
No files found.
samples/SkiaMultiplatformSample/src/iosMain/kotlin/org/jetbrains/skiko/sample/App.ios.kt
View file @
d3979724
...
@@ -6,6 +6,7 @@ import org.jetbrains.skiko.GenericSkikoView
...
@@ -6,6 +6,7 @@ import org.jetbrains.skiko.GenericSkikoView
import
org.jetbrains.skiko.SkiaLayer
import
org.jetbrains.skiko.SkiaLayer
import
org.jetbrains.skiko.SkikoView
import
org.jetbrains.skiko.SkikoView
import
org.jetbrains.skiko.SkikoViewController
import
org.jetbrains.skiko.SkikoViewController
import
org.jetbrains.skiko.SkikoGestureEventKind
import
platform.UIKit.*
import
platform.UIKit.*
import
platform.Foundation.*
import
platform.Foundation.*
...
@@ -36,7 +37,7 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {
...
@@ -36,7 +37,7 @@ class SkikoAppDelegate : UIResponder, UIApplicationDelegateProtocol {
override
fun
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
:
Map
<
Any
?
,
*
>?):
Boolean
{
override
fun
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
:
Map
<
Any
?
,
*
>?):
Boolean
{
window
=
UIWindow
(
frame
=
UIScreen
.
mainScreen
.
bounds
)
window
=
UIWindow
(
frame
=
UIScreen
.
mainScreen
.
bounds
)
window
!!
.
rootViewController
=
SkikoViewController
().
apply
{
window
!!
.
rootViewController
=
SkikoViewController
(
SkikoGestureEventKind
.
values
()
).
apply
{
setAppFactory
{
layer
->
setAppFactory
{
layer
->
GenericSkikoView
(
layer
,
makeApp
(
layer
)).
also
{
GenericSkikoView
(
layer
,
makeApp
(
layer
)).
also
{
layer
.
skikoView
=
it
layer
.
skikoView
=
it
...
...
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkiaLayer.ios.kt
View file @
d3979724
...
@@ -14,6 +14,12 @@ import platform.darwin.NSObject
...
@@ -14,6 +14,12 @@ import platform.darwin.NSObject
import
kotlin.system.getTimeNanos
import
kotlin.system.getTimeNanos
actual
open
class
SkiaLayer
{
actual
open
class
SkiaLayer
{
private
val
gestures
:
Array
<
SkikoGestureEventKind
>?
constructor
(
gestures
:
Array
<
SkikoGestureEventKind
>?
=
null
)
{
this
.
gestures
=
gestures
}
fun
isShowing
():
Boolean
{
fun
isShowing
():
Boolean
{
return
true
return
true
}
}
...
@@ -142,15 +148,29 @@ actual open class SkiaLayer {
...
@@ -142,15 +148,29 @@ actual open class SkiaLayer {
)
)
)
)
}
}
}
}
if
(!
gestures
.
isNullOrEmpty
())
{
// We have ':' in selector to take care of function argument.
// We have ':' in selector to take care of function argument.
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
TAP
))
{
view
.
addGestureRecognizer
(
UITapGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onTap:"
)))
view
.
addGestureRecognizer
(
UITapGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onTap:"
)))
}
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
LONGPRESS
))
{
view
.
addGestureRecognizer
(
UILongPressGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onLongPress:"
)))
view
.
addGestureRecognizer
(
UILongPressGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onLongPress:"
)))
}
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
PINCH
))
{
view
.
addGestureRecognizer
(
UIPinchGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onPinch:"
)))
view
.
addGestureRecognizer
(
UIPinchGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onPinch:"
)))
}
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
ROTATION
))
{
view
.
addGestureRecognizer
(
UIRotationGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onRotation:"
)))
view
.
addGestureRecognizer
(
UIRotationGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onRotation:"
)))
}
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
SWIPE
))
{
view
.
addGestureRecognizer
(
UISwipeGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onSwipe:"
)))
view
.
addGestureRecognizer
(
UISwipeGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onSwipe:"
)))
}
if
(
gestures
.
contains
(
SkikoGestureEventKind
.
PAN
))
{
view
.
addGestureRecognizer
(
UIPanGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onPan:"
)))
view
.
addGestureRecognizer
(
UIPanGestureRecognizer
(
controller
,
NSSelectorFromString
(
"onPan:"
)))
}
}
// TODO: maybe add observer for view.viewDidDisappear() to detach us?
// TODO: maybe add observer for view.viewDidDisappear() to detach us?
redrawer
=
MetalRedrawer
(
this
).
apply
{
redrawer
=
MetalRedrawer
(
this
).
apply
{
needRedraw
()
needRedraw
()
...
...
skiko/src/iosMain/kotlin/org/jetbrains/skiko/SkikoViewController.kt
View file @
d3979724
...
@@ -16,12 +16,18 @@ import platform.UIKit.UIPressesEvent
...
@@ -16,12 +16,18 @@ import platform.UIKit.UIPressesEvent
@ExportObjCClass
@ExportObjCClass
class
SkikoViewController
:
UIViewController
,
UIKeyInputProtocol
{
class
SkikoViewController
:
UIViewController
,
UIKeyInputProtocol
{
private
var
gestures
:
Array
<
SkikoGestureEventKind
>?
=
null
@OverrideInit
@OverrideInit
constructor
()
:
super
(
nibName
=
null
,
bundle
=
null
)
constructor
()
:
super
(
nibName
=
null
,
bundle
=
null
)
@OverrideInit
@OverrideInit
constructor
(
coder
:
NSCoder
)
:
super
(
coder
)
constructor
(
coder
:
NSCoder
)
:
super
(
coder
)
constructor
(
gestures
:
Array
<
SkikoGestureEventKind
>?
=
null
)
:
this
()
{
this
.
gestures
=
gestures
}
override
fun
canBecomeFirstResponder
()
=
true
override
fun
canBecomeFirstResponder
()
=
true
private
var
keyEvent
:
UIPress
?
=
null
private
var
keyEvent
:
UIPress
?
=
null
...
@@ -131,7 +137,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
...
@@ -131,7 +137,7 @@ class SkikoViewController : UIViewController, UIKeyInputProtocol {
val
(
width
,
height
)
=
UIScreen
.
mainScreen
.
bounds
.
useContents
{
val
(
width
,
height
)
=
UIScreen
.
mainScreen
.
bounds
.
useContents
{
this
.
size
.
width
to
this
.
size
.
height
this
.
size
.
width
to
this
.
size
.
height
}
}
skikoLayer
=
SkiaLayer
().
apply
{
skikoLayer
=
SkiaLayer
(
gestures
).
apply
{
skikoView
=
appFactory
(
this
)
skikoView
=
appFactory
(
this
)
}
}
view
.
contentScaleFactor
=
UIScreen
.
mainScreen
.
scale
view
.
contentScaleFactor
=
UIScreen
.
mainScreen
.
scale
...
...
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