changeset 27:3dd331a54bc7

Testing iPad Charts
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Thu, 14 Jan 2021 19:15:22 +0000
parents f8f54f72e843
children 387abbfa0a58 239743e13e36
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Functions/Price.swift lazybear/LazyBearApp.swift lazybear/Tests/SizeClassView.swift lazybear/Tests/TestFavourites.swift
diffstat 7 files changed, 90 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj	Thu Jan 14 11:52:36 2021 +0000
+++ b/LazyBear.xcodeproj/project.pbxproj	Thu Jan 14 19:15:22 2021 +0000
@@ -15,7 +15,6 @@
 		954D997125A253A9001F7F60 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D997025A253A9001F7F60 /* Config.swift */; };
 		954D998325A27571001F7F60 /* Price.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D998225A27571001F7F60 /* Price.swift */; };
 		9552A61F25B06580001CD0C8 /* SampleConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9552A61E25B0657F001CD0C8 /* SampleConfig.swift */; };
-		955AD1F425AE2BDC00965D42 /* TestFavourites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955AD1F325AE2BDC00965D42 /* TestFavourites.swift */; };
 		95612C472598D17F00F7698F /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95612C462598D17F00F7698F /* User.swift */; };
 		95612C4A2598D1F800F7698F /* About.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95612C492598D1F800F7698F /* About.swift */; };
 		95612C502598D48200F7698F /* Companies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95612C4E2598D48200F7698F /* Companies.swift */; };
@@ -35,6 +34,8 @@
 		95B04EB325212369000AD27F /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B04EB225212369000AD27F /* LazyBearApp.swift */; };
 		95B04EB525212369000AD27F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B04EB425212369000AD27F /* ContentView.swift */; };
 		95B04EB72521236A000AD27F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95B04EB62521236A000AD27F /* Assets.xcassets */; };
+		95D0012825B0C3A5007D45FD /* SizeClassView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95D0012725B0C3A5007D45FD /* SizeClassView.swift */; };
+		95D0013225B0CFAB007D45FD /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 95D0013125B0CFAB007D45FD /* Charts */; };
 		95D1BF4925ADCF7700E5D063 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95D1BF4825ADCF7700E5D063 /* Persistence.swift */; };
 		95D1BF4C25ADD08500E5D063 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95D1BF4B25ADD08500E5D063 /* Main.swift */; };
 		95DF5194259DDC45003790B2 /* AboutButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95DF5193259DDC45003790B2 /* AboutButton.swift */; };
@@ -53,7 +54,6 @@
 		954D997025A253A9001F7F60 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Config.swift; path = lazybear/Config.swift; sourceTree = SOURCE_ROOT; };
 		954D998225A27571001F7F60 /* Price.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Price.swift; path = lazybear/Functions/Price.swift; sourceTree = SOURCE_ROOT; };
 		9552A61E25B0657F001CD0C8 /* SampleConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SampleConfig.swift; path = lazybear/SampleConfig.swift; sourceTree = SOURCE_ROOT; };
-		955AD1F325AE2BDC00965D42 /* TestFavourites.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TestFavourites.swift; path = lazybear/Tests/TestFavourites.swift; sourceTree = SOURCE_ROOT; };
 		95612C462598D17F00F7698F /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = User.swift; path = lazybear/User.swift; sourceTree = SOURCE_ROOT; };
 		95612C492598D1F800F7698F /* About.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = About.swift; path = lazybear/About.swift; sourceTree = SOURCE_ROOT; };
 		95612C4E2598D48200F7698F /* Companies.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Companies.swift; sourceTree = "<group>"; };
@@ -75,6 +75,7 @@
 		95B04EB425212369000AD27F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
 		95B04EB62521236A000AD27F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
 		95B04EBB2521236A000AD27F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		95D0012725B0C3A5007D45FD /* SizeClassView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SizeClassView.swift; path = lazybear/Tests/SizeClassView.swift; sourceTree = SOURCE_ROOT; };
 		95D1BF4825ADCF7700E5D063 /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Persistence.swift; path = "LazyBear/Core Data/Persistence.swift"; sourceTree = SOURCE_ROOT; };
 		95D1BF4B25ADD08500E5D063 /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Main.swift; path = lazybear/Main.swift; sourceTree = SOURCE_ROOT; };
 		95DF5193259DDC45003790B2 /* AboutButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutButton.swift; sourceTree = "<group>"; };
@@ -90,6 +91,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				95002580256D17D9008FFD28 /* StoreKit.framework in Frameworks */,
+				95D0013225B0CFAB007D45FD /* Charts in Frameworks */,
 				954D996D25A2461B001F7F60 /* SwiftUICharts in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -108,7 +110,7 @@
 		952F791C2598B1CD00FF929F /* Tests */ = {
 			isa = PBXGroup;
 			children = (
-				955AD1F325AE2BDC00965D42 /* TestFavourites.swift */,
+				95D0012725B0C3A5007D45FD /* SizeClassView.swift */,
 			);
 			path = Tests;
 			sourceTree = "<group>";
@@ -231,6 +233,7 @@
 			name = LazyBear;
 			packageProductDependencies = (
 				954D996C25A2461B001F7F60 /* SwiftUICharts */,
+				95D0013125B0CFAB007D45FD /* Charts */,
 			);
 			productName = LazyBear;
 			productReference = 95B04EAF25212369000AD27F /* LazyBear.app */;
@@ -261,6 +264,7 @@
 			mainGroup = 95B04EA625212369000AD27F;
 			packageReferences = (
 				954D996B25A2461B001F7F60 /* XCRemoteSwiftPackageReference "ChartView" */,
+				95D0013025B0CFAB007D45FD /* XCRemoteSwiftPackageReference "swiftui-charts" */,
 			);
 			productRefGroup = 95B04EB025212369000AD27F /* Products */;
 			projectDirPath = "";
@@ -291,7 +295,6 @@
 				95AB4A7A259DCBAE0064C9C1 /* ReadJson.swift in Sources */,
 				95DF5194259DDC45003790B2 /* AboutButton.swift in Sources */,
 				95612C512598D48200F7698F /* SearchBar.swift in Sources */,
-				955AD1F425AE2BDC00965D42 /* TestFavourites.swift in Sources */,
 				95A1ECC525A37541001D4A21 /* TransactionRow.swift in Sources */,
 				956FAF7C25AF421E0002B2C1 /* FavCompany+CoreDataProperties.swift in Sources */,
 				95B04EB525212369000AD27F /* ContentView.swift in Sources */,
@@ -314,6 +317,7 @@
 				95DF5197259DDD68003790B2 /* AppInfo.swift in Sources */,
 				954D997125A253A9001F7F60 /* Config.swift in Sources */,
 				95A1ECAF25A36127001D4A21 /* Transaction.swift in Sources */,
+				95D0012825B0C3A5007D45FD /* SizeClassView.swift in Sources */,
 				9521A8BD259B93200000D417 /* Company.swift in Sources */,
 				9552A61F25B06580001CD0C8 /* SampleConfig.swift in Sources */,
 				954D992525A2123B001F7F60 /* PriceModel.swift in Sources */,
@@ -464,7 +468,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTS_MACCATALYST = NO;
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Debug;
 		};
@@ -491,7 +495,7 @@
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SUPPORTS_MACCATALYST = NO;
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1,2";
 			};
 			name = Release;
 		};
@@ -527,6 +531,14 @@
 				minimumVersion = 1.5.4;
 			};
 		};
+		95D0013025B0CFAB007D45FD /* XCRemoteSwiftPackageReference "swiftui-charts" */ = {
+			isa = XCRemoteSwiftPackageReference;
+			repositoryURL = "https://github.com/spacenation/swiftui-charts.git";
+			requirement = {
+				kind = upToNextMajorVersion;
+				minimumVersion = 1.0.0;
+			};
+		};
 /* End XCRemoteSwiftPackageReference section */
 
 /* Begin XCSwiftPackageProductDependency section */
@@ -535,6 +547,11 @@
 			package = 954D996B25A2461B001F7F60 /* XCRemoteSwiftPackageReference "ChartView" */;
 			productName = SwiftUICharts;
 		};
+		95D0013125B0CFAB007D45FD /* Charts */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = 95D0013025B0CFAB007D45FD /* XCRemoteSwiftPackageReference "swiftui-charts" */;
+			productName = Charts;
+		};
 /* End XCSwiftPackageProductDependency section */
 
 /* Begin XCVersionGroup section */
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved	Thu Jan 14 11:52:36 2021 +0000
+++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved	Thu Jan 14 19:15:22 2021 +0000
@@ -9,6 +9,24 @@
           "revision": "4699847a9ac0c694666cea3acef133498952566e",
           "version": "1.5.4"
         }
+      },
+      {
+        "package": "Charts",
+        "repositoryURL": "https://github.com/spacenation/swiftui-charts.git",
+        "state": {
+          "branch": null,
+          "revision": "0b66e5c2326e954efdcc94a9eeb699e2f2ae80a2",
+          "version": "1.0.0"
+        }
+      },
+      {
+        "package": "Shapes",
+        "repositoryURL": "https://github.com/swift-extensions/swiftui-shapes.git",
+        "state": {
+          "branch": null,
+          "revision": "c58b15c37eae9bd20525c6daa93a06a689ca75cb",
+          "version": "1.1.0"
+        }
       }
     ]
   },
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/Functions/Price.swift	Thu Jan 14 11:52:36 2021 +0000
+++ b/lazybear/Functions/Price.swift	Thu Jan 14 19:15:22 2021 +0000
@@ -13,7 +13,7 @@
     @Published var showingAlert = false
     
     func request(symbol: String) {
-        guard let url = URL(string: priceUrl(symbol: symbol, sandbox: false)) else {  // Change sandbox when production
+        guard let url = URL(string: priceUrl(symbol: symbol, sandbox: true)) else {  // Change sandbox when production
             print("Invalid URL")
             return
         }
--- a/lazybear/LazyBearApp.swift	Thu Jan 14 11:52:36 2021 +0000
+++ b/lazybear/LazyBearApp.swift	Thu Jan 14 19:15:22 2021 +0000
@@ -14,7 +14,7 @@
     var body: some Scene {
         WindowGroup {
             NavigationView {
-                ContentView()
+                SizeClassView()
                     .environment(\.managedObjectContext, persistenceController.container.viewContext)
             }
             .navigationViewStyle(StackNavigationViewStyle())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lazybear/Tests/SizeClassView.swift	Thu Jan 14 19:15:22 2021 +0000
@@ -0,0 +1,47 @@
+//
+//  SizeClassView.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 14/1/21.
+//
+
+import SwiftUI
+import SwiftUICharts
+
+struct SizeClassView: View {
+    @Environment(\.verticalSizeClass) var verticalSizeClass: UserInterfaceSizeClass?
+    @Environment(\.horizontalSizeClass) var horizontalSizeClass: UserInterfaceSizeClass?
+    
+    var body: some View {
+        VStack {
+            if horizontalSizeClass == .compact && verticalSizeClass == .regular {
+                Text("iPhone Portrait")
+            }
+            else if horizontalSizeClass == .regular && verticalSizeClass == .regular {
+                HStack {
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                    Spacer()
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                }.padding()
+                Spacer()
+                HStack {
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                    Spacer()
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                }.padding()
+                Spacer()
+                HStack {
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                    Spacer()
+                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.extraLarge)
+                }.padding()
+            }
+        }
+    }
+}
+
+struct SizeClassView_Previews: PreviewProvider {
+    static var previews: some View {
+        SizeClassView()
+    }
+}
--- a/lazybear/Tests/TestFavourites.swift	Thu Jan 14 11:52:36 2021 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-//
-//  TestFavourites.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 12/1/21.
-//
-/*
-import SwiftUI
-
-struct TestFavourites: View {
-    @Environment(\.managedObjectContext) private var viewContext
-    @FetchRequest(entity: FavCompany.entity(), sortDescriptors: [])
-    var favCompanies: FetchedResults<FavCompany>
-    
-    var body: some View {
-        VStack {
-            // Add to favourite
-            Button(action: { addFavourite() }) {
-                Text("Add to favourite")
-            }
-            
-            // Display favourites
-            List {
-                ForEach(favCompanies) { favCompany in
-                    HStack {
-                        Text(String(favCompany.cik))
-                        Text(favCompany.symbol)
-                        Text(favCompany.name)
-
-                    }.padding()
-                }
-                // Delete from persistent storage
-                .onDelete { indexSet in
-                    for index in indexSet {
-                        viewContext.delete(favCompanies[index])
-                    }
-                    do {
-                        try viewContext.save()
-                        print("Company deleted")
-                    } catch {
-                        print(error.localizedDescription)
-                    }
-                }
-            }
-        }
-    }
-    
-    func addFavourite() {
-        let favCompany = FavCompany(context: viewContext)
-        favCompany.cik = 12345
-        favCompany.symbol = "AAPL"
-        favCompany.name = "Apple Inc"
-        do {
-            try viewContext.save()
-            print("Company saved.")
-        } catch {
-            print(error.localizedDescription)
-        }
-    }
-    /*
-    func updateFavourite(favCompany: FavCompany) {
-        let newStatus = false
-        viewContext.performAndWait {
-            favCompany.cik = newStatus
-            try? viewContext.save()
-            print("Company updated")
-        }
-    }
-     */
-}
-
-struct TestFavourites_Previews: PreviewProvider {
-    static var previews: some View {
-        TestFavourites()
-    }
-}
-*/