Giter Site home page Giter Site logo

sparrowcode / alertkit Goto Github PK

View Code? Open in Web Editor NEW
2.3K 15.0 128.0 10.82 MB

Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.

Home Page: https://sparrowcode.io/frameworks

License: MIT License

Ruby 1.62% Swift 98.38%
alert popup swift apple native applemusic appstore feedback animated ui

alertkit's Introduction

AlertKit

Popup from Apple Music & Feedback in AppStore. Contains Done, Heart, Error and other. Supports Dark Mode. I tried to recreate Apple's alerts as much as possible. You can find these alerts in the AppStore after feedback and after you add a song to your library in Apple Music.

Alert Kit v5

For UIKit & SwiftUI call this:

AlertKitAPI.present(
    title: "Added to Library",
    icon: .done,
    style: .iOS17AppleMusic,
    haptic: .success
)

Available 2 styles:

public enum AlertViewStyle {

    case iOS16AppleMusic
    case iOS17AppleMusic
}

iOS Dev Community

Navigate

Installation

Ready to use on iOS 13+. Supports iOS and visionOS. Working with UIKit and SwiftUI.

Swift Package Manager

In Xcode go to Project -> Your Project Name -> Package Dependencies -> Tap Plus. Insert url:

https://github.com/sparrowcode/AlertKit

or adding it to the dependencies of your Package.swift:

dependencies: [
    .package(url: "https://github.com/sparrowcode/AlertKit", .upToNextMajor(from: "5.1.8"))
]

CocoaPods:

This is an outdated way of doing things. I advise you to use SPM. However, I will continue to support Cocoapods for some time.

Cocoapods Instalation

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

pod 'SPAlert'

Manually

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

SwiftUI

You can use basic way via AlertKitAPI or call via modifier:

let alertView = AlertAppleMusic17View(title: "Hello", subtitle: nil, icon: .done)

VStack {}
    .alert(isPresent: $alertPresented, view: alertView)

Customisation

If you need customisation fonts, icon, colors or any other, make view:

let alertView = AlertAppleMusic17View(title: "Added to Library", subtitle: nil, icon: .done)

// change font
alertView.titleLabel.font = UIFont.systemFont(ofSize: 21)
// change color
alertView.titleLabel.textColor = .white

Present & Dismiss

You can present and dismiss alerts manually via view.

let alertView = AlertAppleMusic17View(title: "Added to Library", subtitle: nil, icon: .done)

// present
alertView.present(on: self)
// and dismiss
alertView.dismiss()

For dismiss all alerts that was presented:

AlertKitAPI.dismissAllAlerts()

Apps Using

If you use a AlertKit, add your app via Pull Request.

alertkit's People

Contributors

alpaycli avatar aniltaskiran avatar erjanmx avatar honqii avatar itsliamdowd avatar ivanvorobei avatar jillevdw avatar leeceny avatar nikolajjsj avatar romanpodymov avatar shakhrayv avatar swifthing avatar tijme 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  avatar  avatar  avatar  avatar  avatar  avatar

alertkit's Issues

Force dark mode

In some cases, I need to use dark style alerts. How can I enable this?

Build failures: Likely regression in recent commit

Hello from React Native land! I'm crawling up from a distant dependency on this package (see initial author post in #45 ) which recently seems to have broken due to a change in AlertKit.

I found this issue while trying to build using Expo, which is a React Native build service for anyone not familiar. Specifically, in the step in which it runs Fastlane. The issue started around Oct 14, 2023 5:16 PM EST, which seems to line up with the timing and contents of 0bc23a5.

The full error message refers to AlertAppleMusic16View.swift and AlertAppleMusic17View.swift.

❌  (/Users/expo/workingdir/build/react-native-app/ios/Pods/SPAlert/Sources/AlertKit/Views/AlertAppleMusic16View.swift:19:5)

  17 |         default: UIColor(red: 88 / 255, green: 87 / 255, blue: 88 / 255, alpha: 1)
  18 |         }
> 19 |     }
     |     ^ missing return in closure expected to return 'UIColor'
  20 |     
  21 |     fileprivate weak var viewForPresent: UIView?
  22 |     fileprivate var presentDismissDuration: TimeInterval = 0.2

❌  (/Users/expo/workingdir/build/react-native-app/ios/Pods/SPAlert/Sources/AlertKit/Views/AlertAppleMusic17View.swift:19:5)

  17 |         default: UIColor(red: 88 / 255, green: 87 / 255, blue: 88 / 255, alpha: 1)
  18 |         }
> 19 |     }
     |     ^ missing return in closure expected to return 'UIColor'
  20 |     
  21 |     fileprivate weak var viewForPresent: UIView?
  22 |     fileprivate var presentDismissDuration: TimeInterval = 0.2

Removing the package resolves the build issues. Unfortunately I'm not familiar enough with Swift build systems to debug with any more granularity.

If it helps, the build was run using XCode 14.13.1, fastlane 2.213.0, CocoaPods 1.12.1, and Ruby 2.7.

Dark Theme

Свободу попугаям и любителям тёмной темы!!!

Color for icon in SwiftUI

Is your feature request related to a problem? Please describe.
Please add custom color support to icons in SwiftUI.

Describe the solution you'd like
Something, where you can define the color of the .error icon animation. It would be pretty nice!

DismissByTap always true

Hi

alertView.dismissByTap = false

return always true

this is my code (I call in a function)

   `let alertView = SPAlertView(title: "Hi", message: "Hi")

    alertView.dismissByTap = false

    alertView.duration = 3

    alertView.haptic = .success 

    alertView.present()`

Any suggestion?

Thanks

layout.bottomSpace no longer accessible

Hi, why is the following property no longer accessible?

alertView.layout.bottomSpace = UIScreen.main.bounds.height
alertView.layout.topSpace = UIScreen.main.bounds.height

so I could have it displayed very well in full screen above everything.

Thanks

AlertView: change frame to all screen

Hi, one more thing,

is possible to set the frame alertView to all screen. UIScreen.main.bounds.height and width, in order to cover also navbar and tab bar?

i'm trying but i can't do it.

thank you

Alert appears behind keyboard if the keyboard is open.

I'm using SPAlert in a passcode view. Whenever a user enters an incorrect password, SPAlert will show an alert message with an icon. However, the alert appears partly behind the keyboard that is open.

Is there any layout option that resolves this?

Version in use: 1.1.1

Xcode 13 beta 3: 'shared' is unavailable in application extensions for iOS

Describe the bug
The package won't compile in latest Xcode 13.0 beta 3 using SPM. It seems that the latest compiler requires us to mark present(...) as @available(iOSApplicationExtension, unavailable) explicitly since UIApplication.shared is unavailable in extension target. Even though we don't have any extension target.

// SPAlertView.swift

    open func present(duration: TimeInterval = SPAlertConfiguration.duration, haptic: SPAlertHaptic = .success, completion: (() -> Void)? = nil) {
        
        if self.presentWindow == nil {
            self.presentWindow = UIApplication.shared.keyWindow // <=== 👀 Error: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.... 'shared' has been explicitly marked unavailable here (UIKit.UIApplication)
        }
        
        guard let window = self.presentWindow else { return }
        
        window.addSubview(self)
        
        // Prepare for present
        // ...
        

To Reproduce

  1. Create a new iOS project in Xcode, and add SPAlert in Package Dependencies.
  2. Add SPAlert library to iOS target.
  3. Compile.

Expected behavior
No error like in Xcode 12.

Smartphone (please complete the following information):

  • Xcode version 13.0 beta 3
  • SPAlert version 3.2.4
  • Installed via SPM

SPAlert hiding or dismissing instantly in some views. Maybe due to a UITextView

A workaround that help me was:

    self.perform(#selector(self.showSaveCompleted), with: nil, afterDelay: 1)
    

    @objc func showSaveCompleted() {
        DispatchQueue.main.async {
        
            let alertView = SPAlertView(title: "Title.", message: "Message.", preset: SPAlertPreset.done)
            alertView.duration = 3
            alertView.dismissByTap = true
            alertView.present()
        }
    }
    ```

New logo/icon proposal

Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks

Feature Request

Hi,

Don't know if possible, but can you add and loader to your library?

Seems like this library is the only one that is working with Swift UI

I needed to add a delegate or a completionHandler for when animation is done

Hi,

Very nice library, I was just a bit suprised because the library didn't have a delegate that is triggered when the animation is complete. I am hoping something like this could be added so I can integrate the library using Swift Package Manager.

    /**
     Use this method for force dismiss controller. By default it call automatically.
     */
    @objc public func dismiss() {
        UIView.animate(withDuration: 0.2, animations: {
            self.alpha = 0
            self.transform = self.transform.scaledBy(x: 0.8, y: 0.8)
        }, completion: { finished in
            self.delegate?.didFinishAnimation()
            self.removeFromSuperview()
        })
    }

or adding a completionHandler
    public func present(completionHandler: @escaping (() -> Void)) {
        haptic.impact()
        keyWindow.addSubview(self)
        layoutIfNeeded()
        layoutSubviews()
        alpha = 0
        transform = transform.scaledBy(x: 0.8, y: 0.8)

        UIView.animate(withDuration: 0.2, animations: {
            self.alpha = 1
            self.transform = CGAffineTransform.identity
        }, completion: { _ in
            if let iconView = self.iconView as? SPAlertIconAnimatable {
                iconView.animate()
            }
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + self.duration) {
                self.dismiss(completionHandler: completionHandler)
            }
        })
    }

Set dismissByTap to false is not working

Describe the bug
tapGesterRecognizer is initialized before dismissByTap is set to false.

To Reproduce

let alertView = SPAlertView(title: "", preset: .spinner) // tapGesture is added to view
alertView.dismissByTap = false // will not work
alertView.present()

CleanShot 2021-11-30 at 19 54 21

watchOS Support

The alerts are so cool! Does there any plan to support watchOS? I really need it!

How to Dismiss this?

AlertKitAPI.present(
title: "...",
icon: AlertIcon.spinnerSmall,
style: .iOS17AppleMusic,
haptic: AlertHaptic.none
)

Change size of alert

Is there any way that I can change the size of alert. Currently it's too big and I couldn't find any way to reduce the it.

Content color is not always correct for Dark Mode.

Details

  • iOS Version 13+
  • Framework Version 4.2.0
  • Installed via SPM

Describe the Bug
Content color is not always correct for Dark Mode.

Reason
When initiating the view, defaultContentColor is called from the initializer, looking for a window to get the traitCollection.
As the window is not defined yet, nil is returned, and lightColor will always be in use.

Solution for iOS 13+ only
Use UIColor.init(dynamicProvider: _)

I'll make a PR about that.
EDIT: opened #44

I don't know yet how to fix it for iOS 12.x

Request to add support for macOS app

Thank you for creating such a useful library. However, it appears that it only supports UIKit at the moment. It would be great if it could also support AppKit.

Dark Mode Not Working in iOS 13

I'm using SPAlert in an app that has iOS 13 as the minimum target but in both light & dark modes on device, the alert always uses light mode.

More Preset

Thank you for the amazing work you've done.

I would like to suggest two important preset:

  • Cross

  • Warning

Thanks again

Custom styles

Are there any plans for custom styles?
I'd apperciate a way to change alert size, corner radius, position, background color, border color, etc..

Feature request

Hi,
This project is beautiful and clean just love it.

I am not sure if this possible for this project but here is the list of a few features I would love to have in this Project.

  1. More Position for Alert.
  2. allow color Image.
  3. Allow custom color for the text.

Add abillity to control alert duration

It would be neat if it was possible to specify the duration of the the alert when presenting it. Right now the duration property is only available in the view, and not the AlertKitAPI wrapping class.

Context:

AlertKitAPI.present(
    title: "Oops",
    subtitle: error?.localizedDescription,
    icon: .error,
    style: .iOS17AppleMusic,
    haptic: .error
)

Is it possible that we can display things other than images inside the alert?

Hi @ivanvorobei

I'm trying to use this SPAlert to display a loading indicator, but for now, it only accepts a couple of default presets and a custom UIImage. Is there any changes that we could pass something like
CAShapeLayer in it? For example https://github.com/relatedcode/ProgressHUD/blob/master/ProgressHUD/Sources/ProgressHUD.swift#L743-L785

I know I can probably address this with a custom loading image. But with so many different screen resolutions, I'm not sure if it's a good idea to go about :(

Thanks for creating and publishing OSS like this :)

OC

Can I join?

black background blur support

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

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.