Skip to content

Add native macOS destination #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Pow Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
546A29D4292A6B1200A80DE2 /* SprayExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 546A29D3292A6B1200A80DE2 /* SprayExample.swift */; };
549BF5F5293642BC00B2DCCF /* SocialFeedExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 549BF5F4293642BC00B2DCCF /* SocialFeedExample.swift */; };
54A962302934CC4400BBD5FE /* GithubButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54A9622F2934CC4400BBD5FE /* GithubButton.swift */; };
54CFF812297EEE220033F113 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54CFF811297EEE220033F113 /* AboutView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -192,6 +193,7 @@
546A29D3292A6B1200A80DE2 /* SprayExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SprayExample.swift; sourceTree = "<group>"; };
549BF5F4293642BC00B2DCCF /* SocialFeedExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialFeedExample.swift; sourceTree = "<group>"; };
54A9622F2934CC4400BBD5FE /* GithubButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubButton.swift; sourceTree = "<group>"; };
54CFF811297EEE220033F113 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
54D37CAD292F9C4A00788E8A /* Pow-Example-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Pow-Example-Info.plist"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -316,6 +318,7 @@
546A29C3292A4B9000A80DE2 /* Transitions */,
546A29C4292A4B9F00A80DE2 /* Change Effects */,
549BF5F6293642BE00B2DCCF /* Screens */,
54CFF811297EEE220033F113 /* AboutView.swift */,
);
path = Examples;
sourceTree = "<group>";
Expand Down Expand Up @@ -502,6 +505,7 @@
files = (
546A298C292A31BB00A80DE2 /* ExampleList.swift in Sources */,
546A29CE292A591F00A80DE2 /* ShineExample.swift in Sources */,
54CFF812297EEE220033F113 /* AboutView.swift in Sources */,
546A29C0292A420F00A80DE2 /* SwooshExample.swift in Sources */,
546A29BA292A40D800A80DE2 /* PoofExample.swift in Sources */,
546A29B2292A3ED800A80DE2 /* GlareExample.swift in Sources */,
Expand Down Expand Up @@ -677,9 +681,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.movingparts.Pow-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -710,9 +718,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.movingparts.Pow-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
65 changes: 32 additions & 33 deletions Pow Example/ExampleList.swift
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
import Pow
import MessageUI
import SwiftUI

struct ExampleList: View {
var body: some View {
List {
#if os(iOS)
Section {
VStack(alignment: .leading, spacing: 12) {
Text("This is the official example app for Pow, the Surprise and Delight framework for SwiftUI.")

Text("Tap the individual examples to see the effects and transitions in action.")

Text("**Note:** While this app requires iOS 16, Pow itself supports iOS 15 and above.")
}
.font(.subheadline.leading(.loose))
.foregroundColor(.primary)

Link(destination: URL(string: "https://movingparts.io/pow")!) {
ViewThatFits {
Label("Pow Website and Licensing Options", systemImage: "safari")
Label("Pow Website & Licensing Options", systemImage: "safari")
Label("Pow Website & Licensing", systemImage: "safari")
Label("Pow Website", systemImage: "safari")
}
}

Link(destination: URL(string: "https://github.com/movingparts-io/Pow-Examples")!) {
ViewThatFits {
Label("GitHub Repository for this App", systemImage: "terminal")
Label("GitHub Repo for this App", systemImage: "terminal")
Label("Repo for this App", systemImage: "terminal")
}
}

if MFMailComposeViewController.canSendMail() {
Link(destination: URL(string: "mailto:[email protected]")!) {
Label("Support", systemImage: "envelope")
}
}
AboutView()
}
#else
NavigationLink("About Pow") {
DecoratedAboutView()
}
#endif

#if os(iOS)
Section {
SocialFeedExample.navigationLink
CheckoutExample.navigationLink
Expand All @@ -48,14 +23,17 @@ struct ExampleList: View {
} footer: {
Text("Pre-composed screens that show how to use Pow in context. Use them as inspiration for your app.")
}
#endif

Section {
JumpExample.navigationLink
PingExample.navigationLink
RiseExample.navigationLink
ShakeExample.navigationLink
ShineExample.navigationLink
#if os(iOS)
SoundEffectExample.navigationLink
#endif
SpinExample.navigationLink
SprayExample.navigationLink
} header: {
Expand Down Expand Up @@ -126,14 +104,35 @@ struct InfoButton<T: Example>: View {
@Environment(\.presentInfoAction)
var presentInfoAction

@State
var isPopoverPresented = false

var body: some View {
#if os(iOS)
if let presentInfoAction {
Button {
presentInfoAction(type)
} label: {
Label("About", systemImage: "info.circle")
}
}
#else
Button {
isPopoverPresented.toggle()
} label: {
Label("About", systemImage: "info.circle")
}
.popover(isPresented: $isPopoverPresented, arrowEdge: .bottom) {
ScrollView {
VStack {
type.erasedDescription
}
.padding()
}
.frame(maxWidth: 500)
}
.help("About")
#endif
}
}

Expand Down
58 changes: 58 additions & 0 deletions Pow Example/Examples/AboutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import SwiftUI

#if os(iOS)
import MessageUI
#endif

struct AboutView: View {
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("This is the official example app for Pow, the Surprise and Delight framework for SwiftUI.")

Text("Tap the individual examples to see the effects and transitions in action.")

Text("**Note:** While this app requires iOS 16, Pow itself supports iOS 15 and above.")
}
#if os(iOS)
.font(.subheadline.leading(.loose))
#endif
.foregroundColor(.primary)

Link(destination: URL(string: "https://movingparts.io/pow")!) {
ViewThatFits {
Label("Pow Website and Licensing Options", systemImage: "safari")
Label("Pow Website & Licensing Options", systemImage: "safari")
Label("Pow Website & Licensing", systemImage: "safari")
Label("Pow Website", systemImage: "safari")
}
}

Link(destination: URL(string: "https://github.com/movingparts-io/Pow-Examples")!) {
ViewThatFits {
Label("GitHub Repository for this App", systemImage: "terminal")
Label("GitHub Repo for this App", systemImage: "terminal")
Label("Repo for this App", systemImage: "terminal")
}
}

#if os(iOS)
if MFMailComposeViewController.canSendMail() {
Link(destination: URL(string: "mailto:[email protected]")!) {
Label("Support", systemImage: "envelope")
}
}
#endif
}
}

struct DecoratedAboutView: View {
var body: some View {
GroupBox {
VStack(alignment: .leading) {
AboutView()
.fixedSize()
}
.padding()
}
}
}
2 changes: 2 additions & 0 deletions Pow Example/Examples/Change Effects/SoundEffectsExample.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if os(iOS)
import Pow
import SwiftUI

Expand Down Expand Up @@ -180,3 +181,4 @@ struct SoundEffectExample_Previews: PreviewProvider {
SoundEffectExample()
}
}
#endif
5 changes: 5 additions & 0 deletions Pow Example/Examples/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct IconView<Content: View>: View {
var colorScheme

var body: some View {
#if os(iOS)
ZStack {
Rectangle()
.fill(.primary)
Expand All @@ -147,6 +148,10 @@ struct IconView<Content: View>: View {
.strokeBorder(.white.opacity(0.1), lineWidth: 0.5)
.blendMode(.plusLighter)
}
#else
content
.symbolRenderingMode(.monochrome)
#endif
}
}

Expand Down
12 changes: 12 additions & 0 deletions Pow Example/Examples/Screens/CheckoutExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,25 @@ struct CheckoutExample: View, Example {
}
.listStyle(.plain)
.navigationTitle("")
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.animation(.default, value: quantity != 0)
.toolbar {
if quantity == 0 {
#if os(iOS)
ToolbarItem(placement: .navigationBarTrailing) {
Button("Undo") {
quantity = 1
}
}
#endif
}
}
#if os(iOS)
.changeEffect(.feedback(SoundEffect("whop")), value: quantity == 0, isEnabled: quantity == 0)
.changeEffect(.feedback(SoundEffect("wip")), value: quantity != 0, isEnabled: quantity != 0)
#endif
.safeAreaInset(edge: .bottom, spacing: 0) {
VStack(spacing: 16) {
VStack(alignment: .leading, spacing: 0) {
Expand Down Expand Up @@ -128,8 +134,10 @@ private struct CartItem: View {
.alignmentGuide(.listRowSeparatorLeading) { dimensions in
dimensions[.leading]
}
#if os(iOS)
.changeEffect(.feedback(SoundEffect("beep")), value: quantity, isEnabled: quantity > lastQuantity && quantity > 1)
.changeEffect(.feedback(SoundEffect("boop")), value: quantity, isEnabled: quantity < lastQuantity && quantity > 0)
#endif
.onChange(of: quantity) { newValue in
lastQuantity = quantity
}
Expand Down Expand Up @@ -222,9 +230,11 @@ struct PayButton: View {
.tint(status == .failed ? .red : status == .succeeded ? .green : nil)
.allowsHitTesting(status == .initial)
.changeEffect(.shake(rate: .fast), value: status == .failed, isEnabled: status == .failed)
#if os(iOS)
.changeEffect(.feedback(SoundEffect("plop")), value: status == .inProgress, isEnabled: status == .inProgress)
.changeEffect(.feedback(SoundEffect("sparkle")), value: status == .succeeded, isEnabled: status == .succeeded)
.changeEffect(.feedback(SoundEffect("notfound")), value: status == .failed, isEnabled: status == .failed)
#endif
}
}

Expand Down Expand Up @@ -269,7 +279,9 @@ struct CheckoutExample_Previews: PreviewProvider {
static var previews: some View {
NavigationStack {
CheckoutExample()
#if os(iOS)
.toolbar(.visible, for: .navigationBar)
#endif
}
}
}
20 changes: 16 additions & 4 deletions Pow Example/Examples/Screens/SocialFeedExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,21 @@ struct SocialFeedExample: View, Example {
.safeAreaInset(edge: .bottom, spacing: 0) {
tabBar
}
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
}

var buttonBar: some View {
HStack(alignment: .firstTextBaseline, spacing: 12) {
#if os(iOS)
let pop = SoundEffect("pop1", "pop2", "pop3", "pop4", "pop5")

let sparkle = SoundEffect(isBoosted ? "sparkle.rising" : "sparkle.falling")

let pick = SoundEffect(isBookmarked ? "pick.rising" : "pick.falling")
#endif

Button {
isLiked.toggle()
} label: {
Expand All @@ -99,9 +107,9 @@ struct SocialFeedExample: View, Example {
}
}
.tint(isLiked ? .red : .gray)
#if os(iOS)
.changeEffect(.feedback(pop), value: isLiked, isEnabled: isLiked)

let sparkle = SoundEffect(isBoosted ? "sparkle.rising" : "sparkle.falling")
#endif

Button {
isBoosted.toggle()
Expand All @@ -125,7 +133,9 @@ struct SocialFeedExample: View, Example {
}
}
.tint(isBoosted ? .green : .gray)
#if os(iOS)
.changeEffect(.feedback(sparkle), value: isBoosted)
#endif

Button {
clapCount += 1
Expand All @@ -150,11 +160,11 @@ struct SocialFeedExample: View, Example {
)
}
}
#if os(iOS)
.changeEffect(.feedback(pop), value: clapCount)
#endif
.tint(clapCount > 202 ? .blue : .gray)

let pick = SoundEffect(isBookmarked ? "pick.rising" : "pick.falling")

Button {
isBookmarked.toggle()
} label: {
Expand All @@ -169,7 +179,9 @@ struct SocialFeedExample: View, Example {
}
.tint(isBookmarked ? .orange : .gray)
.animation(.spring(response: 0.4, dampingFraction: 1), value: isBookmarked)
#if os(iOS)
.changeEffect(.feedback(pick), value: isBookmarked)
#endif
}
}

Expand Down
Loading