Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularize #42

Merged
merged 3 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example-iOS/Source/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wKB-YJ-GTX">
<rect key="frame" x="0.0" y="458" width="414" height="44"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Animation: Rotate 90" lineBreakMode="wordWrap" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iMa-Yv-xPk">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Animation: Rotate 90" lineBreakMode="wordWrap" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iMa-Yv-xPk">
<rect key="frame" x="0.0" y="0.0" width="83" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
Expand Down Expand Up @@ -461,7 +461,7 @@
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YoR-no-Lrc">
<rect key="frame" x="0.0" y="546" width="414" height="44"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Animation: Ping Pong Ltr" lineBreakMode="characterWrap" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HkQ-5L-2wi">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Animation: Ping Pong Ltr" lineBreakMode="characterWrap" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HkQ-5L-2wi">
<rect key="frame" x="0.0" y="0.0" width="83" height="44"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
Expand Down
26 changes: 13 additions & 13 deletions Example-iOS/Source/SwiftUI/ExampleUIRiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RiveRuntime
struct ExampleUIRiveView: View {
@ObservedObject private var riveController = RiveController(
"artboard_animations",
fit: Fit.cover
fit: Fit.fitCover
)
@State private var loopCount: Int = 0
@State private var selection = 1
Expand Down Expand Up @@ -50,17 +50,17 @@ struct ExampleUIRiveView: View {
if #available(iOS 14.0, *) {
Menu {
Button {
riveController.fit = .contain
riveController.fit = .fitContain
} label: {
Text("Contain")
}
Button {
riveController.fit = Fit.cover
riveController.fit = .fitCover
} label: {
Text("Cover")
}
Button {
riveController.fit = Fit.fill
riveController.fit = .fitFill
} label: {
Text("Fill")
}
Expand All @@ -70,47 +70,47 @@ struct ExampleUIRiveView: View {
}
Menu {
Button {
riveController.alignment = .topLeft
riveController.alignment = .alignmentTopLeft
} label: {
Text("Top Left")
}
Button {
riveController.alignment = .topCenter
riveController.alignment = .alignmentTopCenter
} label: {
Text("Top Center")
}
Button {
riveController.alignment = .topRight
riveController.alignment = .alignmentTopRight
} label: {
Text("Top Right")
}
Button {
riveController.alignment = .centerLeft
riveController.alignment = .alignmentCenterLeft
} label: {
Text("Left")
}
Button {
riveController.alignment = .center
riveController.alignment = .alignmentCenter
} label: {
Text("Center")
}
Button {
riveController.alignment = .centerRight
riveController.alignment = .alignmentCenterRight
} label: {
Text("Right")
}
Button {
riveController.alignment = .bottomLeft
riveController.alignment = .alignmentBottomLeft
} label: {
Text("Bottom Left")
}
Button {
riveController.alignment = .bottomCenter
riveController.alignment = .alignmentBottomCenter
} label: {
Text("Bottom Center")
}
Button {
riveController.alignment = .bottomRight
riveController.alignment = .alignmentBottomRight
} label: {
Text("Bottom Right")
}
Expand Down
2 changes: 1 addition & 1 deletion Example-iOS/Source/SwiftUI/RiveButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct RiveButton: View {
var action: (() -> Void)? = nil

var body: some View {
RiveButtonBridge(resource: resource, fit: .cover, play: $play)
RiveButtonBridge(resource: resource, fit: .fitCover, play: $play)
.frame(width: 100, height: 20)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.onTapGesture {
Expand Down
4 changes: 2 additions & 2 deletions Example-iOS/Source/SwiftUI/RiveButtonBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import RiveRuntime

struct RiveButtonBridge: UIViewRepresentable {
let resource: String
var fit: Fit = .contain
var alignment: RiveRuntime.Alignment = .center
var fit: Fit = .fitContain
var alignment: RiveRuntime.Alignment = .alignmentCenter
var artboard: String? = nil
var animation: String? = nil

Expand Down
2 changes: 1 addition & 1 deletion Example-iOS/Source/SwiftUI/RiveSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct RiveSwitch: View {
var action: ((Bool) -> Void)? = nil

var body: some View {
RiveSwitchBridge(resource: resource, fit: .cover, switchToOn: $switchToOn, switchToOff: $switchToOff)
RiveSwitchBridge(resource: resource, fit: .fitCover, switchToOn: $switchToOn, switchToOff: $switchToOff)
.frame(width: 100, height: 50)
.onTapGesture {
switchToOn = false
Expand Down
4 changes: 2 additions & 2 deletions Example-iOS/Source/SwiftUI/RiveSwitchBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import RiveRuntime

struct RiveSwitchBridge: UIViewRepresentable {
let resource: String
var fit: Fit = .contain
var alignment: RiveRuntime.Alignment = .center
var fit: Fit = .fitContain
var alignment: RiveRuntime.Alignment = .alignmentCenter
var artboard: String? = nil
var onAnimation: String = "On"
var offAnimation: String = "Off"
Expand Down
4 changes: 2 additions & 2 deletions Example-iOS/Source/SwiftUI/RiveViewWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class RiveController: ObservableObject {

init(
_ resource: String,
fit: Fit = Fit.contain,
alignment: RiveRuntime.Alignment = .center,
fit: Fit = .fitContain,
alignment: RiveRuntime.Alignment = .alignmentCenter,
autoplay: Bool = false,
playAnimation: String? = nil
) {
Expand Down
40 changes: 20 additions & 20 deletions Example-iOS/Source/UIkit/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,51 @@ class LayoutViewController: UIViewController {
layoutView.riveView.configure(getRiveFile(resourceName: resourceName))

func setFit(name:String) {
var fit: Fit = .contain
var fit: Fit = .fitContain
switch name {
case "Fill":
fit = .fill
fit = .fitFill
case "Contain":
fit = .contain
fit = .fitContain
case "Cover":
fit = .cover
fit = .fitCover
case "Fit Width":
fit = .fitWidth
fit = .fitFitWidth
case "Fit Height":
fit = .fitHeight
fit = .fitFitHeight
case "Scale Down":
fit = .scaleDown
fit = .fitScaleDown
case "None":
fit = .none
fit = .fitNone
default:
fit = .contain
fit = .fitContain
}
layoutView.riveView.fit = fit
}

func setAlignmnet(name:String) {
var alignment: Alignment = .center
var alignment: Alignment = .alignmentCenter
switch name {
case "Top Left":
alignment = .topLeft
alignment = .alignmentTopLeft
case "Top Center":
alignment = .topCenter
alignment = .alignmentTopCenter
case "Top Right":
alignment = .topRight
alignment = .alignmentTopRight
case "Center Left":
alignment = .centerLeft
alignment = .alignmentCenterLeft
case "Center":
alignment = .center
alignment = .alignmentCenter
case "Center Right":
alignment = .centerRight
alignment = .alignmentCenterRight
case "Bottom Left":
alignment = .bottomLeft
alignment = .alignmentBottomLeft
case "Bottom Center":
alignment = .bottomCenter
alignment = .alignmentBottomCenter
case "Bottom Right":
alignment = .bottomRight
alignment = .alignmentBottomRight
default:
alignment = .center
alignment = .alignmentCenter
}
layoutView.riveView.alignment = alignment
}
Expand Down
Loading