changeset 119:c05ce3dfd489

Add animations
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 05 Feb 2021 16:05:16 +0100
parents 2bc9e5c0a7c6
children 2070372fea68
files LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/ContentView.swift lazybear/Views/InsiderTransactions.swift lazybear/Views/News.swift lazybear/Views/NewsDetail.swift lazybear/Views/Price.swift lazybear/Views/SearchBar.swift lazybear/Views/Stock.swift
diffstat 8 files changed, 30 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/ContentView.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/ContentView.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -22,7 +22,10 @@
     var body: some View {
         VStack(alignment: .leading) {
             if apiAccess.showingView {
+                if !showingSearch {
                 SuperTitle(name: "Home")
+                }
+                
                 SearchBar(searchedText: $searchedCompany, showingSearch: $showingSearch)
 
                 if showingSearch {
@@ -32,6 +35,7 @@
                     Spacer()
                 } else {
                     Watchlist()
+                        .transition(.opacity)
                 }
             }
         }
--- a/lazybear/Views/InsiderTransactions.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/InsiderTransactions.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -19,23 +19,24 @@
     // <--------- API Job --------->
     
     var body: some View {
-        VStack(alignment: .leading) {
+        HStack {
             Text("Insider transactions")
                 .font(.title)
                 .fontWeight(.semibold)
                 .padding([.leading, .bottom])
-            
-            ForEach(data, id: \.self) { data in
-                TransactionRow(data: data)
-            }
+            Spacer()
         }
         .onAppear { getUrl() }
+            
+        ForEach(data, id: \.self) { data in
+            TransactionRow(data: data)
+        }
     }
     
     private func getUrl() {
         // 1 -> Sandbox / 2 -> Production
         let baseUrl = apiAccess.results[2].url ?? ""
-        let token = apiAccess.results[1].key ?? ""
+        let token = apiAccess.results[2].key ?? ""
         let path = "/stable/stock/\(symbol)/insider-transactions?token="
         
         self.url = baseUrl + path + token
--- a/lazybear/Views/News.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/News.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -37,8 +37,8 @@
     
     private func getUrl() {
         // 1 -> Sandbox / 2 -> Production
-        let baseUrl = apiAccess.results[1].url ?? ""
-        let token = apiAccess.results[1].key ?? ""
+        let baseUrl = apiAccess.results[2].url ?? ""
+        let token = apiAccess.results[2].key ?? ""
         let path = "/stable/stock/\(symbol)/news/last/10?token="
         
         self.url = baseUrl + path + token
--- a/lazybear/Views/NewsDetail.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/NewsDetail.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -10,18 +10,10 @@
 
 struct NewsDetail: View {
     @State var new: NewsModel
-    @Environment(\.presentationMode) var newDetailPresentation
     
     var body: some View {
         
         VStack(alignment: .leading) {
-            HStack {
-                Spacer()
-                Button(action: { self.newDetailPresentation.wrappedValue.dismiss() }) {
-                    Image(systemName: "multiply.circle.fill")
-                }
-            }
-        
             Text(new.source ?? "-")
                 .font(.caption2)
             
--- a/lazybear/Views/Price.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/Price.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -48,8 +48,8 @@
     
      private func getUrl() {
         // 1 -> Sandbox / 2 -> Production
-        let baseUrl = apiAccess.results[1].url ?? ""
-        let token = apiAccess.results[1].key ?? ""
+        let baseUrl = apiAccess.results[2].url ?? ""
+        let token = apiAccess.results[2].key ?? ""
         let path = "/stable/stock/\(symbol)/quote?token="
         
         self.url = baseUrl + path + token
--- a/lazybear/Views/SearchBar.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/SearchBar.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -38,24 +38,26 @@
                 .background(Color(.systemGray6))
                 .cornerRadius(10)
                 .onTapGesture {
-                    self.searchBarIsEditing = true
-                    self.showingSearch = true  // Content View
-                    
-                    
+                    withAnimation {
+                        self.searchBarIsEditing = true
+                        self.showingSearch = true  // Content View
+                    }
                 }
  
             if searchBarIsEditing {
                 Button(action: {
-                    self.searchedText = ""
-                    self.searchBarIsEditing = false
-                    self.showingSearch = false  // Content View
-                    
-                    // Force hide keyboard
-                    UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
- 
+                    withAnimation {
+                        self.searchedText = ""
+                        self.searchBarIsEditing = false
+                        self.showingSearch = false  // Content View
+                        
+                        // Force hide keyboard
+                        UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
+                    }
                 }) {
                     Text("Cancel")
                 }
+                .transition(.move(edge: .trailing))
             }
         }
         .padding()
--- a/lazybear/Views/Stock.swift	Fri Feb 05 12:56:14 2021 +0100
+++ b/lazybear/Views/Stock.swift	Fri Feb 05 16:05:16 2021 +0100
@@ -65,8 +65,8 @@
         var range = range
         
         // 1 -> Sandbox / 2 -> Production
-        let baseUrl = apiAccess.results[1].url ?? ""
-        let token = apiAccess.results[1].key ?? ""
+        let baseUrl = apiAccess.results[2].url ?? ""
+        let token = apiAccess.results[2].key ?? ""
         if period[selectedPeriod] == "1W" { range = "5dm" }
         if period[selectedPeriod] == "1M" { range = "1mm" }
         let path = "/stable/stock/\(symbol)/chart/\(range)?chartCloseOnly=true&includeToday=false&token="