mirror of
https://github.com/rive-app/rive-ios.git
synced 2026-01-18 17:11:28 +01:00
Remade the RSlider to fit anywhere and look more visually congruous with its surroundings
This commit is contained in:
committed by
Zachary Duncan
parent
31948d4942
commit
f2866680c8
BIN
Example-iOS/Assets/riveslider.riv
Normal file
BIN
Example-iOS/Assets/riveslider.riv
Normal file
Binary file not shown.
Binary file not shown.
@@ -52,8 +52,8 @@
|
||||
C324DB5F280740FB0060589F /* rbutton.riv in Resources */ = {isa = PBXBuildFile; fileRef = C324DB5E280740FB0060589F /* rbutton.riv */; };
|
||||
C3460A002800A6CE002DBCB7 /* bird.riv in Resources */ = {isa = PBXBuildFile; fileRef = C34609FD2800A6CE002DBCB7 /* bird.riv */; };
|
||||
C3468E6227FDCBC6008652FD /* SimpleSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3468E6127FDCBC6008652FD /* SimpleSlider.swift */; };
|
||||
C3CDFAB827E445A3005CC341 /* riveslider7.riv in Resources */ = {isa = PBXBuildFile; fileRef = C3CDFAB727E445A3005CC341 /* riveslider7.riv */; };
|
||||
C3D187F3280751A8008B739A /* RProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D187F2280751A8008B739A /* RProgressBar.swift */; };
|
||||
C3D187F728075B6C008B739A /* riveslider.riv in Resources */ = {isa = PBXBuildFile; fileRef = C3D187F628075B6C008B739A /* riveslider.riv */; };
|
||||
C9A84F38264495600014D8E0 /* RiveExplorer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9A84F37264495600014D8E0 /* RiveExplorer.swift */; };
|
||||
C9A84F5E2644A75A0014D8E0 /* ExamplesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9A84F5D2644A75A0014D8E0 /* ExamplesViewController.swift */; };
|
||||
C9A84F602644AB6B0014D8E0 /* RiveExplorerBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9A84F5F2644AB6B0014D8E0 /* RiveExplorerBridge.swift */; };
|
||||
@@ -148,8 +148,8 @@
|
||||
C324DB5E280740FB0060589F /* rbutton.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = rbutton.riv; sourceTree = "<group>"; };
|
||||
C34609FD2800A6CE002DBCB7 /* bird.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = bird.riv; sourceTree = "<group>"; };
|
||||
C3468E6127FDCBC6008652FD /* SimpleSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleSlider.swift; sourceTree = "<group>"; };
|
||||
C3CDFAB727E445A3005CC341 /* riveslider7.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = riveslider7.riv; sourceTree = "<group>"; };
|
||||
C3D187F2280751A8008B739A /* RProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RProgressBar.swift; sourceTree = "<group>"; };
|
||||
C3D187F628075B6C008B739A /* riveslider.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = riveslider.riv; sourceTree = "<group>"; };
|
||||
C9A84F37264495600014D8E0 /* RiveExplorer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RiveExplorer.swift; sourceTree = "<group>"; };
|
||||
C9A84F5D2644A75A0014D8E0 /* ExamplesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExamplesViewController.swift; sourceTree = "<group>"; };
|
||||
C9A84F5F2644AB6B0014D8E0 /* RiveExplorerBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RiveExplorerBridge.swift; sourceTree = "<group>"; };
|
||||
@@ -229,9 +229,9 @@
|
||||
C9696B0E24FC6FD10041502A /* Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3D187F628075B6C008B739A /* riveslider.riv */,
|
||||
C324DB5E280740FB0060589F /* rbutton.riv */,
|
||||
C34609FD2800A6CE002DBCB7 /* bird.riv */,
|
||||
C3CDFAB727E445A3005CC341 /* riveslider7.riv */,
|
||||
0450445E26B3F71E007B25CA /* constrained.riv */,
|
||||
04D5B069266A460C004ACA5B /* nothing.riv */,
|
||||
042C88D42644447500E7DBB2 /* artboard_animations.riv */,
|
||||
@@ -441,6 +441,7 @@
|
||||
C9E040A9264DFCFD009ABC7C /* switch.riv in Resources */,
|
||||
042C88E62644447500E7DBB2 /* artboard_animations.riv in Resources */,
|
||||
042C88E72644447500E7DBB2 /* trailblaze.riv in Resources */,
|
||||
C3D187F728075B6C008B739A /* riveslider.riv in Resources */,
|
||||
042C88E12644447500E7DBB2 /* basketball.riv in Resources */,
|
||||
042C88DE2644447500E7DBB2 /* rope.riv in Resources */,
|
||||
0480028B2729AA4400F7132B /* clean_icon_set.riv in Resources */,
|
||||
@@ -449,7 +450,6 @@
|
||||
042C88DD2644447500E7DBB2 /* ui_swipe_left_to_delete.riv in Resources */,
|
||||
042C88E52644447500E7DBB2 /* explorer.riv in Resources */,
|
||||
042C88E22644447500E7DBB2 /* f22.riv in Resources */,
|
||||
C3CDFAB827E445A3005CC341 /* riveslider7.riv in Resources */,
|
||||
046AFA712673AF04004ED497 /* blendmodes.riv in Resources */,
|
||||
042C88EC2644447500E7DBB2 /* vader.riv in Resources */,
|
||||
C9C73E9E24FC471E00EF9516 /* Assets.xcassets in Resources */,
|
||||
|
||||
@@ -38,26 +38,27 @@ struct RiveComponents: DismissableView {
|
||||
VStack {
|
||||
Text("Bird Animation")
|
||||
bird.view()
|
||||
.aspectRatio(1, contentMode: .fill)
|
||||
.frame(maxWidth: .infinity)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
}
|
||||
|
||||
Spacer().padding()
|
||||
|
||||
HStack {
|
||||
Text("RButton:")
|
||||
RButton().view {
|
||||
print("Button tapped")
|
||||
}
|
||||
}
|
||||
|
||||
Spacer().padding()
|
||||
|
||||
HStack {
|
||||
Text("RSwitch:")
|
||||
rswitch.view { on in
|
||||
print("The switch is " + (on ? "on" : "off"))
|
||||
}
|
||||
}
|
||||
|
||||
Spacer().padding()
|
||||
|
||||
VStack {
|
||||
Text("RProgressBar:")
|
||||
rprogress.formattedView()
|
||||
@@ -73,16 +74,19 @@ struct RiveComponents: DismissableView {
|
||||
), in: 0...100)
|
||||
.padding(.leading).padding(.trailing)
|
||||
}
|
||||
|
||||
Spacer().padding()
|
||||
VStack {
|
||||
|
||||
HStack {
|
||||
Text("RSlider:")
|
||||
rslider.formattedView()
|
||||
.padding()
|
||||
rslider.view()
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,11 @@ class RSlider: RViewModel {
|
||||
}
|
||||
|
||||
init(_ initialProgress: Double = 0) {
|
||||
let model = RModel(fileName: "riveslider7", stateMachineName: "Slide", fit: .fitCover)
|
||||
let model = RModel(fileName: "riveslider", stateMachineName: "Slide", fit: .fitScaleDown)
|
||||
progress = initialProgress
|
||||
super.init(model)
|
||||
}
|
||||
|
||||
func formattedView() -> some View {
|
||||
return super.view()
|
||||
.aspectRatio(2.5, contentMode: .fill)
|
||||
}
|
||||
|
||||
func touchBegan(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) {
|
||||
touchMoved(onArtboard: artboard, atLocation: location)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import SwiftUI
|
||||
import RiveRuntime
|
||||
|
||||
class RSwitch: RViewModel {
|
||||
private let onAnimation: String = "On"
|
||||
private let offAnimation: String = "Off"
|
||||
private let startAnimation: String = "StartOff"
|
||||
|
||||
var action: ((Bool) -> Void)? = nil
|
||||
var isOn = false {
|
||||
didSet {
|
||||
stop()
|
||||
@@ -18,12 +23,6 @@ class RSwitch: RViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
private let onAnimation: String = "On"
|
||||
private let offAnimation: String = "Off"
|
||||
private let startAnimation: String = "StartOff"
|
||||
|
||||
var action: ((Bool) -> Void)? = nil
|
||||
|
||||
convenience init() {
|
||||
self.init(fileName: "switch")
|
||||
fit = .fitCover
|
||||
|
||||
Reference in New Issue
Block a user