A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code.

Overview

SimpleAFLoader

A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI framework.

👍 Animation Speed Control!

🎨 Works with any Color

🧰 Customize Loading text, speed & size

No keyframe animations or DispatchQueue calls that could negatively affect the UI

Source files have no depencendies and can be extracted without issue

Installation

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. To use SimpleAFLoader with Swift Package Manager in an Xcode project:

Usage

Firstly, import the package to your file.

import SimpleAFLoader

After that create a @State variable.

@State private var isLoaderVisible: Bool = false
  1. Then must add a .overlay() modifier to your main SwiftUI Stack view. It can be ZStack, VStack or HStack.
  2. To Show/Hide the view you just have to toggle the value for "showLoader" bool parameter.
  3. Use .disabled() modifier to disable the user interaction while loading. (Optional) Note that if you have multiple overlay then place the LoaderView overlay at the last position.
ZStack {
    //...
}
.overlay(**Put The Loader View Here**)
.disabled(isLoaderVisible)

Complete Representation:

import SwiftUI

struct ContentView: View {
    
    @State private var isLoaderVisible: Bool = false
    
    var body: some View {
        ZStack {
            //...
        }
        .overlay(LoaderView(loaderColor: .red, loaderTextColor: .red, loadingText: "Loading", loaderElementSize: .medium, loaderAnimationSpeed: .medium, showLoader: isLoaderVisible))
        .disabled(isLoaderVisible)
        .onAppear {
            isLoaderVisible.toggle()
        }
    }
}

The indicators are customizable in terms of text, color, size, and speed. All parameters are optional and will init with default values if not included. Example implementations:

// DEFAULT PARAMETERS:

// Text == nil          (Options: "Any Single Line Text")
// Color == .secondary  (Options: Any Color)
// Size == .medium      (Options: .small, .medium, .large)
// Speed == .medium     (Options: .low, .medium, .high)

// Use 1:
.overlay(LoaderView(showLoader: isLoaderVisible))
        
// Use 2:
.overlay(LoaderView(loadingText: "Loading", showLoader: isLoaderVisible))
        
// Use 3:
.overlay(LoaderView(loaderColor: .red, loaderTextColor: .red, loadingText: "Loading", showLoader: isLoaderVisible))
        
// Use 4:
.overlay(LoaderView(loaderColor: .green, loaderTextColor: .green, loadingText: "Loading", loaderElementSize: .medium, showLoader: isLoaderVisible))
        
// Use 5:
.overlay(LoaderView(loaderColor: .orange, loaderTextColor: .orange, loadingText: "Loading", loaderElementSize: .large, loaderAnimationSpeed: .high, showLoader: isLoaderVisible))

Supported Platforms:

  • .iOS(.v14) and +

Please Leave a star if you like SimpleAFLoader

You might also like...
Library for creating swipe actions for any SwiftUI View

SwipeActions Library for creating swipe actions for any SwiftUI View, similar to

Shimmer: A super-light modifier that adds a shimmering effect to any SwiftUI View
Shimmer: A super-light modifier that adds a shimmering effect to any SwiftUI View

SwiftUI-Shimmer ✨ Shimmer is a super-light modifier that adds a shimmering effec

An easy way to add a simple, shimmering effect to any view in an iOS app.
An easy way to add a simple, shimmering effect to any view in an iOS app.

Shimmer Shimmer is an easy way to add a shimmering effect to any view in your app. It's useful as an unobtrusive loading indicator. Shimmer was origin

ChainPageCollectionView  A custom View with two level chained collection views and fancy transition animation
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.
MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.

MGFlipView About If you are looking for an easy way of implement 3D flipping view, you are in the right place. MGFlipView allows to create flipping vi

Design-system-demo - This example code is bare-bones to show you what this framework can do

Basic Style Dictionary This example code is bare-bones to show you what this fra

☠️SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading animations.
☠️SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading animations.

SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading animations. Get rid of loading screens or spinners and start using skeletons to represent final content shapes.

Create a smooth transition between any two SwiftUI Views
Create a smooth transition between any two SwiftUI Views

GZMatchedTransformEffect Create a smooth transition between any two SwiftUI Views. It is very similar to the built-in .matchedGeometryEffect() modifie

Comments
  • Couple of things...

    Couple of things...

    This kinds of needs to have some service that can be injected into the environment to drive the overlay. The problem is that busy/loading spinners also need to cover the navigation bar so the user can't interrupt the process. And that means that the view that triggers the overlay isn't usually the view in which the overlay actually resides.

    good first issue 
    opened by hmlongco 1
Releases(v.1.0.0)
Owner
Fahim Rahman
A conscious machine who loves meme, programming, and cooking and is a few inches away from discovering a time portal.
Fahim Rahman
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Jogendra 1.4k Jan 6, 2023
BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous loading of images, animation, custom is very high.

BWMCoverView BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous l

Bi Weiming 31 Mar 10, 2021
Allows a swipe on any part of the screen to start an interruptible pop animation to the previous view

Lazy Pop SwiftUI Swiping on any part of the screen starts an interruptible pop animation to the previous view. Forked from https://github.com/rishi420

Joe Hinkle 150 Dec 18, 2022
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
Lightweight Swift loading activity for iOS7+

EZLoadingActivity Lightweight Swift loading activity for iOS7+. Really simple to use, just add the class and write 1 line of code. Easy to use: EZLoad

Goktug Yilmaz 611 Dec 22, 2022
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces

ADPuzzleAnimation Whats inside Custom animation for UIView inspired by Fabric - Answers animation. Easy to use To create your first animation you need

Anton 126 Dec 25, 2022
Lightweight animation library for UIKit

MotionAnimation Lightweight animation library for UIKit in Swift Checkout the Examples folder for more. Consider MotionAnimation as a extremely simpli

Luke Zhao 145 May 28, 2022