SwiftUISkeleton gives easy way to animate loading of SwiftUI View.
Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler. Once you have your Swift package set up, adding SwiftUISkeleton
as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/serbats/SwiftUISkeleton.git", .branch("master"))
]
import SwiftUI
import SwiftUISkeleton
struct UsersView: View {
@State var users: [String] = []
var body: some View {
VStack {
Text("Test1")
.font(.system(size: 15, weight: .bold))
.skeleton(with: self.users.isEmpty)
SkeletonForEach( self.users, quantity: 2 ) { user in
Text(user ?? "Test2")
.font(.system(size: 55, weight: .bold))
.skeleton(with: self.users.isEmpty,
shape: RoundedRectangle(cornerRadius: 15),
animation: Animation.linear(duration: 1).repeatForever(autoreverses: true),
gradient: Gradient(colors: [.blue, .yellow, .red, .blue]))
}
Text("Test3")
.skeleton(with: self.users.isEmpty,
shape: RoundedRectangle(cornerRadius: 8))
Text("Test4")
.skeleton(with: self.users.isEmpty,
shape: Rectangle(),
gradient: Gradient(colors: [.red, .black, .white, .black, .red]))
Button("fade") {
withAnimation(.easeInOut) {
if self.users.isEmpty {
self.users = ["John Doe",
"Jane Doe",
"James Doe",
"Judy Doe"]
} else {
self.users = []
}
}
}
}
}
}
SwiftUISkeleton is owned and maintained by email.
SwiftUISkeleton is released under the MIT license. See LICENSE for details.
link |
Stars: 6 |
Last commit: 3 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics