From 482642aa0487b3e24242ae2867f2530cca3ae3d6 Mon Sep 17 00:00:00 2001 From: Iiro Alhonen Date: Sat, 6 Jun 2020 15:50:51 +0300 Subject: [PATCH] Added Social media links to the settings view --- Bean Juice.xcodeproj/project.pbxproj | 4 +-- Bean Juice/Settings.swift | 43 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Bean Juice.xcodeproj/project.pbxproj b/Bean Juice.xcodeproj/project.pbxproj index 66cbf93..fade538 100644 --- a/Bean Juice.xcodeproj/project.pbxproj +++ b/Bean Juice.xcodeproj/project.pbxproj @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.1.2; PRODUCT_BUNDLE_IDENTIFIER = com.niftytreestudios.beanjuice; PRODUCT_NAME = "Bean Juice"; SWIFT_VERSION = 5.0; @@ -514,7 +514,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.1; + MARKETING_VERSION = 1.1.2; PRODUCT_BUNDLE_IDENTIFIER = com.niftytreestudios.beanjuice; PRODUCT_NAME = "Bean Juice"; SWIFT_VERSION = 5.0; diff --git a/Bean Juice/Settings.swift b/Bean Juice/Settings.swift index b2825ec..4b279e9 100644 --- a/Bean Juice/Settings.swift +++ b/Bean Juice/Settings.swift @@ -8,6 +8,7 @@ import Foundation import SwiftUI +import SafariServices struct SettingsView: View { @@ -36,6 +37,9 @@ struct SettingsView: View { @State private var selectedColor: Int = 0 @Binding var customColor: Color + @State var showSafari = false + @State var urlString = "https://duckduckgo.com" + var body: some View { let cupSelection = Binding(get: { return self.selectedCup @@ -64,7 +68,7 @@ struct SettingsView: View { } Section(header: Text("Select highlight color") .font(.subheadline), footer: Text("This will affect what highlight color the app uses.")) { - Picker("", selection: colorSelection) { + Picker("Color", selection: colorSelection) { ForEach(0 ..< colors.count) { Text(self.colors[$0].name) .tag($0) @@ -72,12 +76,49 @@ struct SettingsView: View { } } } + Section(header: Text("Follow us on social media") + .font(.subheadline), footer: Text("@BeanJuiceApp"), content: { + Button(action: { + // Open Instagram + self.urlString = "https://www.instagram.com/BeanJuiceApp" + self.showSafari = true + }) { + Text("Instagram") + } + // summon the Safari sheet + .sheet(isPresented: $showSafari) { + SafariView(url:URL(string: self.urlString)!) + } + Button(action: { + // Open Twitter + self.urlString = "https://www.twitter.com/BeanJuiceApp" + self.showSafari = true + }) { + Text("Twitter") + } + // summon the Safari sheet + .sheet(isPresented: $showSafari) { + SafariView(url:URL(string: self.urlString)!) + } + }) .navigationBarTitle("Settings", displayMode: .inline) } } } } +struct SafariView: UIViewControllerRepresentable { + + let url: URL + + func makeUIViewController(context: UIViewControllerRepresentableContext) -> SFSafariViewController { + return SFSafariViewController(url: url) + } + + func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext) { + + } +} //struct Settings_Previews: PreviewProvider { // static var previews: some View { // SettingsView()