-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b89fd4c
commit 2a5bb7c
Showing
7 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Created by Jesse Squires | ||
// https://www.jessesquires.com | ||
// | ||
// Documentation | ||
// https://jessesquires.github.io/ReactiveCollectionsKit | ||
// | ||
// GitHub | ||
// https://github.com/jessesquires/ReactiveCollectionsKit | ||
// | ||
// Copyright © 2019-present Jesse Squires | ||
// | ||
|
||
import Foundation | ||
import ReactiveCollectionsKit | ||
import UIKit | ||
|
||
let sharedEmptyViewProvider = EmptyViewProvider { | ||
if #available(iOS 17.0, *) { | ||
var config = UIContentUnavailableConfiguration.empty() | ||
config.text = "No Content" | ||
config.secondaryText = "The list is empty! Nothing to see here." | ||
config.image = UIImage(systemName: "exclamationmark.triangle.fill") | ||
var background = UIBackgroundConfiguration.clear() | ||
background.backgroundColor = .tertiarySystemBackground | ||
config.background = background | ||
return UIContentUnavailableView(configuration: config) | ||
} | ||
|
||
let label = UILabel() | ||
label.text = "No Content" | ||
label.font = UIFont.preferredFont(forTextStyle: .title1) | ||
label.textAlignment = .center | ||
label.backgroundColor = .secondarySystemBackground | ||
return label | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Created by Jesse Squires | ||
// https://www.jessesquires.com | ||
// | ||
// Documentation | ||
// https://jessesquires.github.io/ReactiveCollectionsKit | ||
// | ||
// GitHub | ||
// https://github.com/jessesquires/ReactiveCollectionsKit | ||
// | ||
// Copyright © 2019-present Jesse Squires | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
/// Provides an "empty state" or "no content" view for a collection view. | ||
public struct EmptyViewProvider { | ||
|
||
/// A closure that returns the view. | ||
public let viewBuilder: () -> UIView | ||
|
||
/// The empty view. | ||
public var view: UIView { | ||
viewBuilder() | ||
} | ||
|
||
/// Initializes an `EmptyViewProvider` with the given closure. | ||
/// | ||
/// - Parameter viewBuilder: A closure that creates and returns the empty view. | ||
public init(_ viewBuilder: @escaping () -> UIView) { | ||
self.viewBuilder = viewBuilder | ||
} | ||
} |