Compare commits

...

5 Commits

Author SHA1 Message Date
Max Desiatov 3ec087854a
Update comment 2020-08-01 22:35:53 +01:00
Jed Fox 0dab4d8ca0
Stub out a few more methods 2020-08-01 17:35:01 -04:00
Max Desiatov aeff44b320
Fix build errors and formatting 2020-08-01 22:32:41 +01:00
Max Desiatov 0ce484c776
Refine formatting 2020-07-31 23:53:27 +01:00
Max Desiatov 46d50989c8
Add `Animation` and `Transaction` stubs 2020-07-31 23:50:01 +01:00
2 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,105 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
let defaultDuration = 0.35
public struct Animation: Equatable {
static let `default` = Animation()
public func delay(_ delay: Double) -> Animation {
.init()
}
public func speed(_ speed: Double) -> Animation {
.init()
}
public func repeatCount(
_ repeatCount: Int,
autoreverses: Bool = true
) -> Animation {
.init()
}
public func repeatForever(autoreverses: Bool = true) -> Animation {
.init()
}
public static func spring(
response: Double = 0.55,
dampingFraction: Double = 0.825,
blendDuration: Double = 0
) -> Animation {
.init()
}
public static func interactiveSpring(
response: Double = 0.15,
dampingFraction: Double = 0.86,
blendDuration: Double = 0.25
) -> Animation {
.init()
}
public static func interpolatingSpring(
mass: Double = 1.0,
stiffness: Double,
damping: Double,
initialVelocity: Double = 0.0
) -> Animation {
.init()
}
public static func easeInOut(duration: Double) -> Animation {
.init()
}
public static var easeInOut: Animation {
easeInOut(duration: defaultDuration)
}
public static func easeIn(duration: Double) -> Animation {
.init()
}
public static var easeIn: Animation {
easeIn(duration: defaultDuration)
}
public static func easeOut(duration: Double) -> Animation {
.init()
}
public static var easeOut: Animation {
easeOut(duration: defaultDuration)
}
public static func linear(duration: Double) -> Animation {
timingCurve(0, 0, 1, 1, duration: duration)
}
public static var linear: Animation {
timingCurve(0, 0, 1, 1)
}
public static func timingCurve(
_ c0x: Double,
_ c0y: Double,
_ c1x: Double,
_ c1y: Double,
duration: Double = defaultDuration
) -> Animation {
.init()
}
}

View File

@ -0,0 +1,27 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
public struct Transaction {
public var animation: Animation?
/** `true` in the first part of the transition update, this avoids situations when `animation(_:)`
could add more animations to this transaction.
*/
public var disablesAnimations: Bool
public init(animation: Animation?) {
self.animation = animation
disablesAnimations = true
}
}