From de0c301b9930524407da5a286c3071daae6dcbf6 Mon Sep 17 00:00:00 2001 From: Maegan Wilson Date: Tue, 22 Mar 2022 16:41:12 -0500 Subject: [PATCH] feat: share view --- .../CoffeeTracker.xcodeproj/project.pbxproj | 16 ++++++ .../CoffeeTracker/About/AboutView.swift | 1 + .../About/BuyDevCoffeeSection.swift | 2 +- .../CoffeeTracker/About/ShareApp.swift | 52 +++++++++++++++++++ .../Components/ActivityView.swift | 24 +++++++++ .../Helpers/SFSymbolHelper.swift | 2 +- 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 CoffeeTracker/CoffeeTracker/About/ShareApp.swift create mode 100644 CoffeeTracker/CoffeeTracker/Components/ActivityView.swift diff --git a/CoffeeTracker/CoffeeTracker.xcodeproj/project.pbxproj b/CoffeeTracker/CoffeeTracker.xcodeproj/project.pbxproj index 9e7b6d1..b2c7da9 100644 --- a/CoffeeTracker/CoffeeTracker.xcodeproj/project.pbxproj +++ b/CoffeeTracker/CoffeeTracker.xcodeproj/project.pbxproj @@ -27,9 +27,11 @@ 3782E03527C4AA81000F0404 /* BeansCollectionViewOO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3782E03427C4AA81000F0404 /* BeansCollectionViewOO.swift */; }; 3797E1C427D6A52F000FE457 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3797E1C327D6A52F000FE457 /* View+Extensions.swift */; }; 3797E1C627D6A6F3000FE457 /* Color+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3797E1C527D6A6F3000FE457 /* Color+Extension.swift */; }; + 379E1CBF27E8BF7C004101E0 /* ShareApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 379E1CBE27E8BF7C004101E0 /* ShareApp.swift */; }; 37B776A627C67A6F00EFD566 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37B776A527C67A6F00EFD566 /* CloudKit.framework */; }; 37C9838427E4E4D4007C85E3 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37C9838327E4E4D4007C85E3 /* Constants.swift */; }; 37C9838727E4E5B8007C85E3 /* RevenueCat in Frameworks */ = {isa = PBXBuildFile; productRef = 37C9838627E4E5B8007C85E3 /* RevenueCat */; }; + 37DD41CB27EA789300BEF00A /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37DD41CA27EA789300BEF00A /* ActivityView.swift */; }; 37F18B2827E4C09500F609DF /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37F18B2727E4C09500F609DF /* AboutView.swift */; }; 37F18B2A27E4C15200F609DF /* BuyDevCoffeeSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37F18B2927E4C15200F609DF /* BuyDevCoffeeSection.swift */; }; /* End PBXBuildFile section */ @@ -55,10 +57,12 @@ 3782E03427C4AA81000F0404 /* BeansCollectionViewOO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeansCollectionViewOO.swift; sourceTree = ""; }; 3797E1C327D6A52F000FE457 /* View+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extensions.swift"; sourceTree = ""; }; 3797E1C527D6A6F3000FE457 /* Color+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Extension.swift"; sourceTree = ""; }; + 379E1CBE27E8BF7C004101E0 /* ShareApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareApp.swift; sourceTree = ""; }; 37B776A327C67A6B00EFD566 /* CoffeeTracker.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CoffeeTracker.entitlements; sourceTree = ""; }; 37B776A527C67A6F00EFD566 /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; }; 37B776A727C67A7800EFD566 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 37C9838327E4E4D4007C85E3 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; + 37DD41CA27EA789300BEF00A /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = ""; }; 37F18B2727E4C09500F609DF /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; 37F18B2927E4C15200F609DF /* BuyDevCoffeeSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuyDevCoffeeSection.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -97,6 +101,7 @@ 371E294D27C40D2100C8ACBF /* CoffeeTracker */ = { isa = PBXGroup; children = ( + 37DD41C927EA788100BEF00A /* Components */, 37F18B2627E4C08500F609DF /* About */, 376A5E5127D844BF0038BDA0 /* PhotoPicker */, 37B776A727C67A7800EFD566 /* Info.plist */, @@ -171,12 +176,21 @@ name = Frameworks; sourceTree = ""; }; + 37DD41C927EA788100BEF00A /* Components */ = { + isa = PBXGroup; + children = ( + 37DD41CA27EA789300BEF00A /* ActivityView.swift */, + ); + path = Components; + sourceTree = ""; + }; 37F18B2627E4C08500F609DF /* About */ = { isa = PBXGroup; children = ( 37F18B2727E4C09500F609DF /* AboutView.swift */, 37F18B2927E4C15200F609DF /* BuyDevCoffeeSection.swift */, 3776B9E027E8B3450042C494 /* UserFeedback.swift */, + 379E1CBE27E8BF7C004101E0 /* ShareApp.swift */, ); path = About; sourceTree = ""; @@ -268,7 +282,9 @@ 376A5E5327D844D60038BDA0 /* PhotoPickerView.swift in Sources */, 3782E03527C4AA81000F0404 /* BeansCollectionViewOO.swift in Sources */, 371E296227C40E8800C8ACBF /* CoffeeTrackerMain.swift in Sources */, + 379E1CBF27E8BF7C004101E0 /* ShareApp.swift in Sources */, 371E295127C40D2100C8ACBF /* ContentView.swift in Sources */, + 37DD41CB27EA789300BEF00A /* ActivityView.swift in Sources */, 371E296527C40EC900C8ACBF /* BeanModel.swift in Sources */, 371E295B27C40D2200C8ACBF /* CoffeeTracker.xcdatamodeld in Sources */, 371E296E27C40F9A00C8ACBF /* BeanDetailView.swift in Sources */, diff --git a/CoffeeTracker/CoffeeTracker/About/AboutView.swift b/CoffeeTracker/CoffeeTracker/About/AboutView.swift index 13a669e..3fe147b 100644 --- a/CoffeeTracker/CoffeeTracker/About/AboutView.swift +++ b/CoffeeTracker/CoffeeTracker/About/AboutView.swift @@ -15,6 +15,7 @@ struct AboutView: View { } } + struct AboutView_Previews: PreviewProvider { static var previews: some View { AboutView() diff --git a/CoffeeTracker/CoffeeTracker/About/BuyDevCoffeeSection.swift b/CoffeeTracker/CoffeeTracker/About/BuyDevCoffeeSection.swift index a80f4c3..b1e19ff 100644 --- a/CoffeeTracker/CoffeeTracker/About/BuyDevCoffeeSection.swift +++ b/CoffeeTracker/CoffeeTracker/About/BuyDevCoffeeSection.swift @@ -69,7 +69,7 @@ struct BuyDevCoffeeSection: View { ) .overlay(RoundedRectangle(cornerRadius: 10) .stroke(Color.secondary, lineWidth: 0.5) - .shadow(color: .secondary, radius: 2, x: 0, y: 0)) + .shadow(color: .secondary, radius: 20, x: 0, y: 0)) .onAppear { Purchases.shared.getOfferings { (offerings, error) in if let packages = offerings?.current?.availablePackages { diff --git a/CoffeeTracker/CoffeeTracker/About/ShareApp.swift b/CoffeeTracker/CoffeeTracker/About/ShareApp.swift new file mode 100644 index 0000000..7f0927c --- /dev/null +++ b/CoffeeTracker/CoffeeTracker/About/ShareApp.swift @@ -0,0 +1,52 @@ +// +// ShareApp.swift +// CoffeeTracker +// +// Created by Maegan Wilson on 3/21/22. +// + +import SwiftUI + +struct ShareApp: View { + + @Environment(\.colorScheme) private var colorScheme + @State private var showingSheet = false + + var body: some View { + Button { + showingSheet = true + } label: { + HStack(spacing: 15) { + Image(systemName: SFSymbols.share) + .foregroundColor(.pink) + .font(.system(size: 36)) + Text("Share coffee_ with someone") + .foregroundColor(.primary) + }.frame(maxWidth: .infinity, alignment: .leading) + .padding() + .background( + RoundedRectangle(cornerRadius: 10) + .fill(colorScheme == .light ? .quaternary : .primary) + ) + .overlay(RoundedRectangle(cornerRadius: 10) + .stroke(Color.secondary, lineWidth: 0.5) + .shadow(color: .secondary, radius: 20, x: 0, y: 0)) + } + .sheet(isPresented: $showingSheet) { + ActivityView(activityItems: [NSURL(string: "https://cctplus.dev")!] as [Any], applicationActivities: nil) + } + + } +} + +struct ShareApp_Previews: PreviewProvider { + static var previews: some View { + ZStack { + Image("Background") + .resizable() + .ignoresSafeArea() + ShareApp() + .padding() + } + } +} diff --git a/CoffeeTracker/CoffeeTracker/Components/ActivityView.swift b/CoffeeTracker/CoffeeTracker/Components/ActivityView.swift new file mode 100644 index 0000000..1224fd8 --- /dev/null +++ b/CoffeeTracker/CoffeeTracker/Components/ActivityView.swift @@ -0,0 +1,24 @@ +// +// ActivityView.swift +// CoffeeTracker +// +// Created by Maegan Wilson on 3/22/22. +// + +import SwiftUI + +struct ActivityView: UIViewControllerRepresentable { + + let activityItems: [Any] + let applicationActivities: [UIActivity]? + + func makeUIViewController(context: UIViewControllerRepresentableContext) -> UIActivityViewController { + return UIActivityViewController(activityItems: activityItems, + applicationActivities: applicationActivities) + } + + func updateUIViewController(_ uiViewController: UIActivityViewController, + context: UIViewControllerRepresentableContext) { + + } +} diff --git a/CoffeeTracker/CoffeeTracker/Helpers/SFSymbolHelper.swift b/CoffeeTracker/CoffeeTracker/Helpers/SFSymbolHelper.swift index 5f8e7b6..7827838 100644 --- a/CoffeeTracker/CoffeeTracker/Helpers/SFSymbolHelper.swift +++ b/CoffeeTracker/CoffeeTracker/Helpers/SFSymbolHelper.swift @@ -14,7 +14,7 @@ enum SFSymbols { static let trash = "trash" static let pencil = "pencil.and.outline" static let plus = "plus" - static let share = "square.and.arrow.up" + static let share = "square.and.arrow.up.fill" static let photo = "photo" static let coffee = "cup.and.saucer.fill" }