Skip to content

Commit

Permalink
make examples independent of each other + some rephrasing
Browse files Browse the repository at this point in the history
  • Loading branch information
calimarkus committed Mar 28, 2024
1 parent f513e10 commit 866d730
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions ExampleProject/ExamplesScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct ExamplesScreen: View {
@State var backgroundType: StatusBarNotificationBackgroundType = .pill

func showDefaultNotification(_ text: String, completion: @escaping (NotificationPresenter) -> ()) {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "default_sample") { style in
style.backgroundStyle.backgroundType = backgroundType
return style
}
Expand All @@ -45,7 +45,7 @@ struct ExamplesScreen: View {
}

func showIncludedStyle(_ text: String, style: IncludedStatusBarNotificationStyle) {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: style) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "incl_style", usingStyle: style) { style in
style.backgroundStyle.backgroundType = backgroundType
return style
}
Expand Down Expand Up @@ -78,7 +78,7 @@ struct ExamplesScreen: View {
}

Section("Settings") {
Text("These settings can be toggled before and during presentation of below examples.")
Text("These settings affect the presentation of all below examples.")
.font(.caption)
.foregroundStyle(.secondary)

Expand All @@ -95,7 +95,7 @@ struct ExamplesScreen: View {
.onChange(of: showActivity) { _ in
if !NotificationPresenter.shared.isVisible {
if showActivity {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "activity") { style in
style.backgroundStyle.backgroundType = backgroundType
style.backgroundStyle.pillStyle.minimumWidth = 0.0
return style
Expand Down Expand Up @@ -150,12 +150,12 @@ struct ExamplesScreen: View {
}

Section("SwiftUI Examples") {
Text("These ignore above settings except the Background Type.")
Text("These SwiftUI examples ignore above subtitle, activity and progress bar settings.")
.font(.caption)
.foregroundStyle(.secondary)

cell(title: "Simple text", subtitle: "Display a SwiftUI text, 2.5s") {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "swiftui") { style in
style.backgroundStyle.backgroundType = backgroundType
style.backgroundStyle.backgroundColor = .systemMint
style.backgroundStyle.pillStyle.minimumWidth = 20.0
Expand All @@ -173,7 +173,7 @@ struct ExamplesScreen: View {
}

cell(title: "Two row layout + Icon", subtitle: "Display SwiftUI text & image, 2.5s") {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "swiftui") { style in
style.backgroundStyle.backgroundType = backgroundType
style.backgroundStyle.backgroundColor = .systemIndigo
style.backgroundStyle.pillStyle.minimumWidth = 20.0
Expand Down Expand Up @@ -211,7 +211,7 @@ struct ExamplesScreen: View {

if #available(iOS 16.0, *) { // Gradient is iOS 16+
cell(title: "Gradient & Icon", subtitle: "A custom SwiftUI background, 2.5s") {
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "gradient") { style in
style.backgroundStyle.backgroundType = backgroundType
style.backgroundStyle.backgroundColor = UIColor(.orange)
style.backgroundStyle.pillStyle.minimumWidth = 20.0
Expand Down Expand Up @@ -246,7 +246,7 @@ struct ExamplesScreen: View {
}

Section("Custom Style Examples") {
Text("These include a progress bar animation.")
Text("These examples showcase a progress bar animation and multiple animation types.")
.font(.caption)
.foregroundStyle(.secondary)

Expand All @@ -266,15 +266,15 @@ struct ExamplesScreen: View {
button.setTitle("Dismiss!", for: .normal)

// present
let styleName = NotificationPresenter.shared.addStyle(named: "tmp", usingStyle: .defaultStyle) { style in
let styleName = NotificationPresenter.shared.addStyle(named: "button") { style in
style.backgroundStyle.backgroundType = backgroundType
style.canTapToHold = false // this ensure the button can receive touches
return style
}
NotificationPresenter.shared.presentCustomView(button, styleName: styleName)
}

cell(title: "Present custom left icon", subtitle: "A custom left view, 2.5s") {
cell(title: "Present a custom left icon", subtitle: "A custom left view, 2.5s") {
// create icon
let image = UIImageView(image: UIImage(systemName: "gamecontroller.fill"))

Expand Down

0 comments on commit 866d730

Please sign in to comment.