Mercurial > public > lazybear
changeset 233:108fe992c703
Fix bugs
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Tue, 02 Mar 2021 18:46:04 +0000 |
parents | 439e94a2200d |
children | 8240a874e35f |
files | LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/Functions/Request.swift LazyBear/Info.plist LazyBear/UI/NewsLanguagePicker.swift LazyBear/UI/NewsView.swift LazyBear/UI/Search.swift LazyBear/UI/Watchlist.swift |
diffstat | 8 files changed, 95 insertions(+), 106 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear.xcodeproj/project.pbxproj Tue Mar 02 18:46:04 2021 +0000 @@ -14,10 +14,11 @@ 9505764325ED670B00D548E4 /* blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 9505763D25ED670B00D548E4 /* blue.png */; }; 9505764425ED670B00D548E4 /* pink.png in Resources */ = {isa = PBXBuildFile; fileRef = 9505763E25ED670B00D548E4 /* pink.png */; }; 9505764525ED670B00D548E4 /* red.png in Resources */ = {isa = PBXBuildFile; fileRef = 9505763F25ED670B00D548E4 /* red.png */; }; - 9508479A25EBD340000106A9 /* TestPullScroll.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9508479925EBD340000106A9 /* TestPullScroll.swift */; }; 950B674925E99FA900BF8593 /* IconPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950B674825E99FA900BF8593 /* IconPicker.swift */; }; 950B674C25E9A03E00BF8593 /* alternativeIcons.json in Resources */ = {isa = PBXBuildFile; fileRef = 950B674B25E9A03E00BF8593 /* alternativeIcons.json */; }; 950B674F25E9A0AE00BF8593 /* IconModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950B674E25E9A0AE00BF8593 /* IconModel.swift */; }; + 9517626025EEB37E00733235 /* PriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9517625F25EEB37E00733235 /* PriceModel.swift */; }; + 9517626325EEBD3800733235 /* IexAttribution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9517626225EEBD3800733235 /* IexAttribution.swift */; }; 9549D63325E1903F0085C3CD /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 9549D63225E1903F0085C3CD /* Charts */; }; 9549D63625E191520085C3CD /* Normalize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9549D63525E191520085C3CD /* Normalize.swift */; }; 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */; }; @@ -67,12 +68,13 @@ 9505763D25ED670B00D548E4 /* blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = blue.png; sourceTree = "<group>"; }; 9505763E25ED670B00D548E4 /* pink.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pink.png; sourceTree = "<group>"; }; 9505763F25ED670B00D548E4 /* red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = red.png; sourceTree = "<group>"; }; - 9508479925EBD340000106A9 /* TestPullScroll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestPullScroll.swift; sourceTree = "<group>"; }; 950B674825E99FA900BF8593 /* IconPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconPicker.swift; sourceTree = "<group>"; }; 950B674B25E9A03E00BF8593 /* alternativeIcons.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = alternativeIcons.json; sourceTree = "<group>"; }; 950B674E25E9A0AE00BF8593 /* IconModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconModel.swift; sourceTree = "<group>"; }; 950BA46B25E944F500D065EF /* Production.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Production.xcconfig; sourceTree = "<group>"; }; 950BA46C25E944FC00D065EF /* Sandbox.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Sandbox.xcconfig; sourceTree = "<group>"; }; + 9517625F25EEB37E00733235 /* PriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceModel.swift; sourceTree = "<group>"; }; + 9517626225EEBD3800733235 /* IexAttribution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IexAttribution.swift; sourceTree = "<group>"; }; 9549D63525E191520085C3CD /* Normalize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Normalize.swift; sourceTree = "<group>"; }; 95672B8B25DDA54700DCBE4A /* LazyBear.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LazyBear.app; sourceTree = BUILT_PRODUCTS_DIR; }; 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyBearApp.swift; sourceTree = "<group>"; }; @@ -132,7 +134,6 @@ 950BA46D25E9450B00D065EF /* Tests */ = { isa = PBXGroup; children = ( - 9508479925EBD340000106A9 /* TestPullScroll.swift */, ); path = Tests; sourceTree = "<group>"; @@ -216,6 +217,7 @@ 95BFAE5325E2C52300A70EC3 /* HistoricalPriceModel.swift */, 95F045FD25E96AA1006A5A17 /* NewsLanguageModel.swift */, 950B674E25E9A0AE00BF8593 /* IconModel.swift */, + 9517625F25EEB37E00733235 /* PriceModel.swift */, ); path = Models; sourceTree = "<group>"; @@ -238,6 +240,7 @@ 95BFAE4A25E2AEA000A70EC3 /* HUD.swift */, 95BFAE5725E2C5A700A70EC3 /* HistoricalPriceView.swift */, 95BB43BF25EA667700B6C965 /* DateSelection.swift */, + 9517626225EEBD3800733235 /* IexAttribution.swift */, ); path = UI; sourceTree = "<group>"; @@ -361,15 +364,16 @@ 95B3E09F25E127D7007EFDE3 /* Request.swift in Sources */, 95F045FE25E96AA1006A5A17 /* NewsLanguageModel.swift in Sources */, 95BFAE5425E2C52300A70EC3 /* HistoricalPriceModel.swift in Sources */, - 9508479A25EBD340000106A9 /* TestPullScroll.swift in Sources */, 95BFAE5825E2C5A700A70EC3 /* HistoricalPriceView.swift in Sources */, 9549D63625E191520085C3CD /* Normalize.swift in Sources */, 95672B9125DDA54700DCBE4A /* ContentView.swift in Sources */, 95F0460425E96DBB006A5A17 /* UserSettings+CoreDataClass.swift in Sources */, 950B674F25E9A0AE00BF8593 /* IconModel.swift in Sources */, 958A733B25E00C3100FD7ECA /* Company+CoreDataProperties.swift in Sources */, + 9517626325EEBD3800733235 /* IexAttribution.swift in Sources */, 95ACB5AF25E03AA100A3CCC8 /* ThemeModel.swift in Sources */, 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */, + 9517626025EEB37E00733235 /* PriceModel.swift in Sources */, 958A734525E00D3D00FD7ECA /* CompanyRow.swift in Sources */, 95ABDD3525E166BA00310776 /* NewsView.swift in Sources */, 95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */, @@ -513,7 +517,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = LazyBear/LazyBear.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 13; DEVELOPMENT_ASSET_PATHS = "\"LazyBear/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES; @@ -538,7 +542,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = LazyBear/LazyBear.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 12; + CURRENT_PROJECT_VERSION = 13; DEVELOPMENT_ASSET_PATHS = "\"LazyBear/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES;
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/Functions/Request.swift Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/Functions/Request.swift Tue Mar 02 18:46:04 2021 +0000 @@ -7,33 +7,30 @@ import Foundation -class Network: ObservableObject { - @Published var showingProgress = false - - // Network request - func request<T: Decodable>(url: String, model: T.Type, completion: @escaping (_ result: T) -> Void) { - // We take some model data T.Type - guard let url = URL(string: url) else { - print("Invalid URL") - return +// Network request +func request<T: Decodable>(url: String, model: T.Type, completion: @escaping (_ result: T) -> Void) { + // We take some model data T.Type + guard let url = URL(string: url) else { + print("Invalid URL") + return + } + let request = URLRequest(url: url) + URLSession.shared.dataTask(with: request) { data, response, error in + if let data = data { + do { + // Decode response with the model passed + let decodedResponse = try JSONDecoder().decode(model, from: data) + DispatchQueue.main.async { + completion(decodedResponse) + } + return + } catch { + // Return error regarding the escaping code + print(error) + } } - let request = URLRequest(url: url) - URLSession.shared.dataTask(with: request) { data, response, error in - if let data = data { - do { - // Decode response with the model passed - let decodedResponse = try JSONDecoder().decode(model, from: data) - DispatchQueue.main.async { - //print(decodedResponse) - completion(decodedResponse) - } - return - } catch { - print(error) - } - } - print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") - } - .resume() + // Error with the request + print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") } + .resume() }
--- a/LazyBear/Info.plist Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/Info.plist Tue Mar 02 18:46:04 2021 +0000 @@ -21,60 +21,60 @@ <key>UIPrerenderedIcon</key> <false/> </dict> - <key>greenIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>green.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> - <key>pinkIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>pink.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> - <key>redIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>red.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> - <key>matteBlackIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>matteBlack.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> - <key>matteWhiteIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>matteWhite.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> - <key>graffitiIcon</key> - <dict> - <key>CFBundleIconFiles</key> - <array> - <string>graffiti.png</string> - </array> - <key>UIPrerenderedIcon</key> - <false/> - </dict> + <key>graffitiIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>graffiti.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + <key>greenIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>green.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + <key>matteBlackIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>matteBlack.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + <key>matteWhiteIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>matteWhite.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + <key>pinkIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>pink.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> + <key>redIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>red.png</string> + </array> + <key>UIPrerenderedIcon</key> + <false/> + </dict> </dict> <key>CFBundlePrimaryIcon</key> <dict>
--- a/LazyBear/UI/NewsLanguagePicker.swift Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/UI/NewsLanguagePicker.swift Tue Mar 02 18:46:04 2021 +0000 @@ -13,9 +13,9 @@ var body: some View { Picker("News language", selection: $language) { - ForEach(newsLanguages, id: \.name) { language in + ForEach(newsLanguages, id: \.code) { language in Text("\(language.flag) \(language.name)") - .tag(language.name) + .tag(language.code) } } .onChange(of: language, perform: { language in
--- a/LazyBear/UI/NewsView.swift Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/UI/NewsView.swift Tue Mar 02 18:46:04 2021 +0000 @@ -9,10 +9,8 @@ struct NewsView: View { var symbol: String - @State var news = [NewsModel]() - - @FetchRequest(entity: UserSettings.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)]) - var userSettings: FetchedResults<UserSettings> + @FetchRequest(entity: UserSettings.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)]) var userSettings: FetchedResults<UserSettings> + @State private var news = [NewsModel]() var body: some View { VStack(alignment: .leading) {
--- a/LazyBear/UI/Search.swift Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/UI/Search.swift Tue Mar 02 18:46:04 2021 +0000 @@ -15,10 +15,6 @@ var body: some View { NavigationView { - let colorNumber = ["1", "2", "3", "4", "5"] - // Iterate over and over through this list to print the color for every row - // Color names are from 1 to 5 - let list = filterList() List(list.indices, id: \.self) { i in let name = list[i].securityName ?? "-" @@ -26,8 +22,7 @@ NavigationLink(destination: CompanyView(hudManager: hudManager, name: name, symbol: symbol) .navigationTitle(symbol) ) { - // Pass color number to the row - CompanyRow(symbol: symbol, name: name, rowNumber: i % colorNumber.count) + CompanyRow(symbol: symbol, name: name, rowNumber: i % 5) } } .navigationBarSearch(self.$company)
--- a/LazyBear/UI/Watchlist.swift Tue Mar 02 18:45:55 2021 +0000 +++ b/LazyBear/UI/Watchlist.swift Tue Mar 02 18:46:04 2021 +0000 @@ -12,22 +12,17 @@ @ObservedObject var hudManager: HUDManager @Environment(\.managedObjectContext) private var moc @FetchRequest(entity: Company.entity(), sortDescriptors: []) var companies: FetchedResults<Company> - @Environment(\.editMode) var mode var body: some View { NavigationView { - // Iterate over and over through this list to print the color for every row - // Color names are from 1 to 5 - let colorNumber = ["1", "2", "3", "4", "5"] List { - ForEach(companies.indices) { i in + ForEach(companies.indices, id: \.self) { i in let name = companies[i].name let symbol = companies[i].symbol NavigationLink(destination: CompanyView(hudManager: hudManager, name: name, symbol: symbol) .navigationTitle(symbol) ) { - // Pass color number to the row - CompanyRow(symbol: symbol, name: name, rowNumber: i % colorNumber.count) + CompanyRow(symbol: symbol, name: name, rowNumber: i % 5) } } .onDelete(perform: removeCompany)