changeset 1:07410566b51b

06/01/21 committer: Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 06 Jan 2021 18:43:39 +0000
parents 668fd7e0d121
children 9f11c3e32bad
files About.swift Insiders.swift Stock.swift Supply/WhatsNew.swift
diffstat 4 files changed, 116 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/About.swift	Tue Jan 05 16:43:09 2021 +0000
+++ b/About.swift	Wed Jan 06 18:43:39 2021 +0000
@@ -22,29 +22,34 @@
                         AboutButton(image: "sparkles", name: "What's new")
                     }
                     Button(action: openUrl(url: "https://apps.apple.com/es/app/lazybear-insider-trading/id1534612943?l=en")) {
-                        AboutButton(image: "checkmark.circle.fill", name: "Rate Lazybear")
+                        AboutButton(image: "plus.circle.fill", name: "Rate Lazybear")
                     }
+                    /*
+                     
                     NavigationLink(destination: TipJar()) {
                         AboutButton(image: "gift.fill", name: "Tip jar")
                     }
+                     */
                     Button(action: openUrl(url: "https://twitter.com/LazybearApp")) {
                         AboutButton(image: "at.circle.fill", name: "@Lazybear")
                     }
                     Button(action: openUrl(url: "https://twitter.com/dennisconcep")) {
                         AboutButton(image: "at.circle.fill", name: "@DennisConcep")
                     }
+                    Button(action: openUrl(url: "https://github.com/denniscm190/lazybear-iOS")) {
+                        AboutButton(image: "star.fill", name: "Github")
+                    }
                     Button(action: openUrl(url: "https://lazybear.app")) {
                         AboutButton(image: "link.circle.fill", name: "Website")
                     }
-                    Button(action: openUrl(url: "https://github.com/denniscm190/lazybear-iOS")) {
-                        AboutButton(image: "star.fill", name: "Github")
-                    }
+                    /*
                     Button(action: {   }) {
                         AboutButton(image: "filemenu.and.selection", name: "Terms & Privacy policy")
                     }
                     Button(action: {   }) {
                         AboutButton(image: "envelope.circle.fill", name: "Contact")
                     }
+                     */
                 }
             }
             .padding()
--- a/Insiders.swift	Tue Jan 05 16:43:09 2021 +0000
+++ b/Insiders.swift	Wed Jan 06 18:43:39 2021 +0000
@@ -26,42 +26,45 @@
     @State private var selectedDate = Date().addingTimeInterval(-6*30*24*60*60)  // month*days*hours*minutes*seconds
     
     var body: some View {
-        VStack {
-            if transaction.showingView {
-                // Graph
-                let cumBuys = cumSum(array: getTransactions(acquisitionOrDisposition: "A"))
-                let cumSells = cumSum(array: getTransactions(acquisitionOrDisposition: "D"))
-                let green = GradientColor(start: .green, end: .green)
-                let red = GradientColor(start: .red, end: .red)
+        GeometryReader { geo in
+            VStack {
+                if transaction.showingView {
+                    // Graph
+                    let cumBuys = cumSum(array: getTransactions(acquisitionOrDisposition: "A"))
+                    let cumSells = cumSum(array: getTransactions(acquisitionOrDisposition: "D"))
+                    let green = GradientColor(start: .green, end: .green)
+                    let red = GradientColor(start: .red, end: .red)
+                    
+                    let width = geo.size.height*0.6
+                    MultiLineChartView(data: [(cumBuys, green), (cumSells, red)], title: "Buys and sells", form: CGSize(width: width, height: width/2.3), rateValue: pct(buy: cumBuys.last!, sell: cumSells.last!))
+                        .padding()
                 
-                MultiLineChartView(data: [(cumBuys, green), (cumSells, red)], title: "Buys and sells", form: ChartForm.extraLarge, rateValue: pct(buy: cumBuys.last!, sell: cumSells.last!))
-                    .padding()
-            
-                DatePicker(selection: $selectedDate, in: ...Date(), displayedComponents: .date) { Text("Transactions since").font(.headline) }
-                    .padding([.leading, .top, .trailing])
-                    .onChange(of: self.selectedDate, perform: { date in
-                        transaction.request(cik: String(cik), date: dateFormatter.string(from: selectedDate))
-                    })
+                    DatePicker(selection: $selectedDate, in: ...Date(), displayedComponents: .date) { Text("Transactions since").font(.headline) }
+                        .padding([.leading, .top, .trailing])
+                        .onChange(of: self.selectedDate, perform: { date in
+                            transaction.request(cik: String(cik), date: dateFormatter.string(from: selectedDate))
+                        })
 
-                List {
-                    ForEach(transaction.result, id:\.self) { trans in
-                        TransactionRow(trans: trans)
+                    List {
+                        ForEach(transaction.result, id:\.self) { trans in
+                            TransactionRow(trans: trans)
+                        }
                     }
+                    .offset(y: 10)
                 }
-                .offset(y: 10)
+                else {
+                    Spacer()
+                    ProgressView()
+                    Spacer()
+                }
             }
-            else {
-                Spacer()
-                ProgressView()
-                Spacer()
+            .onAppear {
+                transaction.request(cik: String(cik), date: dateFormatter.string(from: selectedDate))
             }
+            .alert(isPresented: $transaction.showingAlert) {
+                        Alert(title: Text("There is no data available"), message: Text("We have no data about this company. Try another one."), dismissButton: .default(Text("Got it!")))
+                    }
         }
-        .onAppear {
-            transaction.request(cik: String(cik), date: dateFormatter.string(from: selectedDate))
-        }
-        .alert(isPresented: $transaction.showingAlert) {
-                    Alert(title: Text("There is no data available"), message: Text("We have no data about this company. Try another one."), dismissButton: .default(Text("Got it!")))
-                }
     }
     // Function to sum an array and return a cumulative sum array
     func cumSum(array: [Double]) -> [Double] {
--- a/Stock.swift	Tue Jan 05 16:43:09 2021 +0000
+++ b/Stock.swift	Wed Jan 06 18:43:39 2021 +0000
@@ -17,55 +17,58 @@
     @State var name: String
 
     var body: some View {
-        VStack {
-            if price.showingView {
-                HStack {
-                    Text("$ " + String(price.result.last!.close))
-                        .font(.title)
-                        .fontWeight(.bold)
+        GeometryReader { geo in
+            VStack {
+                if price.showingView {
+                    HStack {
+                        Text("$ " + String(price.result.last!.close))
+                            .font(.title)
+                            .fontWeight(.bold)
+                        
+                        let pct = price.result.last!.changePercent * 100
+                        Text(String(format: "%.2f", pct) + " %")
+                            .font(.headline)
+                            .foregroundColor(whichColor())
+                        
+                        Spacer()
+                    }
+                    .padding([.leading, .top])
                     
-                    let pct = price.result.last!.changePercent * 100
-                    Text(String(format: "%.2f", pct) + " %")
-                        .font(.headline)
-                        .foregroundColor(whichColor())
+                    HStack {
+                        Text(String(price.result.last!.date) + " last price")
+                            .font(.caption)
+                            .padding([.leading])
+                            .opacity(0.5)
+                        Spacer()
+                    }
+                    
+                    // Stock Price
+                    let width = geo.size.height*0.6
+                    let prices = price.result.map { $0.close }  // Get an array of a variable in the struct
+                    LineChartView(data: prices, title: "Stock price", legend: "Last 20 days",  form: CGSize(width: width, height: width/2), rateValue: nil)
+                        .padding()
                     
                     Spacer()
+                    
+                    // Volume
+                    let volume = price.result.map { $0.volume }
+                    BarChartView(data: ChartData(points: volume), title: "Volume", form: CGSize(width: width, height: width/2))
+                        .padding()
+                    
                 }
-                .padding([.leading, .top])
-                
-                HStack {
-                    Text(String(price.result.last!.date) + " last price")
-                        .font(.caption)
-                        .padding([.leading])
-                        .opacity(0.5)
+                else {
+                    Spacer()
+                    ProgressView()
                     Spacer()
                 }
-                
-                // Stock Price
-                let prices = price.result.map { $0.close }  // Get an array of a variable in the struct
-                LineChartView(data: prices, title: "Stock price", legend: "Last 20 days",  form: ChartForm.extraLarge, rateValue: nil)
-                    .padding()
-                
-                Spacer()
-                
-                // Volume
-                let volume = price.result.map { $0.volume }
-                BarChartView(data: ChartData(points: volume), title: "Volume", form: ChartForm.extraLarge)
-                    .padding()
-                
+            }
+            .onAppear {
+                price.request(symbol: symbol)
             }
-            else {
-                Spacer()
-                ProgressView()
-                Spacer()
-            }
+            .alert(isPresented: $price.showingAlert) {
+                        Alert(title: Text("There is no data available"), message: Text("We have no data about this company. Try another one."), dismissButton: .default(Text("Got it!")))
+                    }
         }
-        .onAppear {
-            price.request(symbol: symbol)
-        }
-        .alert(isPresented: $price.showingAlert) {
-                    Alert(title: Text("There is no data available"), message: Text("We have no data about this company. Try another one."), dismissButton: .default(Text("Got it!")))
-                }
     }
     
     func whichColor() -> Color {
--- a/Supply/WhatsNew.swift	Tue Jan 05 16:43:09 2021 +0000
+++ b/Supply/WhatsNew.swift	Wed Jan 06 18:43:39 2021 +0000
@@ -10,38 +10,41 @@
 
 struct WhatsNew: View {
     var body: some View {
-        ScrollView {
-            VStack(alignment: .leading, spacing: 20) {
-                let intro = "This new version comes with lots of changes and many cool stuff. I've been working hard to improve the backend efficiency, deploy a new API and other boring stuff that you probably are not interested in. So let's talk about the cool stuff."
-                Text(intro)
+        GeometryReader { geo in
+            ScrollView {
+                VStack(alignment: .leading, spacing: 20) {
+                    let intro = "This new version comes with lots of changes and many cool stuff. I've been working hard to improve the backend efficiency, deploy a new API and other boring stuff that you probably are not interested in. So let's talk about the cool stuff."
+                    Text(intro)
+                        
+                    let title1 = "New design"
+                    let text1 = "As you can see, there is a completely new design, more clean, colourful, and simple. Now you can check the date for the company you want in three clicks. Less is more."
+                    Text(title1 + " 😎")
+                        .title()
+                        
+                    Text(text1)
                     
-                let title1 = "New design"
-                let text1 = "As you can see, there is a completely new design, more clean, colourful, and simple. Now you can check the date for the company you want in three clicks. Less is more."
-                Text(title1 + " 😎")
-                    .title()
+                    let title2 = "Charts! A bunch!"
+                    let text2 = "Look how cool they are"
+                    Text(title2)
+                        .title()
                     
-                Text(text1)
-                
-                let title2 = "Charts! A bunch!"
-                let text2 = "Look how cool they are"
-                Text(title2)
-                    .title()
-                
-                Text(text2 + " 😁")
-                HStack {
-                    Spacer()
-                    LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Some cool title", form: ChartForm.large, rateValue: 14)
-                    Spacer()
+                    Text(text2 + " 😁")
+                    HStack {
+                        Spacer()
+                        let width = geo.size.height*0.4
+                        LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Some cool title", form: CGSize(width: width, height: width/2), rateValue: 14)
+                        Spacer()
+                    }
+                    
+                    let title3 = "Stock prices"
+                    let text3 = "Finally I found a not-so-expensive method to show stock prices. In this version you can see the latest stock price from the previous day, but I promise you in future versions I am going to add real-time stock prices."
+                    Text(title3)
+                        .title()
+                    
+                    Text(text3)
                 }
-                
-                let title3 = "Stock prices"
-                let text3 = "Finally I found a not-so-expensive method to show stock prices. In this version you can see the latest stock price from the previous day, but I promise you in future versions I am going to add real-time stock prices."
-                Text(title3)
-                    .title()
-                
-                Text(text3)
+                .padding()
             }
-            .padding()
         }
     }
 }