Mercurial > public > lazybear
changeset 441:417148200aaf
Change background color and minor UI updates
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear.xcodeproj/project.pbxproj Sun Jun 20 19:52:21 2021 +0200 @@ -87,6 +87,7 @@ 95AD4A2D26078C1400498079 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AD4A2C26078C1400498079 /* ContentView.swift */; }; 95AF0FF72671320F0049C4AB /* DisplayWords.json in Resources */ = {isa = PBXBuildFile; fileRef = 95AF0FF62671320F0049C4AB /* DisplayWords.json */; }; 95AF0FF92671342E0049C4AB /* DisplayWordsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AF0FF82671342E0049C4AB /* DisplayWordsModel.swift */; }; + 95B85AB6267FAE7A0080CF39 /* ConditionalModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B85AB5267FAE7A0080CF39 /* ConditionalModifier.swift */; }; 95BB05B22670B8C3005A2029 /* KeyStatsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */; }; 95C22F3F26776F010014C98A /* CompanyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C22F3E26776F010014C98A /* CompanyModel.swift */; }; 95C8C0E0262A369F0082D1D9 /* ProfileResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C8C0DF262A369F0082D1D9 /* ProfileResponse.swift */; }; @@ -260,6 +261,7 @@ 95AD4A2C26078C1400498079 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 95AF0FF62671320F0049C4AB /* DisplayWords.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = DisplayWords.json; sourceTree = "<group>"; }; 95AF0FF82671342E0049C4AB /* DisplayWordsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayWordsModel.swift; sourceTree = "<group>"; }; + 95B85AB5267FAE7A0080CF39 /* ConditionalModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConditionalModifier.swift; sourceTree = "<group>"; }; 95BB05B12670B8C3005A2029 /* KeyStatsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyStatsModel.swift; sourceTree = "<group>"; }; 95C22F3E26776F010014C98A /* CompanyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyModel.swift; sourceTree = "<group>"; }; 95C8C0DF262A369F0082D1D9 /* ProfileResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileResponse.swift; sourceTree = "<group>"; }; @@ -375,6 +377,7 @@ 95A7C0732616409D003E2EC1 /* ParseJSON.swift */, 95CCFB5D266E855800C384A1 /* GetDateComponents.swift */, 95CCFB5F266E864C00C384A1 /* ConvertStringToDate.swift */, + 95B85AB5267FAE7A0080CF39 /* ConditionalModifier.swift */, ); path = "Global functions"; sourceTree = "<group>"; @@ -1000,6 +1003,7 @@ 95BB05B22670B8C3005A2029 /* KeyStatsModel.swift in Sources */, 950B6F422676454A0029E447 /* RevenueCatTest.swift in Sources */, 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */, + 95B85AB6267FAE7A0080CF39 /* ConditionalModifier.swift in Sources */, 95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */, 9502BBFD267F63F3003B0A59 /* CustomRectangleBox.swift in Sources */, 95A4B937263EA5C20056F036 /* WatchlistCreatorRow.swift in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/Assets.xcassets/CustomBackground.colorset/Contents.json Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Assets.xcassets/CustomBackground.colorset/Contents.json Sun Jun 20 19:52:21 2021 +0200 @@ -2,13 +2,8 @@ "colors" : [ { "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "254", - "green" : "251", - "red" : "250" - } + "platform" : "ios", + "reference" : "systemGray6Color" }, "idiom" : "universal" },
--- a/LazyBear/Assets.xcassets/CustomSecondaryBackground.colorset/Contents.json Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Assets.xcassets/CustomSecondaryBackground.colorset/Contents.json Sun Jun 20 19:52:21 2021 +0200 @@ -20,13 +20,8 @@ } ], "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.137", - "green" : "0.133", - "red" : "0.133" - } + "platform" : "ios", + "reference" : "secondarySystemBackgroundColor" }, "idiom" : "universal" }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Global functions/ConditionalModifier.swift Sun Jun 20 19:52:21 2021 +0200 @@ -0,0 +1,19 @@ +// +// ConditionalModifier.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 20/6/21. +// + +import SwiftUI + +extension View { + @ViewBuilder + func `if`<Content: View>(_ conditional: Bool, content: (Self) -> Content) -> some View { + if conditional { + content(self) + } else { + self + } + } +}
--- a/LazyBear/LaunchScreen.storyboard Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/LaunchScreen.storyboard Sun Jun 20 19:52:21 2021 +0200 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> - <device id="retina6_1" orientation="portrait" appearance="light"/> + <device id="retina6_7" orientation="portrait" appearance="light"/> <dependencies> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/> <capability name="Named colors" minToolsVersion="9.0"/> @@ -13,12 +13,12 @@ <objects> <viewController id="01J-lp-oVM" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> - <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> + <rect key="frame" x="0.0" y="0.0" width="428" height="926"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="launchLogo" translatesAutoresizingMaskIntoConstraints="NO" id="0zr-qc-AXd" userLabel="default"> - <rect key="frame" x="16" y="346" width="382" height="204"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <rect key="frame" x="145" y="398" width="137" height="130"/> + <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/> </imageView> </subviews> <viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/> @@ -27,7 +27,7 @@ </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="52.173913043478265" y="375"/> + <point key="canvasLocation" x="50.467289719626166" y="374.51403887688986"/> </scene> </scenes> <resources>
--- a/LazyBear/Views/Company/CompanyView.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Company/CompanyView.swift Sun Jun 20 19:52:21 2021 +0200 @@ -45,7 +45,7 @@ KeyStatsHelper(keyStats: company.data.keyStats) } } - .background(Color(.systemGray6).edgesIgnoringSafeArea(.all)) + .background(Color("customBackground").edgesIgnoringSafeArea(.all)) .navigationTitle(symbol.uppercased()) } } else {
--- a/LazyBear/Views/Company/Helpers/ChartHelper.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/ChartHelper.swift Sun Jun 20 19:52:21 2021 +0200 @@ -36,6 +36,7 @@ let dates = historicalPrices.compactMap { $0.date } if company.showChart { LineChartView(data: prices, dates: dates, hours: nil, dragGesture: true) + .padding(.bottom) } else { Spacer() ProgressView()
--- a/LazyBear/Views/Company/Helpers/CustomRectangleBox.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/CustomRectangleBox.swift Sun Jun 20 19:52:21 2021 +0200 @@ -8,10 +8,15 @@ import SwiftUI struct CustomRectangleBox: View { + @Environment(\.colorScheme) private var colorScheme + var body: some View { RoundedRectangle(cornerRadius: 15) - .foregroundColor(.white) - .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + .foregroundColor(Color("customSecondaryBackground")) + .if(colorScheme == .light) { content in + content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + } + } }
--- a/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift Sun Jun 20 19:52:21 2021 +0200 @@ -11,11 +11,12 @@ var keyStats: KeyStatsModel? let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") @State private var showList = false + @Environment(\.colorScheme) private var colorScheme var body: some View { if let keyStats = keyStats { ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing: 40) { + HStack(spacing: 20) { let mirror = Mirror(reflecting: keyStats) ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class @@ -26,8 +27,10 @@ Button(action: { showList = true }) { Capsule() .frame(width: 250, height: 40) - .foregroundColor(.white) - .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + .foregroundColor(Color("customSecondaryBackground")) + .if(colorScheme == .light) { content in + content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + } .overlay( HStack { Text("\(displayWords.keyStats[label]!):")
--- a/LazyBear/Views/Home/Helpers/CurrencyItem.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/CurrencyItem.swift Sun Jun 20 19:52:21 2021 +0200 @@ -9,10 +9,14 @@ struct CurrencyItem: View { var currency: CurrencyModel + @Environment(\.colorScheme) private var colorScheme var body: some View { RoundedRectangle(cornerRadius: 8) - .foregroundColor(Color(.secondarySystemBackground)) + .foregroundColor(Color("customSecondaryBackground")) + .if(colorScheme == .light) { content in + content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + } .frame(width: 330, height: 50) .overlay( HStack {
--- a/LazyBear/Views/Home/Helpers/SectorRow.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/SectorRow.swift Sun Jun 20 19:52:21 2021 +0200 @@ -20,7 +20,7 @@ Text("Real-time data") .font(.caption) .opacity(0.5) - .padding(.horizontal) + .padding([.horizontal, .bottom]) ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) {
--- a/LazyBear/Views/Home/Helpers/StockItem.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/StockItem.swift Sun Jun 20 19:52:21 2021 +0200 @@ -10,12 +10,16 @@ struct StockItem: View { var company: CompanyModel + @Environment(\.colorScheme) private var colorScheme var body: some View { RoundedRectangle(cornerRadius: 20) - .foregroundColor(Color(.secondarySystemBackground)) + .foregroundColor(Color("customSecondaryBackground")) .aspectRatio(0.8, contentMode: .fit) .clipShape(RoundedRectangle(cornerRadius: 20)) + .if(colorScheme == .light) { content in + content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) + } .overlay( VStack(alignment: .leading) { Group {
--- a/LazyBear/Views/Home/HomeView.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Home/HomeView.swift Sun Jun 20 19:52:21 2021 +0200 @@ -24,39 +24,41 @@ var body: some View { if home.showView { NavigationView { - List { - if let sectorPerformance = home.data.sectorPerformance { - SectorRow(sectorPerformance: sectorPerformance) - .listRowInsets(EdgeInsets()) - } - - if let lists = home.data.lists { - let listNames = Array(lists.keys.sorted()) - ForEach(listNames, id: \.self) { listName in - StockRow(listName: listName, companies: lists[listName]!) + ScrollView(showsIndicators: false) { + VStack { + if let sectorPerformance = home.data.sectorPerformance { + SectorRow(sectorPerformance: sectorPerformance) + .listRowInsets(EdgeInsets()) + } + + if let lists = home.data.lists { + let listNames = Array(lists.keys.sorted()) + ForEach(listNames, id: \.self) { listName in + StockRow(listName: listName, companies: lists[listName]!) + .listRowInsets(EdgeInsets()) + } + } + + if let latestCurrencies = home.data.latestCurrencies { + CurrencyRow(latestCurrencies: latestCurrencies) .listRowInsets(EdgeInsets()) } } - - if let latestCurrencies = home.data.latestCurrencies { - CurrencyRow(latestCurrencies: latestCurrencies) - .listRowInsets(EdgeInsets()) - } - } - .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Restart timer - .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", .streaming) } /// Receive timer notification - .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer - .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") - .navigationBarTitleDisplayMode(.inline) - .navigationViewStyle(StackNavigationViewStyle()) - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: { showTradingDates = true }) { - Image(systemName: "calendar.badge.clock") + .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Restart timer + .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", .streaming) } /// Receive timer notification + .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer + .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: { showTradingDates = true }) { + Image(systemName: "calendar.badge.clock") + } } } } + .background(Color("customBackground").edgesIgnoringSafeArea(.all)) } + .navigationViewStyle(StackNavigationViewStyle()) .sheet(isPresented: $showTradingDates) { if let dates = home.data.tradingDates { TradingDates(dates: dates)
--- a/LazyBear/Views/Profile/ProfileView.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Profile/ProfileView.swift Sun Jun 20 19:52:21 2021 +0200 @@ -20,40 +20,43 @@ var body: some View { if profile.showView { NavigationView { - List { - if let apiCompanies = profile.data.quotes { - let watchlistsNames = Array(Set(watchlistCompanies.map { $0.watchlistName })).sorted() /// Get watchlistsNames in Core Data - ForEach(watchlistsNames, id: \.self) { watchlistName in - let companies = createWatchlistRow(apiCompanies, watchlistCompanies, watchlistName) - ProfileStockRow(watchlistName: watchlistName, companies: companies) + ScrollView(showsIndicators: false) { + VStack { + if let apiCompanies = profile.data.quotes { + let watchlistsNames = Array(Set(watchlistCompanies.map { $0.watchlistName })).sorted() /// Get watchlistsNames in Core Data + ForEach(watchlistsNames, id: \.self) { watchlistName in + let companies = createWatchlistRow(apiCompanies, watchlistCompanies, watchlistName) + ProfileStockRow(watchlistName: watchlistName, companies: companies) + } + .listRowInsets(EdgeInsets()) + .onAppear { /// Request API again when Core Data changes to update the list + refreshList() + } } - .listRowInsets(EdgeInsets()) - .onAppear { /// Request API again when Core Data changes to update the list - refreshList() + } + .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Start timer + .onDisappear { self.timer.upstream.connect().cancel() } /// Stop timer + .onReceive(timer) { _ in + if !showCreateNewWatchlist { + prepareUrl(.streaming) + } + } + .navigationTitle("My profile") + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: { showCreateNewWatchlist = true }) { + Image(systemName: "plus") + } } } } - .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Start timer - .onDisappear { self.timer.upstream.connect().cancel() } /// Stop timer - .onReceive(timer) { _ in - if !showCreateNewWatchlist { - prepareUrl(.streaming) - } - } - .navigationTitle("My profile") - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: { showCreateNewWatchlist = true }) { - Image(systemName: "plus") - } - } + .background(Color("customBackground").edgesIgnoringSafeArea(.all)) + .fullScreenCover(isPresented: $showCreateNewWatchlist) { + WatchlistCreator() + .environment(\.managedObjectContext, self.moc) } } - .fullScreenCover(isPresented: $showCreateNewWatchlist) { - WatchlistCreator() - .environment(\.managedObjectContext, self.moc) - } + .navigationViewStyle(StackNavigationViewStyle()) } else { ProgressView() .onAppear { prepareUrl(.initial) }
--- a/LazyBear/Views/Search/SearchView.swift Sun Jun 20 16:58:36 2021 +0200 +++ b/LazyBear/Views/Search/SearchView.swift Sun Jun 20 19:52:21 2021 +0200 @@ -43,6 +43,7 @@ encodeAndRequest(searchedText) }) } + .background(Color("customBackground").edgesIgnoringSafeArea(.all)) .navigationViewStyle(StackNavigationViewStyle()) }