Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Apr 24, 2024
1 parent a35c4d1 commit f8bd773
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 156 deletions.
4 changes: 0 additions & 4 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
A954CAF7297553B8008C1E41 /* SystemNotification in Frameworks */ = {isa = PBXBuildFile; productRef = A954CAF6297553B8008C1E41 /* SystemNotification */; };
A954CAF9297689A4008C1E41 /* SilentModeBell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A954CAF8297689A4008C1E41 /* SilentModeBell.swift */; };
A95F1E562975412D00383605 /* DemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95F1E552975412D00383605 /* DemoApp.swift */; };
A95F1E582975412D00383605 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95F1E572975412D00383605 /* ContentView.swift */; };
A95F1E5A2975412E00383605 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A95F1E592975412E00383605 /* Assets.xcassets */; };
Expand All @@ -19,7 +18,6 @@

/* Begin PBXFileReference section */
A954CAF52975533E008C1E41 /* systemnotification */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = systemnotification; path = ..; sourceTree = "<group>"; };
A954CAF8297689A4008C1E41 /* SilentModeBell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SilentModeBell.swift; sourceTree = "<group>"; };
A95F1E522975412D00383605 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
A95F1E552975412D00383605 /* DemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoApp.swift; sourceTree = "<group>"; };
A95F1E572975412D00383605 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -67,7 +65,6 @@
A95F1E7129754BB400383605 /* Supporting Files */,
A95F1E572975412D00383605 /* ContentView.swift */,
A95F1E552975412D00383605 /* DemoApp.swift */,
A954CAF8297689A4008C1E41 /* SilentModeBell.swift */,
A95F1E5C2975412E00383605 /* Preview Content */,
);
path = Demo;
Expand Down Expand Up @@ -193,7 +190,6 @@
A95F1E582975412D00383605 /* ContentView.swift in Sources */,
A95F1E562975412D00383605 /* DemoApp.swift in Sources */,
A95F1E6E29754B2A00383605 /* Image+Demo.swift in Sources */,
A954CAF9297689A4008C1E41 /* SilentModeBell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
81 changes: 34 additions & 47 deletions Demo/Demo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ struct ContentView: View {
Toggle(isOn: $isSilentModeOn) {
label(.silentModeOff, "Toggle.SilentMode")
}
// listItem(.globe, "Show localized notification", presentLocalized)
listItem(.warning, "Menu.Warning", presentWarning)
listItem(.flag, "Menu.LocalizedMessage", presentLocalizedMessage)
listItem(.static, "Menu.CustomView", presentCustomView)
}
Section("Section.Predefined") {
listItem(.error, "Menu.Error", presentError)
listItem(.success, "Menu.Success", presentSuccess)
listItem(.warning, "Menu.Warning", presentWarning)
}
Section("Section.Toasts") {
listItem(.sheet, "Menu.BottomToast", presentBottomToast)
// listItem(.error, "Show red error from bottom", presentError)
// listItem(.flag, "Show custom view", presentCustomView)

}
// Section(header: Text("Non-dismissing notifications")) {
// listItem(.static, "Show non-dismissing notification", presentStaticNotification)
// }
Section("Section.Modals") {
listItem(.sheet, "Menu.Sheet", presentModalSheet)
listItem(.cover, "Menu.Cover", presentModalCover)
Expand All @@ -101,14 +102,7 @@ struct ContentView: View {
#endif
.systemNotification(toast)
.systemNotificationConfiguration(.standardToast)

.onChange(of: isSilentModeOn) {
if $0 {
presentSilentModeOn()
} else {
presentSilentModeOff()
}
}
.onChange(of: isSilentModeOn) { _ in presentSilentMode() }
}
}

Expand Down Expand Up @@ -162,15 +156,9 @@ private extension ContentView {
toast.present {
SystemNotificationMessage(
title: "Message.Toast.Title",
text: "Message.Toast.Text"
text: "Message.Toast.Text",
style: .prominent(backgroundColor: .black)
)
.systemNotificationMessageStyle(
.init(
backgroundColor: .black,
padding: .init(width: 30, height: 20)
)
)
.environment(\.colorScheme, .dark)
}
}

Expand All @@ -180,6 +168,15 @@ private extension ContentView {
)
}

func presentError() {
notification.presentMessage(
.error(
title: "Message.Error.Title",
text: "Message.Error.Text"
)
)
}

func presentLocalizedMessage() {
notification.present(
SystemNotificationMessage(
Expand All @@ -198,37 +195,27 @@ private extension ContentView {
isSheetActive = true
}

func presentSilentModeOff() {
notification.present {
SystemNotificationMessage(
icon: SilentModeBell(isSilentModeOn: false),
text: "Silent Mode Off"
)
}
func presentSilentMode() {
notification.presentMessage(
.silentMode(on: isSilentModeOn)
)
}

func presentSilentModeOn() {
notification.present {
SystemNotificationMessage(
icon: SilentModeBell(isSilentModeOn: true),
text: "Silent Mode On"
func presentSuccess() {
notification.presentMessage(
.success(
title: "Message.Success.Title",
text: "Message.Success.Text"
)
}
)
}

func presentWarning() {
notification.present(
SystemNotificationMessage(
icon: Image.warning,
notification.presentMessage(
.warning(
title: "Message.Warning.Title",
text: "Message.Warning.Text"
)
.systemNotificationMessageStyle(
.init(
backgroundColor: .orange,
foregroundColor: .white
)
)
)
}
}
Expand Down
89 changes: 80 additions & 9 deletions Demo/Demo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"strings" : {
"🇸🇪" : {

},
"Ding!" : {

},
"Dismiss" : {
"localizations" : {
Expand Down Expand Up @@ -47,6 +44,16 @@
}
}
},
"Menu.Error" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Present an error message"
}
}
}
},
"Menu.LocalizedMessage" : {
"localizations" : {
"en" : {
Expand All @@ -67,12 +74,42 @@
}
}
},
"Menu.Success" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Present a success message"
}
}
}
},
"Menu.Warning" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Present an orange warning"
"value" : "Present a warning"
}
}
}
},
"Message.Error.Text" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Something went wrong"
}
}
}
},
"Message.Error.Title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Error!"
}
}
}
Expand All @@ -97,12 +134,32 @@
}
}
},
"Message.Success.Text" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "This was a big success"
}
}
}
},
"Message.Success.Title" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Yay!"
}
}
}
},
"Message.Toast.Text" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "This toast is presented from the bottom, and styled a bit."
"value" : "This black toast is presented from the bottom"
}
}
}
Expand Down Expand Up @@ -157,11 +214,25 @@
}
}
},
"Silent Mode Off" : {

"Section.Predefined" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Predefined message types"
}
}
}
},
"Silent Mode On" : {

"Section.Toasts" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Toasts"
}
}
}
},
"SystemNotification" : {

Expand Down
1 change: 1 addition & 0 deletions Demo/Demo/Resources/Image+Demo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ extension Image {
static let silentModeOff = Image(systemName: "bell.fill")
static let silentModeOn = Image(systemName: "bell.slash.fill")
static let `static` = Image(systemName: "viewfinder")
static let success = Image(systemName: "checkmark")
static let warning = Image(systemName: "exclamationmark.triangle")
}
94 changes: 0 additions & 94 deletions Demo/Demo/SilentModeBell.swift

This file was deleted.

Loading

0 comments on commit f8bd773

Please sign in to comment.