diff --git a/DXFeedFramework.xcodeproj/project.pbxproj b/DXFeedFramework.xcodeproj/project.pbxproj index 53681499d..94c33874b 100644 --- a/DXFeedFramework.xcodeproj/project.pbxproj +++ b/DXFeedFramework.xcodeproj/project.pbxproj @@ -205,7 +205,6 @@ 6469F8C82A3B25C900846831 /* MarketEvent+Access.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8C72A3B25C900846831 /* MarketEvent+Access.swift */; }; 6469F8CF2A3B300A00846831 /* MetricCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8CB2A3B2F1200846831 /* MetricCell.swift */; }; 6469F8D02A3B301C00846831 /* TimeInterval+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8CD2A3B2F9900846831 /* TimeInterval+Ext.swift */; }; - 6469F8D32A3B401700846831 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8D22A3B401700846831 /* Colors.swift */; }; 6469F8D42A3B401700846831 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8D22A3B401700846831 /* Colors.swift */; }; 6469F8D52A3B401700846831 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8D22A3B401700846831 /* Colors.swift */; }; 6469F8D62A3B408900846831 /* Endpoint+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64B6277C2A3762D000196D07 /* Endpoint+Ext.swift */; }; @@ -220,10 +219,14 @@ 647A513D2BE4DDB600B8B8C9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 647A51372BE4DDB600B8B8C9 /* Assets.xcassets */; }; 647A513E2BE4DDB600B8B8C9 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 647A51392BE4DDB600B8B8C9 /* Preview Assets.xcassets */; }; 647A513F2BE4DDB600B8B8C9 /* DXFeedCandleChartMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647A513B2BE4DDB600B8B8C9 /* DXFeedCandleChartMacApp.swift */; }; - 647A51412BE4DF3700B8B8C9 /* CandleStickChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F42002BDFE25D00A2176D /* CandleStickChart.swift */; }; 647A51442BE4DFD600B8B8C9 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 646979712A3B5AF60003A9BA /* Colors.xcassets */; }; 647A51452BE4E02700B8B8C9 /* CandleStickChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F42002BDFE25D00A2176D /* CandleStickChart.swift */; }; 647A51482BE4EE0600B8B8C9 /* CandleStickChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F42002BDFE25D00A2176D /* CandleStickChart.swift */; }; + 647A51492BE4F71700B8B8C9 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8D22A3B401700846831 /* Colors.swift */; }; + 647A514F2BE5113A00B8B8C9 /* Color+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647A514B2BE5102800B8B8C9 /* Color+Ext.swift */; }; + 647A51502BE5129200B8B8C9 /* Color+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647A514B2BE5102800B8B8C9 /* Color+Ext.swift */; }; + 647A51512BE512E100B8B8C9 /* CandleStickChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643F42002BDFE25D00A2176D /* CandleStickChart.swift */; }; + 647A51532BE5141600B8B8C9 /* Color+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647A514B2BE5102800B8B8C9 /* Color+Ext.swift */; }; 64820AAF2BB2E26100BDFD0B /* DXOtcMarketOrderTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64820AAE2BB2E26100BDFD0B /* DXOtcMarketOrderTest.swift */; }; 6482F3D12BA492A60079AC3D /* SymbolsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6482F3D02BA492A60079AC3D /* SymbolsViewController.swift */; }; 6482F3D22BA492A60079AC3D /* SymbolsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6482F3D02BA492A60079AC3D /* SymbolsViewController.swift */; }; @@ -793,6 +796,7 @@ 647A51392BE4DDB600B8B8C9 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 647A513A2BE4DDB600B8B8C9 /* DXFeedCandleChartMac.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = DXFeedCandleChartMac.entitlements; sourceTree = ""; }; 647A513B2BE4DDB600B8B8C9 /* DXFeedCandleChartMacApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DXFeedCandleChartMacApp.swift; sourceTree = ""; }; + 647A514B2BE5102800B8B8C9 /* Color+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Ext.swift"; sourceTree = ""; }; 64820AAE2BB2E26100BDFD0B /* DXOtcMarketOrderTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXOtcMarketOrderTest.swift; sourceTree = ""; }; 6482F3D02BA492A60079AC3D /* SymbolsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolsViewController.swift; sourceTree = ""; }; 6482F3D62BA49AB70079AC3D /* AddSymbolsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSymbolsViewController.swift; sourceTree = ""; }; @@ -1436,6 +1440,7 @@ 647A51382BE4DDB600B8B8C9 /* Preview Content */, 647A513A2BE4DDB600B8B8C9 /* DXFeedCandleChartMac.entitlements */, 647A513B2BE4DDB600B8B8C9 /* DXFeedCandleChartMacApp.swift */, + 647A514B2BE5102800B8B8C9 /* Color+Ext.swift */, 643F42002BDFE25D00A2176D /* CandleStickChart.swift */, ); path = DXFeedCandleChartMac; @@ -2496,7 +2501,8 @@ buildActionMask = 2147483647; files = ( 647A513F2BE4DDB600B8B8C9 /* DXFeedCandleChartMacApp.swift in Sources */, - 647A51412BE4DF3700B8B8C9 /* CandleStickChart.swift in Sources */, + 647A51512BE512E100B8B8C9 /* CandleStickChart.swift in Sources */, + 647A51532BE5141600B8B8C9 /* Color+Ext.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2518,6 +2524,7 @@ files = ( 647A51452BE4E02700B8B8C9 /* CandleStickChart.swift in Sources */, 643F41F52BDFE1B000A2176D /* DXFeedCandleChartApp.swift in Sources */, + 647A51502BE5129200B8B8C9 /* Color+Ext.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2574,12 +2581,13 @@ 64B6273A2A375C0F00196D07 /* QuoteCell.swift in Sources */, 640F8A532BA9C8D600C7BE22 /* SymbolsDataProvider.swift in Sources */, 6482F3D72BA49AB70079AC3D /* AddSymbolsViewController.swift in Sources */, - 6469F8D32A3B401700846831 /* Colors.swift in Sources */, + 647A514F2BE5113A00B8B8C9 /* Color+Ext.swift in Sources */, 6469F8D62A3B408900846831 /* Endpoint+Ext.swift in Sources */, 64B6273B2A375C0F00196D07 /* PaddingLabel.swift in Sources */, 64B627402A375C0F00196D07 /* SceneDelegate.swift in Sources */, 647A51482BE4EE0600B8B8C9 /* CandleStickChart.swift in Sources */, 6469F8D82A3B4AA400846831 /* MetricCell.swift in Sources */, + 647A51492BE4F71700B8B8C9 /* Colors.swift in Sources */, 646D19E22A3C994000C82315 /* DXFTimer.swift in Sources */, 64B6273E2A375C0F00196D07 /* QuoteTableViewController.swift in Sources */, 64B627392A375C0F00196D07 /* AppDelegate.swift in Sources */, @@ -3254,7 +3262,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 17.2; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3289,7 +3297,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 17.2; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3519,7 +3527,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3553,7 +3561,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Samples/DXFeedCandleChart/DXFeedCandleChartApp.swift b/Samples/DXFeedCandleChart/DXFeedCandleChartApp.swift index f19e856ef..33a166dbd 100644 --- a/Samples/DXFeedCandleChart/DXFeedCandleChartApp.swift +++ b/Samples/DXFeedCandleChart/DXFeedCandleChartApp.swift @@ -11,7 +11,7 @@ import SwiftUI struct DXFeedCandleChartApp: App { var body: some Scene { WindowGroup { - CandleStickChart(symbol: "AAPL") + CandleStickChart(symbol: "AAPL", endpoint: nil) } } } diff --git a/Samples/DXFeedCandleChartMac/Assets.xcassets/AppIcon.appiconset/1024-mac.png b/Samples/DXFeedCandleChartMac/Assets.xcassets/AppIcon.appiconset/1024-mac.png new file mode 100644 index 000000000..593966c55 Binary files /dev/null and b/Samples/DXFeedCandleChartMac/Assets.xcassets/AppIcon.appiconset/1024-mac.png differ diff --git a/Samples/DXFeedCandleChartMac/CandleStickChart.swift b/Samples/DXFeedCandleChartMac/CandleStickChart.swift index 3f4b7cea7..e4457f912 100644 --- a/Samples/DXFeedCandleChartMac/CandleStickChart.swift +++ b/Samples/DXFeedCandleChartMac/CandleStickChart.swift @@ -86,7 +86,6 @@ struct StockPrice: Identifiable { self.high = Decimal(candle.high) self.low = Decimal(candle.low) } - } @@ -128,16 +127,20 @@ class CandleList: ObservableObject, SnapshotDelegate { @Published var candles: [StockPrice] - init(symbol: String) { + init(symbol: String, endpoint: DXEndpoint?) { self.symbol = symbol self.candles = [StockPrice]() - try? createSubscription() + try? createSubscription(endpoint: endpoint) fetchInfo() } - func createSubscription() throws { - endpoint = try DXEndpoint.create().connect("demo.dxfeed.com:7300") - feed = endpoint.getFeed() + func createSubscription(endpoint: DXEndpoint?) throws { + if let endpoint = endpoint { + self.endpoint = endpoint + } else { + self.endpoint = try DXEndpoint.create().connect("demo.dxfeed.com:7300") + } + feed = self.endpoint.getFeed() subscription = try feed?.createSubscription([Candle.self]) snapshotProcessor = SnapshotProcessor() snapshotProcessor.add(self) @@ -145,15 +148,18 @@ class CandleList: ObservableObject, SnapshotDelegate { } func fetchInfo() { - let reader = DXInstrumentProfileReader() - let result = try? reader.readFromFile(address: "https://demo:demo@tools.dxfeed.com/ipf?SYMBOL=\(symbol)") - guard let result = result else { - return - } - result.forEach { profile in - currency = profile.currency - descriptionString = profile.descriptionStr + DispatchQueue.global(qos: .background).async { + let reader = DXInstrumentProfileReader() + let result = try? reader.readFromFile(address: "https://demo:demo@tools.dxfeed.com/ipf?SYMBOL=\(self.symbol)") + guard let result = result else { + return + } + result.forEach { profile in + self.currency = profile.currency + self.descriptionString = profile.descriptionStr + } } + } func updateDate(date: Date, type: CandleType) { @@ -187,14 +193,13 @@ struct CandleStickChart: View { let dateFormatter: DateFormatter let symbol: String - init(symbol: String, type: CandleType = .month, date: Date? = nil) { + init(symbol: String, type: CandleType = .month, date: Date? = nil, endpoint: DXEndpoint?) { dateFormatter = DateFormatter() dateFormatter.dateStyle = DateFormatter.Style.short dateFormatter.timeStyle = DateFormatter.Style.none self.symbol = symbol - self.list = CandleList(symbol: symbol) - + self.list = CandleList(symbol: symbol, endpoint: endpoint) _type = State(initialValue: type) if let date = date { _date = State(initialValue: date) @@ -210,38 +215,38 @@ struct CandleStickChart: View { Section { chart.frame(height: max(reader.size.height/2, 300)) - }.listRowBackground(Color.cellBackground) + }.listRowBackground(Color.sectionBackground) Section("Chart parameters") { Picker("Candle type", selection: $type) { ForEach(CandleType.allCases, id: \.self) { category in Text(String(describing: category).capitalized).tag(category) } - }.onChange(of: type) { _, newValue in + }.onChange(of: type) { value in selectedPrice = nil - list.updateDate(date: date, type: newValue) - }.pickerStyle(SegmentedPickerStyle()) + list.updateDate(date: date, type: value) + } + .pickerStyle(SegmentedPickerStyle()) + .foregroundStyle(Color.labelText) - .foregroundStyle(.text) DatePicker( selection: $date, displayedComponents: [.date] ) { Text("Choose from time") - }.onChange(of: date) { _, newValue in + }.onChange(of: date) { value in selectedPrice = nil - xAxisValues = CandleStickChart.calculateXaxisValues(firstValue: newValue) - list.updateDate(date: newValue, type: type) + xAxisValues = CandleStickChart.calculateXaxisValues(firstValue: value) + list.updateDate(date: value, type: type) } .datePickerStyle(.compact) - .foregroundStyle(.text) + .foregroundStyle(Color.labelText) - } - .listRowBackground(Color.cellBackground) - .listRowSeparator(.hidden) + }.listRowSeparator(.hidden) + .listRowBackground(Color.sectionBackground) } .preferredColorScheme(.dark) - .background(.tableBackground) + .background(Color.viewBackground) .scrollContentBackground(.hidden) } @@ -322,7 +327,7 @@ struct CandleStickChart: View { .frame(width: boxWidth, alignment: .leading) .background { RoundedRectangle(cornerRadius: 13) - .fill(Color.priceBackground) + .fill(Color.infoBackground) .foregroundStyle(.thickMaterial) .padding(.horizontal, -8) .padding(.vertical, -4) diff --git a/Samples/DXFeedCandleChartMac/Color+Ext.swift b/Samples/DXFeedCandleChartMac/Color+Ext.swift new file mode 100644 index 000000000..177469f9a --- /dev/null +++ b/Samples/DXFeedCandleChartMac/Color+Ext.swift @@ -0,0 +1,24 @@ +// +// +// Copyright (C) 2024 Devexperts LLC. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +// + +import SwiftUI + +#if os(macOS) +extension Color { + static let viewBackground = Color.tableBackground + static let sectionBackground = Color.cellBackground + static let infoBackground = Color.priceBackground + static let labelText = Color.text +} +#elseif os(iOS) +extension Color { + static let viewBackground = Color(UIColor.tableBackground) + static let sectionBackground = Color(UIColor.cellBackground) + static let infoBackground = Color(UIColor.priceBackground) + static let labelText = Color(UIColor.text) +} +#endif diff --git a/Samples/DXFeedCandleChartMac/DXFeedCandleChartMacApp.swift b/Samples/DXFeedCandleChartMac/DXFeedCandleChartMacApp.swift index 7dcfae6d5..468996a6b 100644 --- a/Samples/DXFeedCandleChartMac/DXFeedCandleChartMacApp.swift +++ b/Samples/DXFeedCandleChartMac/DXFeedCandleChartMacApp.swift @@ -14,7 +14,8 @@ struct DXFeedCandleChartMacApp: App { WindowGroup { CandleStickChart(symbol: symbol, type: .week, - date: Calendar.current.date(byAdding: .year, value: -4, to: Date())) + date: Calendar.current.date(byAdding: .year, value: -4, to: Date()), + endpoint: nil) .navigationTitle("CandleChart: \(symbol)") } .defaultSize(width: 800, height: 800) diff --git a/Samples/QuoteTableApp/Base.lproj/Main.storyboard b/Samples/QuoteTableApp/Base.lproj/Main.storyboard index 1d98749a2..39ca5c55e 100644 --- a/Samples/QuoteTableApp/Base.lproj/Main.storyboard +++ b/Samples/QuoteTableApp/Base.lproj/Main.storyboard @@ -2,7 +2,6 @@ - @@ -59,7 +58,7 @@ - +