Mercurial > public > simoleon
comparison Simoleon/Helpers/CurrencyRow.swift @ 150:6eac99e99b96
Add error handling to read json function
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Thu, 19 Aug 2021 19:12:56 +0100 |
parents | 04feeb708833 |
children | 2584fd74235a |
comparison
equal
deleted
inserted
replaced
149:07b5d7386e6e | 150:6eac99e99b96 |
---|---|
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct CurrencyRow: View { | 10 struct CurrencyRow: View { |
11 var currencyPairName: String | 11 var currencyPairName: String |
12 var isLocked: Bool? | 12 var isLocked: Bool? |
13 let currencyMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") | |
14 | 13 |
15 var body: some View { | 14 var body: some View { |
16 HStack { | 15 HStack { |
16 let currencyMetadata: [String: CurrencyMetadataModel] = try! read(json: "CurrencyMetadata.json") | |
17 let currencies = currencyPairName.split(separator: "/") | 17 let currencies = currencyPairName.split(separator: "/") |
18 Image(currencyMetadata[String(currencies[0])]!.flag) | 18 Image(currencyMetadata[String(currencies[0])]!.flag) |
19 .resizable() | 19 .resizable() |
20 .aspectRatio(contentMode: .fill) | 20 .aspectRatio(contentMode: .fill) |
21 .frame(width: 30, height: 30) | 21 .frame(width: 30, height: 30) |