AnimateText

0.5.0

This library for animating text. Developed with SwiftUI. This library supports iOS/macOS.
jasudev/AnimateText

What's New

0.5.0

2022-02-10T00:17:44Z

AnimateText

This library for animating text. Developed with SwiftUI. This library supports iOS/macOS.

Platforms iOS macOS instagram SPM MIT

Screenshot

AnimateText.mp4

Example

https://fabulaapp.page.link/224

Usages

  1. AnimateText

    /// A view that animates binding text. Passing the effect type as a generic.
    /// struct AnimateText<E> where E : ATTextAnimateEffect
    /// Binding the text to be expressed.
    @State var text: String = "AnimateText"
    
    /// The type used to split text.
    @State var type: ATUnitType = .letters
    
    /// Custom user info for the effect.
    @State var userInfo: Any? = nil
    
    AnimateText<CustomEffect>($text, type: type, userInfo: userInfo)
    
  2. Each effect only needs to conform to the ATTextAnimateEffect protocol.

    /// Custom animation effect.
    public struct CustomEffect: ATTextAnimateEffect {
    
        public var data: ATElementData
        public var userInfo: Any?
    
        public init(_ data: ATElementData, _ userInfo: Any?) {
            self.data = data
            self.userInfo = userInfo
        }
    
        public func body(content: Content) -> some View {
            content
                .opacity(data.value)
                .animation(.easeInOut.delay(Double(data.index) * 0.06), value: data.value)
        }
    }
  3. ATTextAnimateEffect protocol

    /// A protocol to implement text animation effects.
    public protocol ATTextAnimateEffect: ViewModifier {
    
        /// Informational data required for each element animation.
        var data: ATElementData { get }
        /// Custom user info for the effect.
        /// The effect maintains a strong reference to this object until it (the effect) is invalidated. This parameter may be nil.
        var userInfo: Any? { get }
    
        init(_ data: ATElementData, _ userInfo: Any?)
    }
    

Contact

instagram : @dev.fabula
email : dev.fabula@gmail.com

License

AnimateText is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Apr 15 2024 12:44:40 GMT-0900 (Hawaii-Aleutian Daylight Time)