changeset 26:787ad339ba72

Add public initializer to ChartView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 30 Apr 2021 18:05:04 +0200
parents 408b68f4ee61
children 704ddee7d78f
files DemoProject/DemoProject.xcodeproj/project.pbxproj DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate DemoProject/DemoProject/ContentView.swift DemoProject/DemoProject/Home.swift Sources/StockCharts/LineChart/ChartView.swift StockCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate
diffstat 7 files changed, 102 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/DemoProject/DemoProject.xcodeproj/project.pbxproj	Fri Apr 30 17:57:00 2021 +0200
+++ b/DemoProject/DemoProject.xcodeproj/project.pbxproj	Fri Apr 30 18:05:04 2021 +0200
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 50;
+	objectVersion = 52;
 	objects = {
 
 /* Begin PBXBuildFile section */
@@ -12,6 +12,7 @@
 		95770BE3263C5F86003FA924 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95770BE2263C5F86003FA924 /* Assets.xcassets */; };
 		95770BE6263C5F86003FA924 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95770BE5263C5F86003FA924 /* Preview Assets.xcassets */; };
 		95770BEE263C5FCD003FA924 /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770BED263C5FCD003FA924 /* Home.swift */; };
+		95770BF1263C6096003FA924 /* StockCharts in Frameworks */ = {isa = PBXBuildFile; productRef = 95770BF0263C6096003FA924 /* StockCharts */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -29,6 +30,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				95770BF1263C6096003FA924 /* StockCharts in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -88,6 +90,9 @@
 			dependencies = (
 			);
 			name = DemoProject;
+			packageProductDependencies = (
+				95770BF0263C6096003FA924 /* StockCharts */,
+			);
 			productName = DemoProject;
 			productReference = 95770BDB263C5F85003FA924 /* DemoProject.app */;
 			productType = "com.apple.product-type.application";
@@ -115,6 +120,9 @@
 				Base,
 			);
 			mainGroup = 95770BD2263C5F85003FA924;
+			packageReferences = (
+				95770BEF263C6096003FA924 /* XCRemoteSwiftPackageReference "StockCharts" */,
+			);
 			productRefGroup = 95770BDC263C5F85003FA924 /* Products */;
 			projectDirPath = "";
 			projectRoot = "";
@@ -332,6 +340,25 @@
 			defaultConfigurationName = Release;
 		};
 /* End XCConfigurationList section */
+
+/* Begin XCRemoteSwiftPackageReference section */
+		95770BEF263C6096003FA924 /* XCRemoteSwiftPackageReference "StockCharts" */ = {
+			isa = XCRemoteSwiftPackageReference;
+			repositoryURL = "https://github.com/denniscm190/StockCharts.git";
+			requirement = {
+				branch = main;
+				kind = branch;
+			};
+		};
+/* End XCRemoteSwiftPackageReference section */
+
+/* Begin XCSwiftPackageProductDependency section */
+		95770BF0263C6096003FA924 /* StockCharts */ = {
+			isa = XCSwiftPackageProductDependency;
+			package = 95770BEF263C6096003FA924 /* XCRemoteSwiftPackageReference "StockCharts" */;
+			productName = StockCharts;
+		};
+/* End XCSwiftPackageProductDependency section */
 	};
 	rootObject = 95770BD3263C5F85003FA924 /* Project object */;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved	Fri Apr 30 18:05:04 2021 +0200
@@ -0,0 +1,16 @@
+{
+  "object": {
+    "pins": [
+      {
+        "package": "StockCharts",
+        "repositoryURL": "https://github.com/denniscm190/StockCharts.git",
+        "state": {
+          "branch": "main",
+          "revision": "014e730f72937c5ecc6e82d28db6ce8af87a319d",
+          "version": null
+        }
+      }
+    ]
+  },
+  "version": 1
+}
Binary file DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/DemoProject/DemoProject/ContentView.swift	Fri Apr 30 17:57:00 2021 +0200
+++ b/DemoProject/DemoProject/ContentView.swift	Fri Apr 30 18:05:04 2021 +0200
@@ -6,11 +6,12 @@
 //
 
 import SwiftUI
+import StockCharts
 
 struct ContentView: View {
     var body: some View {
         TabView {
-            ChartViewPreview(data: generateSampleData(350))
+//            ChartViewPreview(data: generateSampleData(350))
                 .tabItem {
                     Label("ChartView", systemImage: "house")
                 }
--- a/DemoProject/DemoProject/Home.swift	Fri Apr 30 17:57:00 2021 +0200
+++ b/DemoProject/DemoProject/Home.swift	Fri Apr 30 18:05:04 2021 +0200
@@ -7,53 +7,53 @@
 
 import SwiftUI
 
-struct Home: View {
-    var data: [Double]
-    var dates: [String]?
-    var hours: [String]?
-    
-    var range = ["5D", "1M", "3M", "1Y", "5Y"]
-    @State private var selectedRange = "3M"
-    
-    var body: some View {
-        NavigationView {
-            VStack(alignment: .leading) {
-                Text("Apple Inc")
-                    .font(.title3)
-                    .padding([.horizontal, .bottom])
-                
-                Picker("Select a range", selection: $selectedRange) {
-                    ForEach(range, id: \.self) {
-                        Text($0)
-                    }
-                }
-                .pickerStyle(SegmentedPickerStyle())
-                .padding(.horizontal)
-                
-                ChartView(data: data, dates: dates, hours: hours)
-                    .padding(.vertical)
-            }
-            .navigationTitle("AAPL")
-            .toolbar {
-                ToolbarItem(placement: .navigationBarTrailing) {
-                    Button(action: {}) {
-                        Image(systemName: "star")
-                    }
-                }
-                
-                ToolbarItem(placement: .navigationBarLeading) {
-                    Button(action: {}) {
-                        Image(systemName: "plus.circle")
-                    }
-                }
-            }
-        }
-        .navigationViewStyle(StackNavigationViewStyle())
-    }
-}
-
-struct Home_Previews: PreviewProvider {
-    static var previews: some View {
-        Home()
-    }
-}
+//struct Home: View {
+//    var data: [Double]
+//    var dates: [String]?
+//    var hours: [String]?
+//    
+//    var range = ["5D", "1M", "3M", "1Y", "5Y"]
+//    @State private var selectedRange = "3M"
+//    
+//    var body: some View {
+//        NavigationView {
+//            VStack(alignment: .leading) {
+//                Text("Apple Inc")
+//                    .font(.title3)
+//                    .padding([.horizontal, .bottom])
+//                
+//                Picker("Select a range", selection: $selectedRange) {
+//                    ForEach(range, id: \.self) {
+//                        Text($0)
+//                    }
+//                }
+//                .pickerStyle(SegmentedPickerStyle())
+//                .padding(.horizontal)
+//                
+//                ChartView(data: data, dates: dates, hours: hours)
+//                    .padding(.vertical)
+//            }
+//            .navigationTitle("AAPL")
+//            .toolbar {
+//                ToolbarItem(placement: .navigationBarTrailing) {
+//                    Button(action: {}) {
+//                        Image(systemName: "star")
+//                    }
+//                }
+//                
+//                ToolbarItem(placement: .navigationBarLeading) {
+//                    Button(action: {}) {
+//                        Image(systemName: "plus.circle")
+//                    }
+//                }
+//            }
+//        }
+//        .navigationViewStyle(StackNavigationViewStyle())
+//    }
+//}
+//
+//struct Home_Previews: PreviewProvider {
+//    static var previews: some View {
+//        Home()
+//    }
+//}
--- a/Sources/StockCharts/LineChart/ChartView.swift	Fri Apr 30 17:57:00 2021 +0200
+++ b/Sources/StockCharts/LineChart/ChartView.swift	Fri Apr 30 18:05:04 2021 +0200
@@ -15,6 +15,12 @@
     @State var showingIndicators = false
     @State var indexPosition = Int()
     
+    public init(data: [Double], dates: [String]?, hours: [String]?) {
+        self.data = data
+        self.dates = dates
+        self.hours = hours
+    }
+    
     public var body: some View {
         VStack {
             ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition)
Binary file StockCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed