diff --git a/Example-iOS/Assets/favorite_animation.riv b/Example-iOS/Assets/favorite_animation.riv new file mode 100644 index 00000000..3bdb52ed Binary files /dev/null and b/Example-iOS/Assets/favorite_animation.riv differ diff --git a/Example-iOS/RiveExample.xcodeproj/project.pbxproj b/Example-iOS/RiveExample.xcodeproj/project.pbxproj index 6881bdc4..ab8d3be2 100644 --- a/Example-iOS/RiveExample.xcodeproj/project.pbxproj +++ b/Example-iOS/RiveExample.xcodeproj/project.pbxproj @@ -267,6 +267,11 @@ 2E83910B2C050B0F003BCF2A /* SwiftNestedInputs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */; }; 2E83910D2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = 2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */; }; 2E83910E2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = 2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */; }; + 65AD0AC82C92DC8300989C11 /* Repro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AD0AC72C92DC8300989C11 /* Repro.swift */; }; + 65AD0AC92C92DC8300989C11 /* Repro.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AD0AC72C92DC8300989C11 /* Repro.swift */; }; + 65AD0ACC2C92E3D700989C11 /* TextureSwiftSupport in Frameworks */ = {isa = PBXBuildFile; productRef = 65AD0ACB2C92E3D700989C11 /* TextureSwiftSupport */; }; + 65AD0ACE2C92E48100989C11 /* favorite_animation.riv in Resources */ = {isa = PBXBuildFile; fileRef = 65AD0ACD2C92E48100989C11 /* favorite_animation.riv */; }; + 65AD0ACF2C92E48100989C11 /* favorite_animation.riv in Resources */ = {isa = PBXBuildFile; fileRef = 65AD0ACD2C92E48100989C11 /* favorite_animation.riv */; }; 83C89ACB29886ECB00044C17 /* StressTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C89ACA29886ECB00044C17 /* StressTest.swift */; }; 83C89ACF2988709400044C17 /* marty.riv in Resources */ = {isa = PBXBuildFile; fileRef = 83C89ACE2988709400044C17 /* marty.riv */; }; 83C89AD1298870A700044C17 /* paper.riv in Resources */ = {isa = PBXBuildFile; fileRef = 83C89AD0298870A700044C17 /* paper.riv */; }; @@ -430,6 +435,8 @@ 27108F2C282C96E700A99D81 /* light_switch.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = light_switch.riv; sourceTree = ""; }; 2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftNestedInputs.swift; sourceTree = ""; }; 2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = runtime_nested_inputs.riv; sourceTree = ""; }; + 65AD0AC72C92DC8300989C11 /* Repro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Repro.swift; sourceTree = ""; }; + 65AD0ACD2C92E48100989C11 /* favorite_animation.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = favorite_animation.riv; sourceTree = ""; }; 83C89ACA29886ECB00044C17 /* StressTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StressTest.swift; sourceTree = ""; }; 83C89ACE2988709400044C17 /* marty.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = marty.riv; sourceTree = ""; }; 83C89AD0298870A700044C17 /* paper.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = paper.riv; sourceTree = ""; }; @@ -494,6 +501,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 65AD0ACC2C92E3D700989C11 /* TextureSwiftSupport in Frameworks */, 040554332B7A291A008F076A /* RiveRuntime in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -530,6 +538,7 @@ 83C89ACA29886ECB00044C17 /* StressTest.swift */, 043025EE2AF905B100320F2E /* CachedAssets.swift */, 0453FCB82B012DA9001185C8 /* SimpleOutOfBand.swift */, + 65AD0AC72C92DC8300989C11 /* Repro.swift */, ); path = Storyboard; sourceTree = ""; @@ -615,6 +624,7 @@ C3745FCB282AE2320087F4AF /* hero_editor.riv */, C3E383472837E6B00029D65E /* watch_v1.riv */, C3ECAC29281837B300A81123 /* leg_day_events_example.riv */, + 65AD0ACD2C92E48100989C11 /* favorite_animation.riv */, C3ECAC28281837B300A81123 /* play_button_event_example.riv */, E5964AB02A9CDB2100140479 /* rating_animation.riv */, C3ECAC2A281837B300A81123 /* switch_event_example.riv */, @@ -775,6 +785,7 @@ name = "Preview (iOS)"; packageProductDependencies = ( 040554322B7A291A008F076A /* RiveRuntime */, + 65AD0ACB2C92E3D700989C11 /* TextureSwiftSupport */, ); productName = RiveExample; productReference = 040554302B7A2858008F076A /* Preview (iOS).app */; @@ -845,6 +856,7 @@ mainGroup = C9C73E8B24FC471E00EF9516; packageReferences = ( F8772AD82AD9483800AB5920 /* XCRemoteSwiftPackageReference "rive-ios" */, + 65AD0ACA2C92E3D700989C11 /* XCRemoteSwiftPackageReference "TextureSwiftSupport" */, ); productRefGroup = C9C73E9524FC471E00EF9516 /* Products */; projectDirPath = ""; @@ -967,6 +979,7 @@ 040554012B7A2858008F076A /* nothing.riv in Resources */, 040554022B7A2858008F076A /* Inter-45562.ttf in Resources */, 040554032B7A2858008F076A /* off_road_car_blog.riv in Resources */, + 65AD0ACE2C92E48100989C11 /* favorite_animation.riv in Resources */, 040554042B7A2858008F076A /* Main.storyboard in Resources */, 040554052B7A2858008F076A /* skills.riv in Resources */, 040554062B7A2858008F076A /* artboard_animations.riv in Resources */, @@ -1098,6 +1111,7 @@ 04D5B06C266A460C004ACA5B /* nothing.riv in Resources */, 0453FCBF2B014E2F001185C8 /* Inter-45562.ttf in Resources */, 042C88E92644447500E7DBB2 /* off_road_car_blog.riv in Resources */, + 65AD0ACF2C92E48100989C11 /* favorite_animation.riv in Resources */, 042C88832643D6B900E7DBB2 /* Main.storyboard in Resources */, 042C88EA2644447500E7DBB2 /* skills.riv in Resources */, 042C88E62644447500E7DBB2 /* artboard_animations.riv in Resources */, @@ -1192,6 +1206,7 @@ 040553EB2B7A2858008F076A /* SwiftMultipleAnimations.swift in Sources */, 040553EC2B7A2858008F076A /* SimpleAnimation.swift in Sources */, 040553ED2B7A2858008F076A /* SwiftSimpleAnimation.swift in Sources */, + 65AD0AC82C92DC8300989C11 /* Repro.swift in Sources */, 040553EE2B7A2858008F076A /* SimpleOutOfBand.swift in Sources */, 040553EF2B7A2858008F076A /* SwiftTestText.swift in Sources */, 040553F02B7A2858008F076A /* SwiftStateMachine.swift in Sources */, @@ -1245,6 +1260,7 @@ 04026DCA27CE3EF6002B3DBF /* SwiftMultipleAnimations.swift in Sources */, 042C88882643DB7100E7DBB2 /* SimpleAnimation.swift in Sources */, 04026DC427CE3ED6002B3DBF /* SwiftSimpleAnimation.swift in Sources */, + 65AD0AC92C92DC8300989C11 /* Repro.swift in Sources */, 0453FCB92B012DA9001185C8 /* SimpleOutOfBand.swift in Sources */, E57798A92A730A9B00FF25C3 /* SwiftTestText.swift in Sources */, 04026DCE27CE3F0F002B3DBF /* SwiftStateMachine.swift in Sources */, @@ -1627,6 +1643,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 65AD0ACA2C92E3D700989C11 /* XCRemoteSwiftPackageReference "TextureSwiftSupport" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/FluidGroup/TextureSwiftSupport"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.20.1; + }; + }; F8772AD82AD9483800AB5920 /* XCRemoteSwiftPackageReference "rive-ios" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/rive-app/rive-ios/"; @@ -1648,6 +1672,11 @@ package = F8772AD82AD9483800AB5920 /* XCRemoteSwiftPackageReference "rive-ios" */; productName = RiveRuntime; }; + 65AD0ACB2C92E3D700989C11 /* TextureSwiftSupport */ = { + isa = XCSwiftPackageProductDependency; + package = 65AD0ACA2C92E3D700989C11 /* XCRemoteSwiftPackageReference "TextureSwiftSupport" */; + productName = TextureSwiftSupport; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = C9C73E8C24FC471E00EF9516 /* Project object */; diff --git a/Example-iOS/RiveExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example-iOS/RiveExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4e224286..853dc34f 100644 --- a/Example-iOS/RiveExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example-iOS/RiveExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,14 +1,42 @@ { + "originHash" : "0be417f319d84ba851dfee87274f90cc28c40672ea1050d771251e9604524119", "pins" : [ + { + "identity" : "descriptors", + "kind" : "remoteSourceControl", + "location" : "https://github.com/FluidGroup/Descriptors", + "state" : { + "revision" : "f41ce2605a76c5d378fe8c5e8c5c98b544dfd108", + "version" : "0.2.3" + } + }, { "identity" : "rive-ios", "kind" : "remoteSourceControl", "location" : "https://github.com/rive-app/rive-ios/", "state" : { - "revision" : "ce21e5a002b0996f55336355dcbbe852deace9ec", - "version" : "5.7.1" + "revision" : "723a0c5dd08ffe277456b1b1d7eaa76a3c9a86a0", + "version" : "6.1.0" + } + }, + { + "identity" : "texture", + "kind" : "remoteSourceControl", + "location" : "https://github.com/FluidGroup/Texture.git", + "state" : { + "revision" : "68df47f0d26522da76b06f22e9a97e4d4ab58dad", + "version" : "3.0.2" + } + }, + { + "identity" : "textureswiftsupport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/FluidGroup/TextureSwiftSupport", + "state" : { + "revision" : "fb748d6a9d0a2dca0635227e1db0360fd26e0e24", + "version" : "3.20.1" } } ], - "version" : 2 + "version" : 3 } diff --git a/Example-iOS/Source/Examples/Storyboard/Repro.swift b/Example-iOS/Source/Examples/Storyboard/Repro.swift new file mode 100644 index 00000000..42afe9c3 --- /dev/null +++ b/Example-iOS/Source/Examples/Storyboard/Repro.swift @@ -0,0 +1,98 @@ +// +// Repro.swift +// RiveExample +// +// Created by Daiki Takano on 2024/09/12. +// Copyright © 2024 Rive. All rights reserved. +// + +import UIKit +import RiveRuntime +import SwiftUI + +class ReproViewController: UIViewController { + + var riveViewModel = RiveViewModel(fileName: "favorite_animation", stateMachineName: "FavoriteButtonAnimStateMachine") + + init() { + + super.init(nibName: nil, bundle: nil) + + setDefaultState(isTrue: true) + + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + + let model = self.riveViewModel + let modelView = model.view() + + let hostingController = UIHostingController(rootView: { + + Group { + + Button(action: { + + self.setIsFavorite() + + }, label: { + + modelView + .aspectRatio(contentMode: .fit) + .frame(width: 50, height: 50) + + }) + .padding(.bottom, 24) + .padding(.top, 24) + + HStack(spacing: 16) { + + Button(action: { self.setIsFavorite() }, label: { Text("setIsFavorite") }) + + Button(action: { self.setIsNotFavorite() }, label: { Text("setIsNotFavorite") }) + + } + .padding(.bottom, 24) + .padding(.horizontal, 24) + + Button(action: { self.setDefaultState(isTrue: true) }, label: { Text("setDefaultState true") }) + .padding(.bottom, 24) + } + .background(Color.black) + + }()) + + addChild(hostingController) + hostingController.view.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(hostingController.view) + + NSLayoutConstraint.activate([ + hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), + hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), + hostingController.view.topAnchor.constraint(equalTo: view.topAnchor), + hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor) + ]) + + hostingController.didMove(toParent: self) + } + + private func setDefaultState(isTrue: Bool) { + if isTrue { + self.riveViewModel.triggerInput("isActive") + } + } + + private func setIsFavorite() { + self.riveViewModel.triggerInput("isFavorite") + } + + private func setIsNotFavorite() { + self.riveViewModel.triggerInput("isNotFavorite") + } +} + diff --git a/Example-iOS/Source/ExamplesMaster.swift b/Example-iOS/Source/ExamplesMaster.swift index 75347f95..c8331330 100644 --- a/Example-iOS/Source/ExamplesMaster.swift +++ b/Example-iOS/Source/ExamplesMaster.swift @@ -24,7 +24,7 @@ class ExamplesMasterTableViewController: UITableViewController { "Stress Test", "Simple assets", "Cached assets", - + "ReproViewController" ] @@ -85,7 +85,17 @@ extension ExamplesMasterTableViewController { // ViewControllers made from Storyboard IDs if indexPath.section == 0 { + + if storyboardIDs[indexPath.row] == "ReproViewController" { + + controller = ReproViewController() + + } else { + controller = storyboard!.instantiateViewController(withIdentifier: storyboardIDs[indexPath.row]) + + } + } // Views made by custom SwiftUI Views