Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
36e598d5
Commit
36e598d5
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add ShakeViewModifier
parent
c8106cfd
No related branches found
No related tags found
2 merge requests
!102
Release 1.0.0
,
!101
Messenger example - logging
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Examples/xx-messenger/Sources/AppCore/SharedUI/ShakeViewModifier.swift
+42
-0
42 additions, 0 deletions
...essenger/Sources/AppCore/SharedUI/ShakeViewModifier.swift
with
42 additions
and
0 deletions
Examples/xx-messenger/Sources/AppCore/SharedUI/ShakeViewModifier.swift
0 → 100644
+
42
−
0
View file @
36e598d5
import
SwiftUI
struct
ShakeViewModifier
:
ViewModifier
{
var
action
:
()
->
Void
func
body
(
content
:
Content
)
->
some
View
{
content
.
onReceive
(
NotificationCenter
.
default
.
publisher
(
for
:
UIDevice
.
deviceDidShakeNotification
),
perform
:
{
_
in
action
()
}
)
}
}
extension
View
{
public
func
onShake
(
perform
action
:
@escaping
()
->
Void
)
->
some
View
{
modifier
(
ShakeViewModifier
(
action
:
action
))
}
}
extension
UIDevice
{
static
let
deviceDidShakeNotification
=
Notification
.
Name
(
rawValue
:
"deviceDidShakeNotification"
)
}
extension
UIWindow
{
open
override
func
motionEnded
(
_
motion
:
UIEvent
.
EventSubtype
,
with
event
:
UIEvent
?
)
{
super
.
motionEnded
(
motion
,
with
:
event
)
guard
motion
==
.
motionShake
else
{
return
}
NotificationCenter
.
default
.
post
(
name
:
UIDevice
.
deviceDidShakeNotification
,
object
:
nil
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment