sparrowcode / alertkit Goto Github PK
View Code? Open in Web Editor NEWNative alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.
Home Page: https://sparrowcode.io/frameworks
License: MIT License
Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.
Home Page: https://sparrowcode.io/frameworks
License: MIT License
Details
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
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
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.
Hi,
This project is beautiful and clean just love it.
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()
}
}
```
Consider adding self.commonInit() in public func present() { } this will resolve the problem.
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
Can I join?
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
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
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
Feature Description
Add support for macOS platform
AlertKitAPI.present(
title: "...",
icon: AlertIcon.spinnerSmall,
style: .iOS17AppleMusic,
haptic: AlertHaptic.none
)
This is very nice library but would like to have completion handler once animation done.
as well would be great if it has buttons in the alert to handle some actions
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
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
Expected behavior
No error like in Xcode 12.
Smartphone (please complete the following information):
SPAlert
version 3.2.4When an alert is tapable, add a small "navigation" arrow type thing. And make a tap function for when an alert is tapped.
Pretty easy.
Given my view
import SwiftUI
import AlertKit
struct CreateRewardView: View {
@StateObject var viewModel: CreateRewardViewModel = CreateRewardViewModel()
@Environment(\.dismiss) private var dismiss
var body: some View {
VStack {
...
}
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Save", action: {
Task {
await viewModel.save()
dismiss()
}
})
}
}
.alert(isPresent: $viewModel.showCreatedAlert, view: viewModel.createdAlert)
}
}
When the user clicks on "Save" button I showCreatedAlert
becomes true
so the alert is shown.
The problem is that a strange behavior happens when dismiss
is triggered. The alert appears/disappears multiple times. Am I doing something wrong?
Hey! Just wanted to share that I wrapped this library (and SPIndicator
) for React Native. I'd never used Swift before.
You can see it here: https://github.com/nandorojo/burnt
And I wrote about it here: https://twitter.com/FernandoTheRojo/status/1592923529644625920
Thanks for the great library!
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.
Can you add it like this? Let's close it when we want to. Thank you
The alerts are so cool! Does there any plan to support watchOS? I really need it!
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.
Thank you for the amazing work you've done.
I would like to suggest two important preset:
Cross
Warning
Thanks again
Are there any plans for custom styles?
I'd apperciate a way to change alert size, corner radius, position, background color, border color, etc..
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 :)
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.
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!
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
)
In some cases, I need to use dark style alerts. How can I enable this?
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.
Свободу попугаям и любителям тёмной темы!!!
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)
}
})
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.