Skip to content

Commit

Permalink
Update to SDK v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoly Petrov authored and Sergey Lagner committed Mar 21, 2021
1 parent 7e718d1 commit 84fa856
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@
repositoryURL = "https://github.com/2gis/native-sdk-ios-swift-package.git";
requirement = {
kind = exactVersion;
version = 0.7.2;
version = 0.8.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/2gis/native-sdk-ios-swift-package.git",
"state": {
"branch": null,
"revision": "8a87d506a618134187410814aa10ec66fb4e8dc0",
"version": "0.7.2"
"revision": "6f770e55a6d65abfadb6fdfbbc364a6c26af3066",
"version": "0.8.0"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions app.xcodeproj/xcshareddata/xcschemes/app.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
12 changes: 6 additions & 6 deletions app/Extensions/RenderedObjectInfo+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ extension RenderedObjectInfo: CustomStringConvertible {
let pointDescription = self.closestMapPoint.description
switch self.item.item {
case let dgisMapObject as DgisMapObject:
return "Id: \(dgisMapObject.id().value)"
return "Id: \(dgisMapObject.id.value)"
case let searchResult as SearchResultMarkerObject:
if let id = searchResult.id() {
if let id = searchResult.id {
return "Id: \(id.value)"
} else {
return searchResult.markerPosition().description
return searchResult.markerPosition.description
}
case let cluster as ClusterObject:
return "Objects count: \(cluster.objectCount())"
return "Objects count: \(cluster.objectCount)"
case let route as RouteMapObject:
return route.route()?.description ?? pointDescription
return route.route?.description ?? pointDescription
case let routePoint as RoutePointMapObject:
return routePoint.route()?.description ?? pointDescription
return routePoint.route?.description ?? pointDescription
case is MyLocationMapObject, is GeometryMapObject:
return pointDescription
default:
Expand Down
2 changes: 1 addition & 1 deletion app/Extensions/TrafficRoute+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import PlatformSDK
extension TrafficRoute: CustomStringConvertible {

public var description: String {
"Distance: \(self.length().millimeters * 1000)m"
"Distance: \(self.length.millimeters * 1000)m"
}
}
18 changes: 12 additions & 6 deletions app/MapObjectCardView/MapObjectCardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,23 @@ final class MapObjectCardViewModel: ObservableObject {
case let marker as Marker:
self.fetchInfo(marker: marker)
default:
self.fetchInfo(genericMapObject: mapObject)
self.fetchInfo(objectInfo: self.objectInfo)
}
}

private func fetchInfo(dgisMapObject object: DgisMapObject) {
self.getDirectoryObjectCancellable = object.directoryObject().sinkOnMainThread(
self.getDirectoryObjectCancellable = object.directoryObject.sinkOnMainThread(
receiveValue: {
[weak self] directoryObject in
guard let directoryObject = directoryObject else { return }

self?.title = directoryObject.title()
self?.description = "ID: \(object.id().value)"
self?.title = directoryObject.title
self?.description = """
\(directoryObject.subtitle)
\(directoryObject.formattedAddress(type: .short)?.streetAddress ?? "(no address)")
\(directoryObject.markerPosition?.description ?? "(no location)")
ID: \(object.id.value)
"""
},
failure: { error in
print("Unable to fetch a directory object. Error: \(error).")
Expand All @@ -59,7 +64,8 @@ final class MapObjectCardViewModel: ObservableObject {
self.description = "\(marker.position)"
}

private func fetchInfo(genericMapObject object: MapObject) {
self.title = String(describing: object)
private func fetchInfo(objectInfo: RenderedObjectInfo) {
self.title = String(describing: type(of: objectInfo))
self.description = String(describing: objectInfo)
}
}
2 changes: 1 addition & 1 deletion app/Marker/MarkerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final class MarkerViewModel: ObservableObject {
}

func addMarkers(text: String) {
let flatPoint = self.map.camera.position().value.point
let flatPoint = self.map.camera.position.value.point
let point = GeoPointWithElevation(
latitude: flatPoint.latitude,
longitude: flatPoint.longitude
Expand Down
4 changes: 2 additions & 2 deletions app/Route/RouteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ final class RouteViewModel: ObservableObject {
}

func setupPointA() {
_ = self.map.camera.position().sinkOnMainThread { [weak self] position in
_ = self.map.camera.position.sinkOnMainThread { [weak self] position in
self?.updatePointA(position.point)
}
}

func setupPointB() {
_ = self.map.camera.position().sinkOnMainThread { [weak self] position in
_ = self.map.camera.position.sinkOnMainThread { [weak self] position in
self?.updatePointB(position.point)
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Search/DirectoryObjectViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ struct DirectoryObjectViewModel {
let address: FormattedAddressViewModel?

init(object: DirectoryObject) {
self.navigationTitle = object.title()
self.title = object.title()
self.subtitle = object.subtitle()
self.navigationTitle = object.title
self.title = object.title
self.subtitle = object.subtitle

let formattedAddress = object.formattedAddress(type: .full)
self.address = formattedAddress.map(FormattedAddressViewModel.init)
Expand Down
4 changes: 2 additions & 2 deletions app/Search/SearchResultItemViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ struct SearchResultItemViewModel: Identifiable {
let object: DirectoryObjectViewModel

init(_ item: DirectoryObject) {
self.title = item.title()
self.subtitle = item.subtitle()
self.title = item.title
self.subtitle = item.subtitle
self.address = item.formattedAddress(type: .short)?.streetAddress
self.object = DirectoryObjectViewModel(object: item)
}
Expand Down
3 changes: 1 addition & 2 deletions app/Search/SearchResultViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ struct SearchResultViewModel {
}

init(_ result: SearchResult? = nil) {
self.items = result?.firstPage()?.items().compactMap({ $0 }).map(SearchResultItemViewModel.init)
?? []
self.items = result?.firstPage?.items.compactMap({ $0 }).map(SearchResultItemViewModel.init) ?? []
}
}

Expand Down
10 changes: 5 additions & 5 deletions app/Search/SearchService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ final class SearchService {
debugPrint(handler!)
dispatcher(.applyObjectSuggest(suggest))
case .performSearchHandler(let handler):
dispatcher(.searchQuery(handler!.searchQuery()!))
dispatcher(.searchQuery(handler!.searchQuery))
case .incompleteTextHandler(let handler):
dispatcher(.setQueryText(handler!.queryText()))
dispatcher(.setQueryText(handler!.queryText))
@unknown default:
fatalError()
}
Expand Down Expand Up @@ -63,7 +63,7 @@ final class SearchService {
let queryText = queryText
let builder = SearchQueryBuilder.fromQueryText(queryText: queryText)
let query = builder.build()
self.search(query: query!)(dispatcher)
self.search(query: query)(dispatcher)
}
}

Expand Down Expand Up @@ -98,7 +98,7 @@ final class SearchService {
guard !queryText.isEmpty else { return }

let builder = SuggestQueryBuilder.fromQueryText(queryText: queryText)
let query = builder.build()!
let query = builder.build()
self.suggest(query: query)(dispatcher)
}
}
Expand All @@ -113,7 +113,7 @@ final class SearchService {
let cancel = future.sink(receiveValue: {
[schedule = self.schedule] result in
schedule {
let suggestResultViewModel = self.makeSuggestResultViewModel(result: result!)
let suggestResultViewModel = self.makeSuggestResultViewModel(result: result)
dispatcher(.setSuggestResult(suggestResultViewModel))
}
}, failure: {
Expand Down
2 changes: 1 addition & 1 deletion app/Search/SuggestResultViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct SuggestResultViewModel {
init(
result: SuggestResult? = nil
) {
self.suggests = result?.suggests().compactMap({ $0 }).map(SuggestViewModel.init) ?? []
self.suggests = result?.suggests.compactMap({ $0 }).map(SuggestViewModel.init) ?? []
}
}

Expand Down
12 changes: 6 additions & 6 deletions app/Search/SuggestViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ struct SuggestViewModel: Identifiable, Hashable {
let object: DirectoryObjectViewModel?

init(suggest: Suggest) {
self.title = suggest.title()
self.subtitle = suggest.subtitle()
self.applyHandler = suggest.handler()
self.icon = makeIcon(for: suggest.handler())
self.object = suggest.handler().object.map(DirectoryObjectViewModel.init)
self.title = suggest.title
self.subtitle = suggest.subtitle
self.applyHandler = suggest.handler
self.icon = makeIcon(for: suggest.handler)
self.object = suggest.handler.object.map(DirectoryObjectViewModel.init)
}

static func ==(_ lhs: Self, rhs: Self) -> Bool {
Expand Down Expand Up @@ -46,7 +46,7 @@ private extension SuggestHandler {
var object: DirectoryObject? {
switch self {
case .objectHandler(let handler):
return handler!.item()
return handler?.item
default:
return nil
}
Expand Down

0 comments on commit 84fa856

Please sign in to comment.