Skip to content

Commit

Permalink
Deprecated old RiveFile utils. Converted Layout, BlendModes and State…
Browse files Browse the repository at this point in the history
…Machine UIKit examples. Commented out unused examples and old RiveView related things. Fixed SimpleAnimation presentation issues.
  • Loading branch information
duncandoit committed Apr 15, 2022
1 parent e6039be commit a456f48
Show file tree
Hide file tree
Showing 17 changed files with 2,311 additions and 2,276 deletions.
8 changes: 4 additions & 4 deletions Example-iOS/RiveExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@
042C88862643DB2200E7DBB2 /* UIkit */ = {
isa = PBXGroup;
children = (
C9A84F5D2644A75A0014D8E0 /* ExamplesViewController.swift */,
042C88872643DB7100E7DBB2 /* SimpleAnimation.swift */,
C3468E6127FDCBC6008652FD /* SimpleSlider.swift */,
042C888B2643EEE300E7DBB2 /* Layout.swift */,
042C888F2644250D00E7DBB2 /* MultipleAnimations.swift */,
C9A84F5D2644A75A0014D8E0 /* ExamplesViewController.swift */,
04A8F6C426454711002C909A /* LoopMode.swift */,
046AFA722673B00B004ED497 /* BlendModes.swift */,
04C4C83D2646FE410047E614 /* StateMachine.swift */,
04A8F6C426454711002C909A /* LoopMode.swift */,
04BE5437264D604500427B39 /* iosPlayer.swift */,
046AFA722673B00B004ED497 /* BlendModes.swift */,
);
path = UIkit;
sourceTree = "<group>";
Expand Down Expand Up @@ -273,8 +273,8 @@
isa = PBXGroup;
children = (
C9D3DE59264F309F001BA265 /* Explorer */,
C9CB2F12264C92D200E7FF0D /* RiveComponents.swift */,
04026DC327CE3ED6002B3DBF /* SwiftSimpleAnimation.swift */,
C9CB2F12264C92D200E7FF0D /* RiveComponents.swift */,
04026DC727CE3EE6002B3DBF /* SwiftLayout.swift */,
04026DC927CE3EF6002B3DBF /* SwiftMultipleAnimations.swift */,
04026DCB27CE3F03002B3DBF /* SwiftLoopMode.swift */,
Expand Down
42 changes: 21 additions & 21 deletions Example-iOS/Source/Main.storyboard

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions Example-iOS/Source/SwiftUI/Explorer/RiveExplorer.swift
Original file line number Diff line number Diff line change
@@ -1,166 +1,166 @@
import SwiftUI
import RiveRuntime

struct RiveExplorer: DismissableView {
@ObservedObject private var riveController = RiveExplorerController(
"artboard_animations",
fit: Fit.fitCover
)
@State private var loopCount: Int = 0
@State private var selection = 1

var dismiss: () -> Void = {}

var body: some View {
ZStack(alignment: .bottomLeading) {
RiveExplorerBridge(
controller: riveController
)
VStack {
HStack(alignment: .center, spacing: 50) {
Menu {
ForEach(riveController.artboardNames(), id: \.self) { name in
Button {
riveController.activeArtboard = name
} label: {
Text(name)
}
}
} label: {
Text("Artboards")
Image(systemName: "square.and.pencil")
}
Menu {
ForEach(riveController.animationNames(), id: \.self) { name in
Button {
riveController.playAnimation = name
} label: {
Text(name)
}
}
} label: {
Text("Animations")
Image(systemName: "list.and.film")
}
}
.padding()
HStack(alignment: .center, spacing: 50) {
Menu {
Button {
riveController.fit = .fitContain
} label: {
Text("Contain")
}
Button {
riveController.fit = .fitCover
} label: {
Text("Cover")
}
Button {
riveController.fit = .fitFill
} label: {
Text("Fill")
}
} label: {
Text("Fit")
Image(systemName: "crop")
}
Menu {
Button {
riveController.alignment = .alignmentTopLeft
} label: {
Text("Top Left")
}
Button {
riveController.alignment = .alignmentTopCenter
} label: {
Text("Top Center")
}
Button {
riveController.alignment = .alignmentTopRight
} label: {
Text("Top Right")
}
Button {
riveController.alignment = .alignmentCenterLeft
} label: {
Text("Left")
}
Button {
riveController.alignment = .alignmentCenter
} label: {
Text("Center")
}
Button {
riveController.alignment = .alignmentCenterRight
} label: {
Text("Right")
}
Button {
riveController.alignment = .alignmentBottomLeft
} label: {
Text("Bottom Left")
}
Button {
riveController.alignment = .alignmentBottomCenter
} label: {
Text("Bottom Center")
}
Button {
riveController.alignment = .alignmentBottomRight
} label: {
Text("Bottom Right")
}
} label: {
Text("Alignment")
Image(systemName: "square.dashed")
}
}
.padding()
HStack {
Button {
if riveController.playback == Playback.play {
riveController.pause()
} else {
riveController.play()
}
} label: {
switch riveController.playback {
case .play:
Image(systemName: "pause.circle")
Text("Pause")
case .pause, .stop:
Image(systemName: "play.circle")
Text("Play")
@unknown default:
fatalError("Unknown playback value")
}


}
Spacer()
Button {

dismiss()
} label: {
Image(systemName: "x.circle")
Text("Dismiss")
}

// Button(action: dismiss, label: {
//import SwiftUI
//import RiveRuntime
//
//struct RiveExplorer: DismissableView {
// @ObservedObject private var riveController = RiveExplorerController(
// "artboard_animations",
// fit: Fit.fitCover
// )
// @State private var loopCount: Int = 0
// @State private var selection = 1
//
// var dismiss: () -> Void = {}
//
// var body: some View {
// ZStack(alignment: .bottomLeading) {
// RiveExplorerBridge(
// controller: riveController
// )
// VStack {
// HStack(alignment: .center, spacing: 50) {
// Menu {
// ForEach(riveController.artboardNames(), id: \.self) { name in
// Button {
// riveController.activeArtboard = name
// } label: {
// Text(name)
// }
// }
// } label: {
// Text("Artboards")
// Image(systemName: "square.and.pencil")
// }
// Menu {
// ForEach(riveController.animationNames(), id: \.self) { name in
// Button {
// riveController.playAnimation = name
// } label: {
// Text(name)
// }
// }
// } label: {
// Text("Animations")
// Image(systemName: "list.and.film")
// }
// }
// .padding()
// HStack(alignment: .center, spacing: 50) {
// Menu {
// Button {
// riveController.fit = .fitContain
// } label: {
// Text("Contain")
// }
// Button {
// riveController.fit = .fitCover
// } label: {
// Text("Cover")
// }
// Button {
// riveController.fit = .fitFill
// } label: {
// Text("Fill")
// }
// } label: {
// Text("Fit")
// Image(systemName: "crop")
// }
// Menu {
// Button {
// riveController.alignment = .alignmentTopLeft
// } label: {
// Text("Top Left")
// }
// Button {
// riveController.alignment = .alignmentTopCenter
// } label: {
// Text("Top Center")
// }
// Button {
// riveController.alignment = .alignmentTopRight
// } label: {
// Text("Top Right")
// }
// Button {
// riveController.alignment = .alignmentCenterLeft
// } label: {
// Text("Left")
// }
// Button {
// riveController.alignment = .alignmentCenter
// } label: {
// Text("Center")
// }
// Button {
// riveController.alignment = .alignmentCenterRight
// } label: {
// Text("Right")
// }
// Button {
// riveController.alignment = .alignmentBottomLeft
// } label: {
// Text("Bottom Left")
// }
// Button {
// riveController.alignment = .alignmentBottomCenter
// } label: {
// Text("Bottom Center")
// }
// Button {
// riveController.alignment = .alignmentBottomRight
// } label: {
// Text("Bottom Right")
// }
// } label: {
// Text("Alignment")
// Image(systemName: "square.dashed")
// }
// }
// .padding()
// HStack {
// Button {
// if riveController.playback == Playback.play {
// riveController.pause()
// } else {
// riveController.play()
// }
// } label: {
// switch riveController.playback {
// case .play:
// Image(systemName: "pause.circle")
// Text("Pause")
// case .pause, .stop:
// Image(systemName: "play.circle")
// Text("Play")
// @unknown default:
// fatalError("Unknown playback value")
// }
//
//
// }
// Spacer()
// Button {
//
// dismiss()
// } label: {
// Image(systemName: "x.circle")
// Text("Dismiss")
// })
}
.padding()
}
.background(Color.init(white: 0, opacity: 0.75))
}
}
}

struct RiveSwiftUIView_Previews: PreviewProvider {
static var previews: some View {
RiveExplorer()
}
}
// }
//
//// Button(action: dismiss, label: {
//// Image(systemName: "x.circle")
//// Text("Dismiss")
//// })
// }
// .padding()
// }
// .background(Color.init(white: 0, opacity: 0.75))
// }
// }
//}
//
//struct RiveSwiftUIView_Previews: PreviewProvider {
// static var previews: some View {
// RiveExplorer()
// }
//}
Loading

0 comments on commit a456f48

Please sign in to comment.