Trên GitHub, calimarkus/JDStatusBarNotification đã đạt 4.3k sao, nhóm Mobile, ngôn ngữ Swift. Highly customizable & feature rich notifications. Interactive dismiss. Custom Views. SwiftUI. Tap-to-hold. Progress. Written in Swift, compatible for ObjC!
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Highly customizable & feature rich notifications displayed below the status bar / notch / Island. Written in Swift, compatible for Obj-C! Please open a Github issue, if you think anything is missing or wrong.
Customizable colors, fonts & animations with multiple built-in styles
Interactive & interuptable Drag-to-Dismiss
Adaptive, dynamic layout
Built-in pill-style or full-width layouts
Pill width matches the presented text (customizable)
Works on notch and no-notch devices
Works in landscape & portrait
Built-in features (automatic layout):
Title, subtitle and left-hand-views (e.g. Icons)
An activity indicator
A progress bar
Custom views (UIView or SwiftUI View)
Some examples of the possibilities - the pill style is the default:
Full-Width styles in action - the above pill style supports the same features and animations:
Copy the JDStatusBarNotification/JDStatusBarNotification folder into your project.
Documentation
Find the class documentation hosted on Github.
Changelog
See CHANGELOG.md
Getting started
All examples here are written in Swift. But everything can be called from Objective-C too. Also checkout the example project, which has many examples and includes a convenient style editor to build a custom style.
SwiftUI state-driven presentation
Showing a simple text notification
var body: some View {
Button("Present/dismiss") {
isPresented.toggle()
}
.notification(title: "Hello World", isPresented: $isPresented)
}
Showing a styled notification with subtitle, activity and/or progress
var body: some View {
Button("Present/dismiss") {
isPresented.toggle()
}
.notification(title: "A text",
subtitle: "with a little subtitle.",
isPresented: $isPresented,
isShowingActivity: $activity, // toggles an activity indicator on/off
progress: $progress, // sets the percentage of a progress bar
includedStyle: .success) // picks a predefined style
}
Showing a custom view as notification
var body: some View {
Button("Present/dismiss") {
isPresented.toggle()
}
.notification(isPresented: $isPresented) {
Text("👋 Hi there!")
.font(.subheadline)
.foregroundStyle(.white)
}
}
Manual presentation (from Swift or ObjC)
Showing a text notification
NotificationPresenter.shared.present("Hello World")
// with completion
NotificationPresenter.shared.present("Hello World") { presenter in
// ...
}
Dismissing a notification
NotificationPresenter.shared.dismiss()
// with completion
NotificationPresenter.shared.dismiss(after: 0.5) { presenter in
// ...
}
NotificationPresenter.shared.present("Animating Progress…") { presenter in
presenter.animateProgressBar(to: 1.0, duration: 0.75) { presenter in
presenter.dismiss()
}
}
// or set an explicit percentage manually (without animation)
NotificationPresenter.shared.displayProgressBar(at: 0.0)
Using other included styles
There's a few included styles you can easily use with the following API:
NotificationPresenter.shared.present("Yay, it works!",
includedStyle: .success)
Showing a custom SwiftUI view (Swift only)
NotificationPresenter.shared.presentSwiftView {
Text("Hi from Swift!")
}
// with completion
NotificationPresenter.shared.presentSwiftView {
Text("Hi from Swift!")
} completion: { presenter in
// ...
}
Using a custom UIView (Swift or ObjC)
If you want full control over the notification content and styling, you can use your own custom UIView.
// present a custom view
let button = UIButton(type: .system, primaryAction: UIAction { _ in
NotificationPresenter.shared.dismiss()
})
button.setTitle("Dismiss!", for: .normal)
NotificationPresenter.shared.presentCustomView(button)
Light Mode
Dark Mode
Customization
You have the option to easily create & use fully customized styles.
From SwiftUI
Modify the style in a NotificationStyleClosure:
var body: some View {
Button("Present/dismiss") {
isPresented.toggle()
}
.notification(isPresented: $isPresented, style: {
let s = $0.backgroundStyle
s.backgroundColor = .black
s.pillStyle.minimumWidth = 150
s.pillStyle.height = 44
}) {
Text("👋 Hi there!")
.font(.subheadline)
.foregroundStyle(.white)
}
}
Manually
The PrepareStyleClosure provides a copy of the default style, which can then be modified. See the StatusBarNotificationStyle API for all options.
// update default style
NotificationPresenter.shared.updateDefaultStyle { style in
style.backgroundStyle.backgroundColor = .red
style.textStyle.textColor = .white
style.textStyle.font = UIFont.preferredFont(forTextStyle: .title3)
// and many more options
return style
}
// set a named custom style
NotificationPresenter.shared.addStyle(named: "xxx") { style in
// ...
return style
}
Style Editor
Or checkout the example project, which contains a full style editor. You can tweak all customization options within the app, see the changes live and even export the configuration code for the newly created style to easily use it in your app.
Background Styles
There's two supported StatusBarNotificationBackgroundType's:
enum {
/// The background is a floating pill around the text.
/// The pill size and appearance can be customized. This is the default.
.pill,
/// The background covers the full display width and the full status bar + navbar height.
.fullWidth
}
Animation Types
The supported StatusBarNotificationAnimationType's:
enum {
/// Slide in from the top of the screen and slide
/// back out to the top. This is the default.
.move,
/// Fade-in and fade-out in place. No movement animation.
.fade,
/// Fall down from the top and bounce a little bit, before
/// coming to a rest. Slides back out to the top.
.bounce
}
Troubleshooting
No notifications are showing up
If your app uses a UIWindowScene the NotificationPresenter needs to know about it before you present any notifications.
The library attempts to find the correct WindowScene automatically, but that might fail. If it fails no notifications will show up at all. You can explicitly set the window scene to resolve this:
calimarkus/JDStatusBarNotification có bao nhiêu sao?
calimarkus/JDStatusBarNotification có 4.3k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/calimarkus/JDStatusBarNotification. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
calimarkus/JDStatusBarNotification có những chủ đề gì?
calimarkus/JDStatusBarNotification có trang demo không?
Dự án có trang chủ ở http://calimarkus.github.io/JDStatusBarNotification/documentation/jdstatusbarnotification. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
calimarkus/JDStatusBarNotification còn đang phát triển không?
Commit gần nhất trên calimarkus/JDStatusBarNotification là 1.7 năm trước (theo timestamp GitHub). Repo có 564 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
calimarkus/JDStatusBarNotification dùng license gì?
calimarkus/JDStatusBarNotification phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
calimarkus/JDStatusBarNotification viết bằng ngôn ngữ gì?
calimarkus/JDStatusBarNotification chủ yếu viết bằng Swift. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc thêm về calimarkus/JDStatusBarNotification ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/calimarkus/JDStatusBarNotification là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về JDStatusBarNotification?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về JDStatusBarNotification.