-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1879 from ably/ECO-4234
[ECO-4234] Updates Push Example to include Channels
- Loading branch information
Showing
16 changed files
with
397 additions
and
41 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
32 changes: 32 additions & 0 deletions
32
Examples/AblyPush/AblyPushExample/Assets.xcassets/ably-logo.imageset/Contents.json
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,32 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ably-brand-light-mode 1.pdf", | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "light" | ||
} | ||
], | ||
"filename" : "ably-brand-light-mode.pdf", | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"filename" : "ably-brand-dark-mode.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+6.79 KB
...ples/AblyPush/AblyPushExample/Assets.xcassets/ably-logo.imageset/ably-brand-dark-mode.pdf
Binary file not shown.
Binary file added
BIN
+6.79 KB
...s/AblyPush/AblyPushExample/Assets.xcassets/ably-logo.imageset/ably-brand-light-mode 1.pdf
Binary file not shown.
Binary file added
BIN
+6.79 KB
...les/AblyPush/AblyPushExample/Assets.xcassets/ably-logo.imageset/ably-brand-light-mode.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Examples/AblyPush/AblyPushExample/Assets.xcassets/push-disabled.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "push-disabled.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+6.42 KB
Examples/AblyPush/AblyPushExample/Assets.xcassets/push-disabled.imageset/push-disabled.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
Examples/AblyPush/AblyPushExample/Assets.xcassets/push-enabled.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "push-enabled.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+5.96 KB
Examples/AblyPush/AblyPushExample/Assets.xcassets/push-enabled.imageset/push-enabled.pdf
Binary file not shown.
52 changes: 52 additions & 0 deletions
52
Examples/AblyPush/AblyPushExample/Buttons/PushButton.swift
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,52 @@ | ||
import SwiftUI | ||
|
||
struct PushButton: View { | ||
let systemImage: String | ||
let activeTitle: String | ||
let inactiveTitle: String | ||
let action: () -> Void | ||
let isButtonEnabled: Bool // is the button enabled | ||
let isActive: Bool // is the action in it's on or off state | ||
|
||
let activeColor = Color(red: 1.00, green: 0.33, blue: 0.09) | ||
let inActiveColor = Color(red: 0.00, green: 0.56, blue: 0.02) | ||
|
||
init( | ||
isButtonEnabled: Bool, | ||
systemImage: String, | ||
activeTitle: String, | ||
inactiveTitle: String, | ||
isActive: Bool, | ||
action: @escaping () -> Void | ||
) { | ||
self.isButtonEnabled = isButtonEnabled | ||
self.systemImage = systemImage | ||
self.activeTitle = activeTitle | ||
self.inactiveTitle = inactiveTitle | ||
self.isActive = isActive | ||
self.action = action | ||
} | ||
|
||
var body: some View { | ||
let button = Button { | ||
action() // manage the toggling of isActive binding within the action. | ||
} label: { | ||
Label(isActive ? activeTitle : inactiveTitle, | ||
systemImage: systemImage) | ||
.frame(maxWidth: .infinity) | ||
.labelStyle(VerticalLabelStyle()) | ||
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0)) | ||
} | ||
.buttonStyle(.borderedProminent) | ||
.buttonBorderShape(.roundedRectangle) | ||
.tint(isActive ? activeColor : inActiveColor) | ||
.disabled(!isButtonEnabled) | ||
.animation(.easeInOut, value: isButtonEnabled) | ||
|
||
if #available(iOS 17.0, *) { | ||
return button.contentTransition(.symbolEffect(.replace)) | ||
} | ||
|
||
return button | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Examples/AblyPush/AblyPushExample/Buttons/StatelessButton.swift
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,48 @@ | ||
import SwiftUI | ||
|
||
struct StatelessButton: View { | ||
let isButtonEnabled: Bool | ||
let systemImage: String | ||
let title: String | ||
let backgroundColor: Color | ||
let action: () -> Void | ||
|
||
@State var taps: Int = 0 // purely to trigger animation on every tap | ||
|
||
init( | ||
isButtonEnabled: Bool, | ||
systemImage: String, | ||
title: String, | ||
backgroundColor: Color = Color(red: 0.00, green: 0.56, blue: 0.02), | ||
action: @escaping () -> Void | ||
) { | ||
self.isButtonEnabled = isButtonEnabled | ||
self.systemImage = systemImage | ||
self.title = title | ||
self.backgroundColor = backgroundColor | ||
self.action = action | ||
} | ||
|
||
var body: some View { | ||
let button = Button { | ||
action() | ||
taps += 1 | ||
} label: { | ||
Label(title, systemImage: systemImage) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.labelStyle(VerticalLabelStyle()) | ||
.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0)) | ||
} | ||
.buttonStyle(.bordered) | ||
.buttonBorderShape(.roundedRectangle) | ||
.tint(backgroundColor) | ||
.disabled(!isButtonEnabled) | ||
.animation(.easeInOut, value: isButtonEnabled) | ||
|
||
if #available(iOS 17.0, *) { | ||
return button.symbolEffect(.bounce.down, value: taps) | ||
} | ||
|
||
return button | ||
} | ||
} |
Oops, something went wrong.