comparison LazyBear/Views/Profile/Helpers/WatchlistCreatorRow.swift @ 430:c78d5b5b3bda

Minor updates
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 19 Jun 2021 16:21:26 +0200
parents 0a4c399170c4
children c6913f0ce46e
comparison
equal deleted inserted replaced
429:e4ca9898b79b 430:c78d5b5b3bda
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct WatchlistCreatorRow: View { 10 struct WatchlistCreatorRow: View {
11 var company: SearchResponse 11 var company: SearchResponse
12 @Binding var presentationMode: PresentationMode 12 @Binding var watchlistCreatorListPresentation: PresentationMode
13 @ObservedObject var watchlistCreatorClass: WatchlistCreatorClass 13 @ObservedObject var watchlistCreatorClass: WatchlistCreatorClass
14 14
15 var body: some View { 15 var body: some View {
16 Button(action: { saveCompany() }) { 16 Button(action: { saveCompany() }) {
17 HStack { 17 HStack {
39 /* 39 /*
40 Save company when it's selected and dismiss view 40 Save company when it's selected and dismiss view
41 */ 41 */
42 private func saveCompany() { 42 private func saveCompany() {
43 watchlistCreatorClass.companies.append(company) 43 watchlistCreatorClass.companies.append(company)
44 $presentationMode.wrappedValue.dismiss() 44 $watchlistCreatorListPresentation.wrappedValue.dismiss()
45 } 45 }
46 } 46 }
47 47
48 struct WatchlistCreatorRow_Previews: PreviewProvider { 48 struct WatchlistCreatorRow_Previews: PreviewProvider {
49 @Environment(\.presentationMode) static var presentationMode 49 @Environment(\.presentationMode) static var presentationMode
50 50
51 static var previews: some View { 51 static var previews: some View {
52 WatchlistCreatorRow(company: SearchResponse(currency: "USD", exchange: nil, region: "US", securityName: "Apple Inc", symbol: "AAPL"), presentationMode: presentationMode, watchlistCreatorClass: WatchlistCreatorClass()) 52 WatchlistCreatorRow(company: SearchResponse(currency: "USD", exchange: nil, region: "US", securityName: "Apple Inc", symbol: "AAPL"), watchlistCreatorListPresentation: presentationMode, watchlistCreatorClass: WatchlistCreatorClass())
53 } 53 }
54 } 54 }