Skip to content

Commit

Permalink
Added Social media links to the settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
Iikeli committed Jun 6, 2020
1 parent fd3e90a commit 482642a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Bean Juice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
43 changes: 42 additions & 1 deletion Bean Juice/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import SwiftUI
import SafariServices

struct SettingsView: View {

Expand Down Expand Up @@ -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<Int>(get: {
return self.selectedCup
Expand Down Expand Up @@ -64,20 +68,57 @@ 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)
// Circle().foregroundColor(self.colors[$0].color)
}
}
}
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<SafariView>) -> SFSafariViewController {
return SFSafariViewController(url: url)
}

func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {

}
}
//struct Settings_Previews: PreviewProvider {
// static var previews: some View {
// SettingsView()
Expand Down

0 comments on commit 482642a

Please # to comment.