Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

This package contains a bundle of Indicators purely written in SwiftUI.

License

Notifications You must be signed in to change notification settings

marlokessler/SwiftUI-Indicators

Repository files navigation

Indicators

This package contains a bundle of Indicators purely written in SwiftUI.

The different Indicators

Getting Started

Swift Package Manager

To get started, add the package dependency via the Swift package manager. Therefore, open your project in Xcode. In the menu select File>Swift Packages>Add Dependency.

Click on Add Dependency.

Then search for Indicators and choose SwiftUI-Indicators from Connapptivity.

Select SwiftUI-Indicators from Connapptivity.

Now choose the version you want to add and the target and click Finish to import the package. Finally you should see it in the project navigator under Swift Pakckage Dependencies.

You can see the package in the navigator.

CocoaPods

Alternatively, you can use cocoapods. Just add

pod 'Indicators'

to your podfile.

For using Indicators in your code just add the import Indicators statement at the top of your swift code file.

General

Indicator Types

This package contains six indicator types and seven different indicators. Available indicators are

Success indicators:

SuccessIndcator()

Failure indicators:

FailureIndcator()

Info indicators:

InfoIndcator()

Waiting Indcators:

CircularWaitingIndcator()

LinearWaitingIndcator()

Progress indcators:

CircularProgressIndcator()

LinearProgressIndcator()

Customization

Every indicator can be customized in several ways:

Indicator()

// Set a custom foregroundcolor.
.foregoundColor(Color?)

// Set a custom linewidth.
.lineWidth(Double)

// Set the animation pace of the indicator.
.pace(Double)

// Set if indicator changes should be animated. The default value is true.
.animated(Bool = true)

// Set your custom animation to the indicator
.animation(Animation?)

The waiting and progress indicators can be additionally customized. To check out these options have a look at the documentation below.

Show Text with Waiting and Progress Indicators

You have the possibility to show text with waiting and progress indicators. The text can be declared directly in the initializer:

WaitingIndicator(Double, text: String?)

ProgressIndicator(Double, text: String?)

With circular indicators the text resizes automatically according to the size of the indicator. The indicator always trys to show the whole text and prevent coverage.

The text resizes automatically.

With linear indicators the text does not resize automatically. Here you can adjust the font according to your needs.

LinearIndicator()
    .font(Font?)

The indicators bottom is aligned to the text base, so the design looks always good.

The indicators bottom is aligned to the text base.

Change the Background Stroke Color with Progress Indicators

To give users a intuitive feeling of how much a process is progressed in relation to the whole, progress indicators have a background stroke. You can change the stroke color or set it to clear, if you do not want a background stroke.

ProgressIndicator()
    .backgroundColor(Color?)

Custom Indicator

You can also create your custom Indicator by implementing the Indicator protocol.

struct CustomIndicator: Indicator { ...

Contribute to this Package

This package is public, because everybody who wants to contribute should be able to do so. And we belive nothing is as powerful as community development. So, feel free to fork and add your code to this package.

About

This package contains a bundle of Indicators purely written in SwiftUI.

Resources

License

Stars

Watchers

Forks

Packages

No packages published