Mercurial > public > lazybear
changeset 234:8240a874e35f
Implement NewsDetail view
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 03 Mar 2021 15:16:41 +0000 |
parents | 108fe992c703 |
children | 68be81b7d02e |
files | LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme LazyBear/UI/DetailNew.swift LazyBear/UI/NewsRow.swift |
diffstat | 6 files changed, 139 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Tue Mar 02 18:46:04 2021 +0000 +++ b/LazyBear.xcodeproj/project.pbxproj Wed Mar 03 15:16:41 2021 +0000 @@ -49,13 +49,15 @@ 95BFAE4B25E2AEA000A70EC3 /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFAE4A25E2AEA000A70EC3 /* HUD.swift */; }; 95BFAE4E25E2B0C200A70EC3 /* HUDManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFAE4D25E2B0C200A70EC3 /* HUDManager.swift */; }; 95BFAE5425E2C52300A70EC3 /* HistoricalPriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFAE5325E2C52300A70EC3 /* HistoricalPriceModel.swift */; }; - 95BFAE5825E2C5A700A70EC3 /* HistoricalPriceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFAE5725E2C5A700A70EC3 /* HistoricalPriceView.swift */; }; + 95BFAE5825E2C5A700A70EC3 /* ChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BFAE5725E2C5A700A70EC3 /* ChartView.swift */; }; + 95D34C2125EFD319006F4A81 /* DetailNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95D34C2025EFD319006F4A81 /* DetailNew.swift */; }; + 95D34C2725EFD5FE006F4A81 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 95D34C2625EFD5FE006F4A81 /* SDWebImageSwiftUI */; }; 95F045FB25E96A58006A5A17 /* newsLanguages.json in Resources */ = {isa = PBXBuildFile; fileRef = 95F045FA25E96A58006A5A17 /* newsLanguages.json */; }; 95F045FE25E96AA1006A5A17 /* NewsLanguageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F045FD25E96AA1006A5A17 /* NewsLanguageModel.swift */; }; 95F0460425E96DBB006A5A17 /* UserSettings+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460225E96DBB006A5A17 /* UserSettings+CoreDataClass.swift */; }; 95F0460525E96DBB006A5A17 /* UserSettings+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460325E96DBB006A5A17 /* UserSettings+CoreDataProperties.swift */; }; 95F0460825E9704F006A5A17 /* ThemePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460725E9704F006A5A17 /* ThemePicker.swift */; }; - 95F0460B25E970DB006A5A17 /* NewsLanguagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460A25E970DB006A5A17 /* NewsLanguagePicker.swift */; }; + 95F0460B25E970DB006A5A17 /* LanguagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460A25E970DB006A5A17 /* LanguagePicker.swift */; }; 95F0461025E976B5006A5A17 /* SettingRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F0460F25E976B5006A5A17 /* SettingRow.swift */; }; 95F0462825E98376006A5A17 /* default.png in Resources */ = {isa = PBXBuildFile; fileRef = 95F0462625E98376006A5A17 /* default.png */; }; /* End PBXBuildFile section */ @@ -106,13 +108,14 @@ 95BFAE4A25E2AEA000A70EC3 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = "<group>"; }; 95BFAE4D25E2B0C200A70EC3 /* HUDManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUDManager.swift; sourceTree = "<group>"; }; 95BFAE5325E2C52300A70EC3 /* HistoricalPriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricalPriceModel.swift; sourceTree = "<group>"; }; - 95BFAE5725E2C5A700A70EC3 /* HistoricalPriceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricalPriceView.swift; sourceTree = "<group>"; }; + 95BFAE5725E2C5A700A70EC3 /* ChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartView.swift; sourceTree = "<group>"; }; + 95D34C2025EFD319006F4A81 /* DetailNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailNew.swift; sourceTree = "<group>"; }; 95F045FA25E96A58006A5A17 /* newsLanguages.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = newsLanguages.json; sourceTree = "<group>"; }; 95F045FD25E96AA1006A5A17 /* NewsLanguageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsLanguageModel.swift; sourceTree = "<group>"; }; 95F0460225E96DBB006A5A17 /* UserSettings+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataClass.swift"; sourceTree = "<group>"; }; 95F0460325E96DBB006A5A17 /* UserSettings+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataProperties.swift"; sourceTree = "<group>"; }; 95F0460725E9704F006A5A17 /* ThemePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemePicker.swift; sourceTree = "<group>"; }; - 95F0460A25E970DB006A5A17 /* NewsLanguagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsLanguagePicker.swift; sourceTree = "<group>"; }; + 95F0460A25E970DB006A5A17 /* LanguagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguagePicker.swift; sourceTree = "<group>"; }; 95F0460F25E976B5006A5A17 /* SettingRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingRow.swift; sourceTree = "<group>"; }; 95F0462625E98376006A5A17 /* default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = default.png; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -122,6 +125,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 95D34C2725EFD5FE006F4A81 /* SDWebImageSwiftUI in Frameworks */, 958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */, 9549D63325E1903F0085C3CD /* Charts in Frameworks */, 95B3E0A625E1318D007EFDE3 /* SwiftlySearch in Frameworks */, @@ -226,21 +230,22 @@ isa = PBXGroup; children = ( 958A734125E00C9900FD7ECA /* Watchlist.swift */, + 958A734825E010F900FD7ECA /* Search.swift */, 958A734425E00D3D00FD7ECA /* CompanyRow.swift */, - 958A734825E010F900FD7ECA /* Search.swift */, + 95ACB5A825E0397B00A3CCC8 /* CompanyView.swift */, + 95ABDD3025E1602D00310776 /* PriceView.swift */, + 95BB43BF25EA667700B6C965 /* DateSelection.swift */, + 95BFAE5725E2C5A700A70EC3 /* ChartView.swift */, + 95ABDD3425E166BA00310776 /* NewsView.swift */, + 95ABDD3B25E1717300310776 /* NewsRow.swift */, + 95D34C2025EFD319006F4A81 /* DetailNew.swift */, 958A735E25E0311B00FD7ECA /* Settings.swift */, 95F0460725E9704F006A5A17 /* ThemePicker.swift */, - 95F0460A25E970DB006A5A17 /* NewsLanguagePicker.swift */, + 95F0460A25E970DB006A5A17 /* LanguagePicker.swift */, 950B674825E99FA900BF8593 /* IconPicker.swift */, 95F0460F25E976B5006A5A17 /* SettingRow.swift */, - 95ABDD3025E1602D00310776 /* PriceView.swift */, - 95ACB5A825E0397B00A3CCC8 /* CompanyView.swift */, - 95ABDD3425E166BA00310776 /* NewsView.swift */, - 95ABDD3B25E1717300310776 /* NewsRow.swift */, + 9517626225EEBD3800733235 /* IexAttribution.swift */, 95BFAE4A25E2AEA000A70EC3 /* HUD.swift */, - 95BFAE5725E2C5A700A70EC3 /* HistoricalPriceView.swift */, - 95BB43BF25EA667700B6C965 /* DateSelection.swift */, - 9517626225EEBD3800733235 /* IexAttribution.swift */, ); path = UI; sourceTree = "<group>"; @@ -282,6 +287,7 @@ packageProductDependencies = ( 95B3E0A525E1318D007EFDE3 /* SwiftlySearch */, 9549D63225E1903F0085C3CD /* Charts */, + 95D34C2625EFD5FE006F4A81 /* SDWebImageSwiftUI */, ); productName = LazyBear; productReference = 95672B8B25DDA54700DCBE4A /* LazyBear.app */; @@ -313,6 +319,7 @@ packageReferences = ( 95B3E0A425E1318D007EFDE3 /* XCRemoteSwiftPackageReference "SwiftlySearch" */, 9549D63125E1903F0085C3CD /* XCRemoteSwiftPackageReference "swiftui-charts" */, + 95D34C2525EFD5FE006F4A81 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */, ); productRefGroup = 95672B8C25DDA54700DCBE4A /* Products */; projectDirPath = ""; @@ -364,7 +371,7 @@ 95B3E09F25E127D7007EFDE3 /* Request.swift in Sources */, 95F045FE25E96AA1006A5A17 /* NewsLanguageModel.swift in Sources */, 95BFAE5425E2C52300A70EC3 /* HistoricalPriceModel.swift in Sources */, - 95BFAE5825E2C5A700A70EC3 /* HistoricalPriceView.swift in Sources */, + 95BFAE5825E2C5A700A70EC3 /* ChartView.swift in Sources */, 9549D63625E191520085C3CD /* Normalize.swift in Sources */, 95672B9125DDA54700DCBE4A /* ContentView.swift in Sources */, 95F0460425E96DBB006A5A17 /* UserSettings+CoreDataClass.swift in Sources */, @@ -377,7 +384,8 @@ 958A734525E00D3D00FD7ECA /* CompanyRow.swift in Sources */, 95ABDD3525E166BA00310776 /* NewsView.swift in Sources */, 95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */, - 95F0460B25E970DB006A5A17 /* NewsLanguagePicker.swift in Sources */, + 95F0460B25E970DB006A5A17 /* LanguagePicker.swift in Sources */, + 95D34C2125EFD319006F4A81 /* DetailNew.swift in Sources */, 95ABDD3125E1602D00310776 /* PriceView.swift in Sources */, 95BFAE4B25E2AEA000A70EC3 /* HUD.swift in Sources */, 95F0460525E96DBB006A5A17 /* UserSettings+CoreDataProperties.swift in Sources */, @@ -600,6 +608,14 @@ minimumVersion = 1.2.3; }; }; + 95D34C2525EFD5FE006F4A81 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.1; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -613,6 +629,11 @@ package = 95B3E0A425E1318D007EFDE3 /* XCRemoteSwiftPackageReference "SwiftlySearch" */; productName = SwiftlySearch; }; + 95D34C2625EFD5FE006F4A81 /* SDWebImageSwiftUI */ = { + isa = XCSwiftPackageProductDependency; + package = 95D34C2525EFD5FE006F4A81 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */; + productName = SDWebImageSwiftUI; + }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Tue Mar 02 18:46:04 2021 +0000 +++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Wed Mar 03 15:16:41 2021 +0000 @@ -2,6 +2,24 @@ "object": { "pins": [ { + "package": "SDWebImage", + "repositoryURL": "https://github.com/SDWebImage/SDWebImage.git", + "state": { + "branch": null, + "revision": "a6b6e44eadf0d39250c10a7cc0e3b91d0bdb0e94", + "version": "5.10.4" + } + }, + { + "package": "SDWebImageSwiftUI", + "repositoryURL": "https://github.com/SDWebImage/SDWebImageSwiftUI.git", + "state": { + "branch": null, + "revision": "88f2d679b7c47d98f1d5dc4f23a5d28c665b97b7", + "version": "2.0.1" + } + }, + { "package": "SwiftlySearch", "repositoryURL": "https://github.com/thislooksfun/SwiftlySearch.git", "state": {
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Tue Mar 02 18:46:04 2021 +0000 +++ b/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Wed Mar 03 15:16:41 2021 +0000 @@ -31,7 +31,7 @@ </Testables> </TestAction> <LaunchAction - buildConfiguration = "Debug" + buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/UI/DetailNew.swift Wed Mar 03 15:16:41 2021 +0000 @@ -0,0 +1,49 @@ +// +// DetailNew.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 3/3/21. +// + +import SwiftUI +import SDWebImageSwiftUI + +struct DetailNew: View { + var new: NewsModel + + var body: some View { + NavigationView { + ScrollView(showsIndicators: false) { + VStack(alignment: .leading) { + Text(new.headline ?? "") + .font(.title2) + .fontWeight(.semibold) + .padding(.horizontal) + .padding(.top) + + VStack(alignment: .leading) { + WebImage(url: URL(string: new.image ?? "")) + .resizable() + .indicator(.activity) + .scaledToFit() + + Text(new.summary ?? "") + .padding(.horizontal) + + Link("Read the full story", destination: URL(string: new.url ?? "")!) + .padding(.horizontal) + .padding(.top) + } + } + } + .navigationTitle(new.source ?? "-") + .navigationBarTitleDisplayMode(.inline) + } + } +} + +struct DetailNew_Previews: PreviewProvider { + static var previews: some View { + DetailNew(new: NewsModel(datetime: 1613838000000, headline: "As Facebook, Microsoft, Apple, Uber, Amazon, and others play larger roles in OpenStreetMap, hobbyists fear private sector will overshadow their work (Corey Dickinson/Bloomberg)", source: "Techmeme", url: "https://cloud.iexapis.com/v1/news/article/d760b0bc-42f0-4ed0-a721-a7691eeaa132", summary: "Corey Dickinson / Bloomberg : As Facebook, Microsoft, Apple, Uber, Amazon, and others play larger roles in OpenStreetMap, hobbyists fear private sector will overshadow their work — What do Lyft, Facebook, the International Red Cross, the U.N., the government of Nepal and Pokémon Go have in common?", image: "https://cloud.iexapis.com/v1/news/image/d760b0bc-42f0-4ed0-a721-a7691eeaa132")) + } +}
--- a/LazyBear/UI/NewsRow.swift Tue Mar 02 18:46:04 2021 +0000 +++ b/LazyBear/UI/NewsRow.swift Wed Mar 03 15:16:41 2021 +0000 @@ -9,40 +9,48 @@ struct NewsRow: View { var new: NewsModel + @State var showingDetail = false var body: some View { - HStack { - VStack(alignment: .leading) { - if let source = new.source { - Text(source.uppercased()) - .font(.caption) - .opacity(0.5) + + Button(action: { self.showingDetail = true }) { + HStack { + VStack(alignment: .leading) { + if let source = new.source { + Text(source.uppercased()) + .font(.caption) + .opacity(0.5) + + } + + if let headline = new.headline { + Text(headline) + .font(.headline) + .lineLimit(4) + } - } - - if let headline = new.headline { - Text(headline) - .font(.headline) - .lineLimit(4) - } - - if let summary = new.summary { - Text(summary) - .opacity(0.5) - .font(.subheadline) - .lineLimit(1) - .padding(.bottom, 5) - } - - if (new.datetime != nil) { - let humanDate = convertDate() - Text("\(humanDate) ago") - .font(.caption2) - .opacity(0.5) + if let summary = new.summary { + Text(summary) + .opacity(0.5) + .font(.subheadline) + .lineLimit(1) + .padding(.bottom, 5) + } + + if (new.datetime != nil) { + let humanDate = convertDate() + Text("\(humanDate) ago") + .font(.caption2) + .opacity(0.5) + } } } } + .buttonStyle(PlainButtonStyle()) .padding(.horizontal) + .sheet(isPresented: $showingDetail) { + DetailNew(new: new) + } } // Cover Epoch time to human date