changeset 250:8fec23e8f7c3

Fix ActionView bugs
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 12 Mar 2021 10:32:58 +0100
parents 73d31bcfa0b7
children a2d87e6e5184
files LazyBear/ContentView.swift LazyBear/UI/ActionView.swift LazyBear/UI/CompanyView.swift
diffstat 3 files changed, 29 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear/ContentView.swift	Fri Mar 12 08:54:26 2021 +0100
+++ b/LazyBear/ContentView.swift	Fri Mar 12 10:32:58 2021 +0100
@@ -44,7 +44,7 @@
             
             // Action sheet
             ZStack(alignment: .bottom) {
-                Color(.gray)
+                Color(.black)
                     .edgesIgnoringSafeArea(.all)
                     .opacity(hudManager.showAction ? 0.2: 0)
                     .animation(.easeInOut)
--- a/LazyBear/UI/ActionView.swift	Fri Mar 12 08:54:26 2021 +0100
+++ b/LazyBear/UI/ActionView.swift	Fri Mar 12 10:32:58 2021 +0100
@@ -10,32 +10,39 @@
 struct ActionView: View {
     @EnvironmentObject var companyType: CompanyType
     @EnvironmentObject var hudManager: HudManager
+    @Environment(\.colorScheme) var colorScheme  // Detect dark mode
     
     var body: some View {
-        VStack {
-            VStack {
+        VStack(alignment: .leading) {
+            VStack(alignment: .leading) {
                 Group {
                     Button(action: { changeViewTo(.stock) }) {
                         Image(systemName: "chart.bar")
+                            .frame(width: 50)
+                        
                         Text("Stock & news")
                         Spacer()
                     }
+                    .padding([.leading, .top, .trailing])
+                    
                     Divider()
-                        .offset(x: 45)
+                        .offset(x: 75)
                     
                     Button(action: { changeViewTo(.insiders) }) {
                         Image(systemName: "chart.pie")
+                            .frame(width: 50)
+                        
                         Text("Insider transactions")
                         Spacer()
                     }
+                    .padding([.leading, .bottom, .trailing])
                 }
                 .modifier(Title())
             }
-            .padding()
             .background(
-                Color(.white)
-                    .cornerRadius(20)
+                colorScheme == .dark ? Color(red: 0.15, green: 0.17, blue: 0.18): Color(.white)
             )
+            .cornerRadius(20)
             
             Button(action: { self.hudManager.showAction = false }) {
                 Spacer()
@@ -43,15 +50,14 @@
                 Spacer()
             }
             .modifier(Title())
-            .padding(.vertical)
+            .padding()
             .background(
-                Color(.white)
-                    .cornerRadius(20)
+                colorScheme == .dark ? Color(red: 0.15, green: 0.17, blue: 0.18): Color(.white)
             )
+            .cornerRadius(20)
         }
-        .frame(maxWidth: 600)
     }
-    
+        
     private func changeViewTo(_ view: ViewType ) {
         // Show view after one second.
         // Give time to dismiss the Action View
@@ -85,3 +91,4 @@
             .frame(maxWidth: .infinity)
     }
 }
+
--- a/LazyBear/UI/CompanyView.swift	Fri Mar 12 08:54:26 2021 +0100
+++ b/LazyBear/UI/CompanyView.swift	Fri Mar 12 10:32:58 2021 +0100
@@ -33,7 +33,14 @@
         .toolbar {
             ToolbarItem(placement: .principal) {
                 Button(action: { self.hudManager.showAction.toggle() }) {
-                    Text("Test")
+                    HStack {
+                        if companyType.view == .stock {
+                            Text("Stock")
+                        } else if companyType.view == .insiders {
+                            Text("Insiders")
+                        }
+                        Image(systemName: "chevron.down")
+                    }
                 }
             }
             
@@ -70,6 +77,8 @@
     static var previews: some View {
         NavigationView {
             CompanyView(name: "apple inc", symbol: "aapl")
+                .environmentObject(HudManager())
+                .environmentObject(CompanyType())
                 .navigationTitle("APPL")
         }
         .navigationViewStyle(StackNavigationViewStyle())