Mercurial > public > lazybear
changeset 61:3d81c34d56d3
Update DetailInsiders
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 20 Jan 2021 17:34:23 +0100 |
parents | 4b4fb0d84815 |
children | 9b84adfa89d4 |
files | LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Functions/ReadJson.swift lazybear/Models/FormDescription.swift lazybear/Supply views/InsiderDetail.swift |
diffstat | 5 files changed, 42 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Wed Jan 20 17:16:47 2021 +0100 +++ b/LazyBear.xcodeproj/project.pbxproj Wed Jan 20 17:34:23 2021 +0100 @@ -52,6 +52,8 @@ 95DF5197259DDD68003790B2 /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95DF5196259DDD68003790B2 /* AppInfo.swift */; }; 95DF519A259DE0E2003790B2 /* WhatsNew.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95DF5199259DE0E2003790B2 /* WhatsNew.swift */; }; 95DF519D259DE118003790B2 /* TipJar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95DF519C259DE118003790B2 /* TipJar.swift */; }; + 95E0287825B88F0B00020CF2 /* formDescription.json in Resources */ = {isa = PBXBuildFile; fileRef = 95E0287725B88F0B00020CF2 /* formDescription.json */; }; + 95E0287B25B88F3C00020CF2 /* FormDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E0287A25B88F3C00020CF2 /* FormDescription.swift */; }; 95F7CAF625ADC7B7009E0E7C /* LazyBear.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 95F7CAF425ADC7B7009E0E7C /* LazyBear.xcdatamodeld */; }; /* End PBXBuildFile section */ @@ -102,6 +104,8 @@ 95DF5196259DDD68003790B2 /* AppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; }; 95DF5199259DE0E2003790B2 /* WhatsNew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhatsNew.swift; sourceTree = "<group>"; }; 95DF519C259DE118003790B2 /* TipJar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipJar.swift; sourceTree = "<group>"; }; + 95E0287725B88F0B00020CF2 /* formDescription.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = formDescription.json; path = lazybear/Data/formDescription.json; sourceTree = SOURCE_ROOT; }; + 95E0287A25B88F3C00020CF2 /* FormDescription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FormDescription.swift; path = lazybear/Models/FormDescription.swift; sourceTree = SOURCE_ROOT; }; 95F7CAF525ADC7B7009E0E7C /* LazyBear.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LazyBear.xcdatamodel; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -179,6 +183,7 @@ 95AB4A7C259DCC0C0064C9C1 /* CompanyDataModel.swift */, 954D992425A2123B001F7F60 /* HistoricalPricesModel.swift */, 95A1ECB125A36230001D4A21 /* InsiderTransactionModel.swift */, + 95E0287A25B88F3C00020CF2 /* FormDescription.swift */, ); path = Models; sourceTree = "<group>"; @@ -186,6 +191,7 @@ 95AB4A71259DCAB20064C9C1 /* Data */ = { isa = PBXGroup; children = ( + 95E0287725B88F0B00020CF2 /* formDescription.json */, 954D992125A2105F001F7F60 /* companies.json */, ); path = Data; @@ -311,6 +317,7 @@ buildActionMask = 2147483647; files = ( 95B04EB72521236A000AD27F /* Assets.xcassets in Resources */, + 95E0287825B88F0B00020CF2 /* formDescription.json in Resources */, 954D992225A2105F001F7F60 /* companies.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -324,6 +331,7 @@ files = ( 95AB4A7A259DCBAE0064C9C1 /* ReadJson.swift in Sources */, 95DF5194259DDC45003790B2 /* AboutButton.swift in Sources */, + 95E0287B25B88F3C00020CF2 /* FormDescription.swift in Sources */, 959B940C25B6058E00EEB802 /* StockStats.swift in Sources */, 950B79F925B1CEA100E5DB5B /* PriceOverview.swift in Sources */, 959B940925B5F4BC00EEB802 /* LazyColumns.swift in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/Functions/ReadJson.swift Wed Jan 20 17:16:47 2021 +0100 +++ b/lazybear/Functions/ReadJson.swift Wed Jan 20 17:34:23 2021 +0100 @@ -11,6 +11,7 @@ // With this function I parse the local JSON file to read it and create a list with its items. let companiesData: [CompanyDataModel] = load("companies.json") +let formDescription: [FormDescription] = load("formDescription.json") func load<T: Decodable>(_ filename: String) -> T { let data: Data
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Models/FormDescription.swift Wed Jan 20 17:34:23 2021 +0100 @@ -0,0 +1,13 @@ +// +// FormDescription.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 20/1/21. +// + +import SwiftUI + +struct FormDescription: Hashable, Codable { + var transactionCode: String + var description: String +}
--- a/lazybear/Supply views/InsiderDetail.swift Wed Jan 20 17:16:47 2021 +0100 +++ b/lazybear/Supply views/InsiderDetail.swift Wed Jan 20 17:34:23 2021 +0100 @@ -9,6 +9,7 @@ struct InsiderDetail: View { @State var transaction: InsiderTransactionModel + @Environment(\.presentationMode) var detailPresentationMode var body: some View { NavigationView { @@ -30,8 +31,26 @@ SectionBody(image: "dollarsing.circle", data: data) SectionBody(image: "info.circle", data: "Type: " + transaction.transaction_type) } - + let transactionCode = transaction.transaction_type.components(separatedBy: "-")[0] + Section(header: Text("What is a (" + transactionCode + ") transaction type?")) { + HStack { + let transactionCodesArray = formDescription.map { $0.transactionCode } + let index = transactionCodesArray.firstIndex(of: transactionCode) + let description = formDescription[index!].description + Text(description) + } + } } + .navigationBarTitle("Transaction details") + .navigationBarItems(leading: + Button(action: { self.detailPresentationMode.wrappedValue.dismiss() } + ) { + Image(systemName: "multiply") + .resizable() + .frame(width: 25, height: 25) + + } + ) } } }