-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented StateMachine touch events and a Magic 8 Ball example to d…
…emonstrate them. Removed old RArtboardDelegate now that the touch events are handled by the StateMachine.
- Loading branch information
1 parent
f7b8da9
commit 9d9d1b9
Showing
36 changed files
with
297 additions
and
113 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
Example-iOS/Source/Examples/SwiftUI/SwiftTouchEvents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// SwiftTouchEvents.swift | ||
// RiveExample | ||
// | ||
// Created by Zachary Duncan on 4/26/22. | ||
// Copyright © 2022 Rive. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import RiveRuntime | ||
|
||
struct SwiftTouchEvents: DismissableView { | ||
var dismiss: () -> Void = {} | ||
|
||
var body: some View { | ||
ScrollView { | ||
VStack { | ||
RiveViewModel(fileName: "play_button_event_example", stateMachineName: "State Machine") | ||
.view() | ||
.aspectRatio(1, contentMode: .fit) | ||
|
||
// RiveViewModel(fileName: "switch_event_example", stateMachineName: "Main State Machine") | ||
// .view() | ||
// .aspectRatio(1, contentMode: .fit) | ||
|
||
RiveViewModel(fileName: "magic_8-ball_v2", stateMachineName: "Main State Machine") | ||
.view() | ||
.aspectRatio(1, contentMode: .fit) | ||
|
||
RiveViewModel(fileName: "leg_day_events_example", stateMachineName: "Don't Skip Leg Day") | ||
.view() | ||
.aspectRatio(1, contentMode: .fit) | ||
|
||
ClockViewModel() | ||
.view() | ||
.aspectRatio(1, contentMode: .fit) | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
Example-iOS/Source/Examples/ViewModel/ClockViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// TouchEvents.swift | ||
// RiveExample | ||
// | ||
// Created by Zachary Duncan on 4/26/22. | ||
// Copyright © 2022 Rive. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import RiveRuntime | ||
|
||
class ClockViewModel: RiveViewModel { | ||
var timer: Timer! | ||
var hours: Double = 0 { | ||
didSet { | ||
try? setInput("isTime", value: hours > 12 ? hours-12 : hours) | ||
} | ||
} | ||
|
||
convenience init() { | ||
self.init(fileName: "watch_v1", stateMachineName: "Time") | ||
print("Clock widget init'd") | ||
|
||
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in | ||
let date = Date() | ||
let calendar = Calendar.current | ||
|
||
let hour = calendar.component(.hour, from: date) | ||
let minute = calendar.component(.minute, from: date) | ||
let second = calendar.component(.second, from: date) | ||
|
||
self.hours = Double(hour) + Double(minute)/60 + Double(second)/1200 | ||
} | ||
} | ||
|
||
deinit { | ||
timer.invalidate() | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.