Giter Site home page Giter Site logo

ivanvorobei / spindicator Goto Github PK

View Code? Open in Web Editor NEW
759.0 9.0 46.0 6.52 MB

Floating indicator, mimicrate to indicator which appear when silent mode switched. Can be present from top and bottom. Interactive with gesters.

Home Page: https://opensource.ivanvorobei.io

License: MIT License

Swift 99.04% Ruby 0.96%
uikit apple interface ui animation swift xcode alert banner popover

spindicator's Introduction

SPIndicator

Mimicrate for the indicator which appears when silent mode is turned on / off. Availabe 2 animated presets: done & error. Also supports custom images and presentations from top, center & bottom sides.

To get an alert like in Apple music, use this library instead SPAlert.

Navigate

Installation

Ready for use on iOS 12+ & tvOS 12+.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ivanvorobei/SPIndicator", .upToNextMajor(from: "1.6.0"))
]

CocoaPods:

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'SPIndicator'

Manually

If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/SPIndicator folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

Quick Start

For best experience, I recommend presenting indicator by calling the class functions SPIndicator. These functions are updated regularly and show the indicator as Apple way:

// Presets:
SPIndicator.present(title: "Error", message: "Try Again", preset: .error)

// For show with custom image:
let image = UIImage.init(systemName: "sun.min.fill")!.withTintColor(.systemYellow, renderingMode: .alwaysOriginal)
SPIndicator.present(title: "Custom Image", message: "With tint color", preset: .custom(image))

// For show text only:
SPIndicator.present(title: "Error", haptic: .error)

Usage

Duration

To change the presentation duration time, create the indicator view and call the method present with a custom duration:

let indicatorView = SPIndicatorView(title: "Complete", preset: .done)
indicatorView.present(duration: 3)

Layout

To customise the layout & margins use the layout property. You can manage margins for each side, icon size and space between image and titles:

indicatorView.layout.iconSize = .init(width: 24, height: 24)
indicatorView.layout.margins.top = 12

Dismiss by Drag

By default, you can drag the indicator to hide it. While the indicator is dragging, dismiss is not working. This behaviour can be disabled:

indicatorView.dismissByDrag = false

Haptic

To manage haptics, you shoud pass it in present method:

indicatorView.present(duration: 1.5, haptic: .success, completion: nil)

You can remove the duration and completion parameters from the init. They have default values.

Present Side

You can change the presentation side:

SPIndicator.present(title: "Error", message: "Try Again", preset: .error, from: .bottom)

// or for custom `SPIndicatorView`

indicatorView.presentSide = .bottom

In the case from above, the indicator will appear from bottom and will be attached to bottom. To manage the offset - check the property offset.

Shared Configuration

Also, you can change some default values for the alerts. For example, you can change the default duration for an alert with this code:

SPIndicatorView.appearance().duration = 2

It will apply for all alerts. I recommend to set it in app delegate, but you can change it in runtime.

SwiftUI

Use like system alert only show message tips:

Button("Show Indicator") {
    showIndicator = true
}.SPIndicator(isPresent: $showIndicator, title: "This is title only")

or show message, title, image and other configuration:

Button("Show Indicator") {
    showIndicator = true
}.SPIndicator(
    isPresent: $showIndicator, 
    title: "Title", 
    message: "Message",
    duration: 2.0, 
    presentSide: .top,
    dismissByDrag: false, 
    preset: .custom(UIImage(systemName: "heart")!), 
    haptic: .success, 
    layout: .init(), 
    completion: {
        print("Indicator is destoryed")
    })

Russian Community

Я веду телеграм-канал, там публикую новости и туториалы.
С проблемой помогут в чате.

Видео-туториалы выклыдываю на YouTube:

Tutorials on YouTube

spindicator's People

Contributors

angcosmin avatar ivanvorobei avatar konekoya avatar nandorojo avatar olegtatarciuc avatar snnafi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spindicator's Issues

Send custom width value

Feature Description

I would like to be able to increase or decrease the width of my toast, not sure of how much effort it might take, but I can take a look and work in it if it's possible :)
image

Multiline Message

Feature Description
Currently, the behavior for long messages is to truncate the text to fit on one line. I believe it would make more sense for the view to increase in height based on the dimensions of its contents to allow for more lines of the message text to show. In order to maintain backwards compatibility, I think the default number of lines for the message should be 1, and the container should expand when the number of lines is modified to be greater than 1 (and has multiple lines).

From what I can tell, areaHeight is currently constant and only used in one place. With some preliminary testing, it seems increasing this value here increase the size of the container, so I image one could just measure the height of the children instead of using areaHeight.

[Feature Request] Progress Indicator

Is it possible to make it a progress indicator?

Put a UIActivityIndicatorView at the icon and provide a call back like

SPIndicator.presentProgress(message: "Hello") { completion in
    // do some work
    Backend.shared.load()
    // when done
    completion.send()
}

Problem when the view has a AVPlayerViewController

Details

  • iOS Version: 16.1.1
  • Framework Version: Branch Main
  • Installed via SPM

I'm trying to create a list of videos, each entry has a video player but using the library AZVideoPlayer for fullscreen and PiP support

There's a issue where the HUD goes under the notch

I was able to find out that the problem probably lies in the AVPlayerViewController, I tried to implement a simpler version of the video player with the AVPlayerViewController and got the same result, no issues when using the native VideoPlayer

RPReplay_Final1668563545.mov

It's a bit hard to get a idea with the screen grab but the toast should cover the "Feed" word completely

I added the SPIndicator on the topmost view to see if it would helped but it doesn't

Example project provided is not running

Details

  • iOS Version [15.3]
  • Xcode version [13.2]
  • Downloaded from github

Screenshot 2022-02-02 at 6 12 53 PM

Describe the Bug
Example project provided is not running, giving compile time errors as shown in the screen shot

Improve Visibility

It would be useful to be able to customise the shadow and borders of the alert in order to improve its visibility above a white background because now it's barely noticeble

Something like this :
shadow( x : _ y : _ color : _ )
borders( width : _ color : _ )

Warning Preset

Feature Description
It would be great to also have a predefined Warning Preset next to Success and Error.
The color should probably be yellow and you could use the "exclamationmark" SF Symbol as its Image.

It's difficult to implement it by myself, since there is no API for animating the Image like with the other two Presets I suppose.

didn't present

Describe the bug
didn't present the indicatorView
To Reproduce

import SPIndicator

class ViewController: UIViewController {

    let indicatorView = SPIndicatorView(title: "wow", message: "succ")

    override func viewDidLoad() {
        super.viewDidLoad()
        indicatorView.layout.iconSize = .init(width: 24, height: 24)
        indicatorView.layout.margins.top = 20
        indicatorView.dismissByDrag = true
        indicatorView.present()
    }

Smartphone (please complete the following information):

  • iOS Version = 14
  • SPIndicator` version = 1.1.5
  • Installed via [e.g. SPM, Cocoapods, Manually] = cocapods

Drag functionality is broken.

Details

  • iOS Version 15.2.1
  • Framework Version 1.6.3
  • Installed via SPM

Describe the Bug
The drag & drop functionality is broken. The indicator view in not being dragged. It just jumps and it is not following the finger around.

'shared' is unavailable in application extensions for iOS

Describe the bug
SPIndicator doesn't compile on XCode 13b3
7 Points of failure.

To Reproduce
Build / Run Project with SPIndicator SPM.

Expected behavior
Build successfully.

Screenshots
Screen Shot 2021-07-22 at 11 32 53 AM

Smartphone (please complete the following information):

  • iOS Version: 15.0 B3
  • SPIndicator version: 1.2.3
  • Installed via SPM

Additional context
XCode 13b3 no longer supports shared in application extensions
Possible fix: https://twitter.com/twannl/status/1415643870512226307

Icon color customization

Feature Description
It would be great to have an option to customize an icon's color for .done case.

tvos support

SPIndicator is wanderful in iOS but i can‘t display it on tvOS however in cocoaspod it support tvOS
anyway thanks for your working on SPIndicator

Using on macCatalyst

First of all, thank you so much for this library. It really is super helpful and awesome. I can't wait to fully integrate it into my project.

One thing I noticed is that on macCatalyst, the display position and animation can be a bit wonky. For example, it seems that when displayed at the top of the screen, there is no padding and so it is against the top toolbar of the Mac application. Furthermore, the animation is choppy on Mac for some reason and the SPIndicator tends to flicker. I don't have this issue at all with SPAlert.

Can you have a look? Thank you. :)

Dynamic island

Hi,
very beautiful library! Great job!
I've a question: is possible to add the support with the new iPhone 14 Pro dynamic island when present the indicator from the top?

Indicator is showing up many more times than one

Details

  • iOS Version 16.0 beta 3
  • Framework Version 1.6.4
  • Installed via Manually

Describe the Bug
As soon as the Indicator got fired one time, anything you do on the UI triggers many more times.

RPReplay_Final1657907183.mov

Custom corner radius.

Hi.
I must say, this is a very cool Toast pod, but it lacks more customization options.
The one thing I am missing right now is the custom corner radius for the background view.
I hope you can add it as soon as possible.

Cheers! 👋

Tuist fetch

Details

  • iOS Version 15.0
  • Framework Version 1.6.4
  • Installed via SPM

Describe the Bug
Error when insert dependencies via SPM and Tuist

We received an error that we couldn't handle:
    - Localized description: The data couldn’t be read because it is missing.
    - Error: keyNotFound(CodingKeys(stringValue: "name", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "targets", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "settings", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"name\", intValue: nil) (\"name\").", underlyingError: nil))

Appear on bottom instead of top

Hi,

This is a nice library. Thanks.

Can you add position featured, like appear on bottom or center instead of only top?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.