changeset 164:b899c1142d9d

Implement AboutView
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Sat, 11 Sep 2021 16:29:38 +0200
parents 35573bdd7d9b
children 6f024e6a3b19
files Simoleon/AboutView.swift Simoleon/ContentView.swift Simoleon/SettingsView.swift Simoleon/UI/LockedCurrencyPicker.swift
diffstat 4 files changed, 82 insertions(+), 217 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Simoleon/AboutView.swift	Sat Sep 11 16:29:38 2021 +0200
@@ -0,0 +1,70 @@
+//
+//  AboutView.swift
+//  Simoleon
+//
+//  Created by Dennis Concepción Martín on 19/07/2021.
+//
+
+import SwiftUI
+
+struct AboutView: View {
+    var body: some View {
+        Form {
+            Section(header: Text("Stay in touch")) {
+                Link(destination: URL(string: "https://itunes.apple.com/app/id1576390953?action=write-review")!) {
+                    HStack {
+                        Image(systemName: "heart.fill")
+                            .foregroundColor(Color(.systemRed))
+                            .imageScale(.large)
+
+                        Text("Rate Simoleon")
+                    }
+                }
+                
+                Link(destination: URL(string: "https://twitter.com/dennisconcep")!) {
+                    HStack {
+                        Image("TwitterLogo")
+                            .resizable()
+                            .frame(width: 30, height: 30)
+                        
+                        Text("Developer's Twitter")
+                    }
+                }
+                
+                Link(destination: URL(string: "https://dennistech.io/contact")!) {
+                    HStack {
+                        Image(systemName: "envelope.fill")
+                            .foregroundColor(Color(.systemIndigo))
+                            .imageScale(.large)
+                        
+                        Text("Contact")
+                    }
+                }
+            }
+            
+            Section(header: Text("About")) {
+                Link(destination: URL(string: "https://dennistech.io")!) {
+                    Text("Website")
+                }
+                
+                Link(destination: URL(string: "https://dennistech.io/simoleon-privacy-policy")!) {
+                    Text("Privacy Policy")
+                }
+                
+                Link(destination: URL(string: "https://dennistech.io/simoleon-terms-of-use")!) {
+                    Text("Terms of Use")
+                }
+            }
+        }
+        .navigationTitle("About")
+        .if(UIDevice.current.userInterfaceIdiom == .phone) { content in
+            NavigationView { content }
+        }
+    }
+}
+
+struct AboutView_Previews: PreviewProvider {
+    static var previews: some View {
+        AboutView()
+    }
+}
--- a/Simoleon/ContentView.swift	Sat Sep 11 16:28:44 2021 +0200
+++ b/Simoleon/ContentView.swift	Sat Sep 11 16:29:38 2021 +0200
@@ -19,7 +19,7 @@
         // MARK: - iPad
         if UIDevice.current.userInterfaceIdiom == .pad {
             NavigationView {
-//                Sidebar()
+                Sidebar()
                 ConversionView()
             }
         } else {
@@ -31,17 +31,17 @@
                     }
                     .tag(Tab.convert)
                 
-//                FavoritesView()
-//                    .tabItem {
-//                        Label("Favorites", systemImage: "star")
-//                    }
-//                    .tag(Tab.favorites)
-//
-//                SettingsView()
-//                    .tabItem {
-//                        Label("Settings", systemImage: "gear")
-//                    }
-//                    .tag(Tab.settings)
+                FavoritesView()
+                    .tabItem {
+                        Label("Favorites", systemImage: "star")
+                    }
+                    .tag(Tab.favorites)
+
+                AboutView()
+                    .tabItem {
+                        Label("Settings", systemImage: "gear")
+                    }
+                    .tag(Tab.settings)
             }
         }
     }
--- a/Simoleon/SettingsView.swift	Sat Sep 11 16:28:44 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-////
-////  SettingsView.swift
-////  Simoleon
-////
-////  Created by Dennis Concepción Martín on 19/07/2021.
-////
-//
-//import SwiftUI
-//import Purchases
-//
-//struct SettingsView: View {
-//    @Environment(\.managedObjectContext) private var viewContext
-//    @FetchRequest(sortDescriptors: []) private var defaultCurrency: FetchedResults<DefaultCurrency>
-//    @State private var selectedDefaultCurrency = ""
-//    @State private var showingSubscriptionPaywall = false
-//    @State private var entitlementIsActive = false
-//    @State private var alertTitle = ""
-//    @State private var alertMessage = ""
-//    @State private var showingAlert = false
-//    @State private var searchCurrency = ""
-//    let file = File()
-//    
-//    /*
-//     If searched currency string is empty:
-//     * Show all currencies
-//     else:
-//     * Show filtered list of currencies containing searched currency string
-//     */
-//    var searchResults: [String] {
-//        let currencyPairsSupported: [String] = try! file.read(json: "CurrencyPairsSupported.json")
-//        if searchCurrency.isEmpty {
-//            return currencyPairsSupported.sorted()
-//        } else {
-//            return currencyPairsSupported.filter { $0.contains(searchCurrency.uppercased()) }
-//        }
-//    }
-//    
-//    var body: some View {
-//        List {
-//            Section(header: Text("Preferences")) {
-//                if entitlementIsActive {
-//                    Picker("Default currency", selection: $selectedDefaultCurrency) {
-//                        SearchBar(placeholder: "Search...", text: $searchCurrency)
-//                            .padding(5)
-//                        
-//                        ForEach(searchResults, id: \.self) { currencyPairsSupported in
-//                            Text(currencyPairsSupported)
-//                                .tag(currencyPairsSupported)
-//                        }
-//                    }
-//                } else {
-//                    LockedCurrencyPicker()
-//                        .contentShape(Rectangle())
-//                        .onTapGesture { showingSubscriptionPaywall = true }
-//                }
-//            }
-//            
-//            Section(header: Text("Stay in touch")) {
-//                Link(destination: URL(string: "https://itunes.apple.com/app/id1576390953?action=write-review")!) {
-//                    HStack {
-//                        Image(systemName: "heart.fill")
-//                            .foregroundColor(Color(.systemRed))
-//                            .imageScale(.large)
-//
-//                        Text("Rate Simoleon")
-//                    }
-//                }
-//                
-//                Link(destination: URL(string: "https://twitter.com/dennisconcep")!) {
-//                    HStack {
-//                        Image("TwitterLogo")
-//                            .resizable()
-//                            .frame(width: 30, height: 30)
-//                        
-//                        Text("Developer's Twitter")
-//                    }
-//                }
-//                
-//                Link(destination: URL(string: "https://dennistech.io/contact")!) {
-//                    HStack {
-//                        Image(systemName: "envelope.fill")
-//                            .foregroundColor(Color(.systemIndigo))
-//                            .imageScale(.large)
-//                        
-//                        Text("Contact")
-//                    }
-//                }
-//            }
-//            
-//            Section(header: Text("About")) {
-//                Link(destination: URL(string: "https://dennistech.io")!) {
-//                    Text("Website")
-//                }
-//                
-//                Link(destination: URL(string: "https://dennistech.io/simoleon-privacy-policy")!) {
-//                    Text("Privacy Policy")
-//                }
-//                
-//                Link(destination: URL(string: "https://dennistech.io/simoleon-terms-of-use")!) {
-//                    Text("Terms of Use")
-//                }
-//            }
-//        }
-//        .alert(isPresented: $showingAlert) {
-//            Alert(title: Text(alertTitle), message: Text(alertMessage), dismissButton: .default(Text("Ok")))
-//        }
-//        .onAppear {
-//            checkEntitlement()
-//            /*
-//             if selectedDefaultCurrency is empty:
-//             * View is appearing for the first time
-//             * Set initial default curency for picker
-//             else:
-//             * View is appearing after user selected another default currency
-//             * Save it to core data
-//             */
-////            if selectedDefaultCurrency == "" {
-////                selectedDefaultCurrency = defaultCurrency.first?.pair ?? "USD/GBP"
-////            } else {
-////                setCoreData()
-////            }
-//        }
-//        .listStyle(InsetGroupedListStyle())
-//        .navigationTitle("Settings")
-//        .sheet(isPresented: $showingSubscriptionPaywall, onDismiss: checkEntitlement) {
-//            SubscriptionPaywall(showingSubscriptionPaywall: $showingSubscriptionPaywall)
-//        }
-//        .if(UIDevice.current.userInterfaceIdiom == .phone) { content in
-//            NavigationView { content }
-//        }
-//    }
-//     
-//    // Save default currency to core data
-////    private func setCoreData() {
-////        if defaultCurrency.isEmpty {  // If it's empty -> add record
-////            let defaultCurrency = DefaultCurrency(context: viewContext)
-////            defaultCurrency.pair = selectedDefaultCurrency
-////            
-////            do {
-////                try viewContext.save()
-////            } catch {
-////                print(error.localizedDescription)
-////            }
-////        } else {  // If not, update record
-////            defaultCurrency.first?.pair = selectedDefaultCurrency
-////            try? viewContext.save()
-////        }
-////    }
-//    
-//    // Check if user subscription is active
-//    private func checkEntitlement() {
-//        #if SCREENSHOTS
-//        entitlementIsActive = true
-//        #else
-//        Purchases.shared.purchaserInfo { (purchaserInfo, error) in
-//            if purchaserInfo?.entitlements["all"]?.isActive == true {
-//                entitlementIsActive = true
-//            }
-//            
-//            if let error = error as NSError? {
-//                alertTitle = error.localizedDescription
-//                alertMessage = error.localizedFailureReason ?? ""
-//                showingAlert = true
-//            }
-//        }
-//        #endif
-//    }
-//}
-//
-//struct SettingsView_Previews: PreviewProvider {
-//    static var previews: some View {
-//        SettingsView()
-//    }
-//}
--- a/Simoleon/UI/LockedCurrencyPicker.swift	Sat Sep 11 16:28:44 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-//
-//  LockedCurrencyPicker.swift
-//  Simoleon
-//
-//  Created by Dennis Concepción Martín on 22/07/2021.
-//
-
-import SwiftUI
-
-//struct LockedCurrencyPicker: View {
-//    @Environment(\.managedObjectContext) private var viewContext
-//    @FetchRequest(sortDescriptors: []) private var defaultCurrency: FetchedResults<DefaultCurrency>
-//    
-//    var body: some View {
-//        HStack {
-//            Text("Default currency")
-//            Spacer()
-//            Text(defaultCurrency.first?.pair ?? "USD/GBP")
-//                .foregroundColor(.secondary)
-//            
-//            Image(systemName: "lock")
-//                .foregroundColor(.secondary)
-//        }
-//    }
-//}
-//
-//struct LockedCurrencyPicker_Previews: PreviewProvider {
-//    static var previews: some View {
-//        LockedCurrencyPicker()
-//    }
-//}