Commit f58f3a79 by Dmitriy Stepanets

Working on mapping the glances

parent 84d5202c
......@@ -55,6 +55,11 @@
CD39F2F525DE9571009FE398 /* ArrowButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD39F2F425DE9571009FE398 /* ArrowButton.swift */; };
CD3F6E6925FA59D4002DB99B /* ForecastDetailPeriodButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3F6E6825FA59D4002DB99B /* ForecastDetailPeriodButton.swift */; };
CD3F6E6C25FA5A90002DB99B /* PeriodButtonProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3F6E6B25FA5A90002DB99B /* PeriodButtonProtocol.swift */; };
CD427D27266F856700B4350A /* InMobiShortsSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D26266F856700B4350A /* InMobiShortsSource.framework */; };
CD427D28266F856700B4350A /* InMobiShortsSource.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D26266F856700B4350A /* InMobiShortsSource.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CD427D2A266F86C600B4350A /* ShortsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD427D29266F86C600B4350A /* ShortsManager.swift */; };
CD427D2C266F940500B4350A /* OneWeatherAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D2B266F940500B4350A /* OneWeatherAnalytics.framework */; };
CD427D2D266F940600B4350A /* OneWeatherAnalytics.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D2B266F940500B4350A /* OneWeatherAnalytics.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
CD4742D0261200500061AC95 /* TodayAlertCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4742CF261200500061AC95 /* TodayAlertCell.swift */; };
CD4F6A2A266663C300252FE1 /* Pods_1Weather.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B543196B99BA697763514F6 /* Pods_1Weather.framework */; };
CD4F6A2B266663C300252FE1 /* Pods_1Weather.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6B543196B99BA697763514F6 /* Pods_1Weather.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
......@@ -209,6 +214,7 @@
dstSubfolderSpec = 10;
files = (
CDFE45BD26566EF50021A29F /* WDTWeatherSource.framework in Embed Frameworks */,
CD427D28266F856700B4350A /* InMobiShortsSource.framework in Embed Frameworks */,
CD4F6A2B266663C300252FE1 /* Pods_1Weather.framework in Embed Frameworks */,
CEEF4101265E47FF00425D8F /* BlendFIPSSource.framework in Embed Frameworks */,
CE13B97C2626FB11007CBD4D /* PSMLocationSDK.xcframework in Embed Frameworks */,
......@@ -216,6 +222,7 @@
CD3884562657BA8B0070FD6F /* CoreDataStorage.framework in Embed Frameworks */,
CD3883C32657B6A10070FD6F /* BlendHealthSource.framework in Embed Frameworks */,
CD3884842657BBCC0070FD6F /* DelayedSaveStorage.framework in Embed Frameworks */,
CD427D2D266F940600B4350A /* OneWeatherAnalytics.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -290,6 +297,9 @@
CD39F2F425DE9571009FE398 /* ArrowButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrowButton.swift; sourceTree = "<group>"; };
CD3F6E6825FA59D4002DB99B /* ForecastDetailPeriodButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastDetailPeriodButton.swift; sourceTree = "<group>"; };
CD3F6E6B25FA5A90002DB99B /* PeriodButtonProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeriodButtonProtocol.swift; sourceTree = "<group>"; };
CD427D26266F856700B4350A /* InMobiShortsSource.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = InMobiShortsSource.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD427D29266F86C600B4350A /* ShortsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortsManager.swift; sourceTree = "<group>"; };
CD427D2B266F940500B4350A /* OneWeatherAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD4742CF261200500061AC95 /* TodayAlertCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayAlertCell.swift; sourceTree = "<group>"; };
CD55E0BA2615EE2400CC4DC7 /* PollutantView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollutantView.swift; sourceTree = "<group>"; };
CD5692B32653D46100A3CDBE /* SplashAnimationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashAnimationViewController.swift; sourceTree = "<group>"; };
......@@ -435,7 +445,9 @@
files = (
CE14445F2638B6CF008E2162 /* StoreKit.framework in Frameworks */,
CD4F6A2A266663C300252FE1 /* Pods_1Weather.framework in Frameworks */,
CD427D27266F856700B4350A /* InMobiShortsSource.framework in Frameworks */,
CD3883C22657B6A10070FD6F /* BlendHealthSource.framework in Frameworks */,
CD427D2C266F940500B4350A /* OneWeatherAnalytics.framework in Frameworks */,
CE13B97B2626FB11007CBD4D /* PSMLocationSDK.xcframework in Frameworks */,
CDFE45BC26566EF50021A29F /* WDTWeatherSource.framework in Frameworks */,
CD3884552657BA8B0070FD6F /* CoreDataStorage.framework in Frameworks */,
......@@ -1137,6 +1149,7 @@
CD6C22ED26677DBC00D75659 /* PushNotificationsManager.swift */,
CD6C22E926677BDF00D75659 /* ConfigManager.swift */,
87C171F325FF7A4000DA3464 /* PopularCitiesManager.swift */,
CD427D29266F86C600B4350A /* ShortsManager.swift */,
);
path = Network;
sourceTree = "<group>";
......@@ -1160,6 +1173,8 @@
DBFD169AA2AA6A3CB5B68BB5 /* Frameworks */ = {
isa = PBXGroup;
children = (
CD427D2B266F940500B4350A /* OneWeatherAnalytics.framework */,
CD427D26266F856700B4350A /* InMobiShortsSource.framework */,
CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */,
CD3884822657BBCC0070FD6F /* DelayedSaveStorage.framework */,
CD3884542657BA8B0070FD6F /* CoreDataStorage.framework */,
......@@ -1585,6 +1600,7 @@
CD37D3F6260DF5BA002669D6 /* SettingsViewModel.swift in Sources */,
CD17C5F625D15B4400EE884E /* TodayViewController.swift in Sources */,
CD86245E25E646350097F3FB /* SunUvView.swift in Sources */,
CD427D2A266F86C600B4350A /* ShortsManager.swift in Sources */,
CDF8F12D26208E7B00DB384A /* MapCurrentTimeView.swift in Sources */,
CE6F5F0C263C8B3D00973137 /* SmartTextProvider.swift in Sources */,
CEC7D8EE2639FE2700B8836D /* OLInAppStoreManager.swift in Sources */,
......
......@@ -12,7 +12,7 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>55</integer>
<integer>57</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
......
......@@ -3,4 +3,38 @@
uuid = "55281C35-FE9F-4CED-865E-FBED0E7393F6"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "7E92F321-211B-4E2A-A0ED-7D8541E572CA"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
landmarkName = "updateShorts(completion:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "A47DA89D-0414-467A-9D69-CB580EA7F2F1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "80"
endingLineNumber = "80"
landmarkName = "updateShorts(completion:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
//
// ShortsManager.swift
// 1Weather
//
// Created by Dmitry Stepanets on 08.06.2021.
//
import Foundation
import OneWeatherCore
import InMobiShortsSource
import OneWeatherAnalytics
class ShortsManager {
static let shared = ShortsManager()
private let source = InMobiShortSource()
private let log = Logger(componentName: "ShortsManager")
private init() {}
func fetchShorts(completion:@escaping (_ result: Result<[ShortsItem], Error>) -> Void) {
source.updateShorts {[weak self] shortItems, error in
guard error == nil else {
self?.log.debug("Failed to update shorts \(String(describing: error?.localizedDescription))")
completion(.failure(error!))
return
}
guard let items = shortItems else {
self?.log.debug("Fetched shorts are empty")
return
}
completion(.success(items))
}
}
}
......@@ -70,17 +70,20 @@ class TodayDayTimesCell: UITableViewCell {
return
}
if stackView.arrangedSubviews.isEmpty {
for index in 0..<maxNumberOfItems {
let availableItemsCount = min(maxNumberOfItems, validDayTimeWeather.count)
if stackView.arrangedSubviews.count != availableItemsCount{
stackView.removeAll()
for index in 0..<availableItemsCount {
let view = DayTimeView(dayTimeWeather: validDayTimeWeather[index],
withSeparator: index != maxNumberOfItems - 1)
withSeparator: index != availableItemsCount - 1)
stackView.addArrangedSubview(view)
}
stackView.layoutIfNeeded()
return
}
if stackView.arrangedSubviews.count == maxNumberOfItems {
else {
//Just reload
for (index, arrangedSubview) in stackView.arrangedSubviews.enumerated() {
guard let dayTimeView = arrangedSubview as? DayTimeView else {
continue
......
......@@ -61,7 +61,10 @@ class TodayViewController: UIViewController {
}
@objc private func handleCityButton() {
self.coordinator.openLocationsSearch()
ShortsManager.shared.fetchShorts { result in
//
}
// self.coordinator.openLocationsSearch()
}
@objc private func handleNotificationButton() {
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
CD427D1F266F657900B4350A /* OneWeatherCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D1E266F657900B4350A /* OneWeatherCore.framework */; };
CD427D23266F715900B4350A /* OneWeatherAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD427D22266F715900B4350A /* OneWeatherAnalytics.framework */; };
CDFE3F12266E407A00E72910 /* InMobiShortsSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDFE3F08266E407A00E72910 /* InMobiShortsSource.framework */; };
CDFE3F17266E407A00E72910 /* InMobiShortsSourceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDFE3F16266E407A00E72910 /* InMobiShortsSourceTests.swift */; };
CDFE3F19266E407A00E72910 /* InMobiShortsSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFE3F0B266E407A00E72910 /* InMobiShortsSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -29,6 +31,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
CD427D1E266F657900B4350A /* OneWeatherCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD427D22266F715900B4350A /* OneWeatherAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CDFE3F08266E407A00E72910 /* InMobiShortsSource.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = InMobiShortsSource.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CDFE3F0B266E407A00E72910 /* InMobiShortsSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InMobiShortsSource.h; sourceTree = "<group>"; };
CDFE3F0C266E407A00E72910 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
......@@ -48,6 +52,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CD427D1F266F657900B4350A /* OneWeatherCore.framework in Frameworks */,
CD427D23266F715900B4350A /* OneWeatherAnalytics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -62,12 +68,22 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
CD427D1D266F657900B4350A /* Frameworks */ = {
isa = PBXGroup;
children = (
CD427D22266F715900B4350A /* OneWeatherAnalytics.framework */,
CD427D1E266F657900B4350A /* OneWeatherCore.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
CDFE3EFE266E407A00E72910 = {
isa = PBXGroup;
children = (
CDFE3F0A266E407A00E72910 /* InMobiShortsSource */,
CDFE3F15266E407A00E72910 /* InMobiShortsSourceTests */,
CDFE3F09266E407A00E72910 /* Products */,
CD427D1D266F657900B4350A /* Frameworks */,
);
sourceTree = "<group>";
};
......
......@@ -6,13 +6,144 @@
//
import Foundation
import OneWeatherCore
import OneWeatherAnalytics
public class InMobiShortSource {
private static let apiKey = "9b5f4682b74f75cbedb34ee235c988f9"
private static let region = "US"
private static let sdkV = "80000"
public enum InMobiShortSourceError: Error {
case badUrl
case invalidIds
case networkError(Error?)
case badServerResponse(Error?)
case dataEncodingError(String)
}
public class InMobiShortSource: ShortSource {
private let log = Logger(componentName: "InMobiShortSource")
private let baseURL = "https://in.api.glance.inmobi.com/api/v0/glance"
private let apiKey = "9b5f4682b74f75cbedb34ee235c988f9"
private let region = "US"
private let sdkV = "80000"
public init() {}
public func updateShorts(completion: @escaping ShortsSourceCompletion) {
self.getGlanceIds {[weak self] glanceIds, glanceIdsError in
guard let self = self else { return }
guard glanceIdsError == nil else {
completion(nil, glanceIdsError)
return
}
guard
let ids = glanceIds,
!ids.isEmpty
else {
self.log.debug("Glance IDs is empty")
completion(nil, InMobiShortSourceError.invalidIds)
return
}
var urlString = "https://in.api.glance.inmobi.com/api/v0/glance/data/ad?region=\(self.region)&sdkV=\(self.sdkV)&ids="
for (index, id) in ids.enumerated() {
urlString += id.glanceId
if index != ids.count - 1 {
urlString += ","
}
}
guard let updateURL = URL(string: urlString) else {
assertionFailure("Should never happen. The URL should be correct.")
return
}
var request = URLRequest(url: updateURL)
request.httpMethod = "GET"
request.addValue(self.apiKey, forHTTPHeaderField:"X-Api-Key")
let dataTask = URLSession.shared.dataTask(with: request) { data, response, error in
guard error == nil else {
self.log.debug("Network response: error \(String(describing: error))")
completion(nil, InMobiShortSourceError.networkError(error))
return
}
guard let data = data else {
self.log.debug("Network response: error Invalid data")
completion(nil, InMobiShortSourceError.dataEncodingError("Invalid data"))
return
}
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
do {
let glancesDict = try decoder.decode([String:[GlanceDetails]].self, from: data)
if let glanceDetailsArray = glancesDict["glances"] {
completion(glanceDetailsArray.map{self.toAppModel(glanceDetails: $0)}, nil)
}
else {
completion(nil, InMobiShortSourceError.dataEncodingError("Failed to decode glance details array"))
}
}
catch {
completion(nil, InMobiShortSourceError.dataEncodingError(error.localizedDescription))
}
}
dataTask.resume()
}
}
public func getShorts(completion: @escaping (_ shorts:[GlanceDetails]) -> Void) {
private func getGlanceIds(completion: @escaping (_ ids:[Glance]?, _ error:InMobiShortSourceError?) -> Void) {
let urlString = "\(self.baseURL)/updates/deef?region=\(self.region)&sdkV=\(self.sdkV)"
guard let updateURL = URL(string: urlString) else {
assertionFailure("Should never happen. The URL should be correct.")
return
}
var request = URLRequest(url: updateURL)
request.httpMethod = "GET"
request.addValue(self.apiKey, forHTTPHeaderField: "X-Api-Key")
let dataTask = URLSession.shared.dataTask(with: request) { data, response, error in
guard error == nil else {
self.log.debug("Network response: error \(String(describing: error))")
completion(nil, .networkError(error))
return
}
guard let data = data else {
self.log.debug("Network response: error Invalid data")
completion(nil, .dataEncodingError("Invalid data"))
return
}
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
do {
let glancesDict = try decoder.decode([String:[Glance]].self, from: data)
completion(glancesDict["updates"], nil)
}
catch {
completion(nil, .dataEncodingError(error.localizedDescription))
}
}
dataTask.resume()
}
private func toAppModel(glanceDetails:GlanceDetails) -> ShortsItem {
ShortsItem(id: glanceDetails.id,
images: glanceDetails.image.supportedImages.map{ .init(width: $0.width, height: $0.height, url: $0.url) },
updatedAtInSecs: glanceDetails.updatedAtInSecs,
startsAtInSecs: glanceDetails.startsAtInSecs,
endsAtInSecs: glanceDetails.endsAtInSecs,
shareURL: glanceDetails.shareURL,
title: glanceDetails.peekData.title,
summaryText: glanceDetails.peek.articlePeek.summary,
sourceName: glanceDetails.peekData.sourceName,
heartCount: glanceDetails.peekData.heartCount,
shortURL: glanceDetails.peekData.shortURL,
ctaText: glanceDetails.peekData.ctaText,
ctaURL: glanceDetails.peek.articlePeek.cta.url,
likeCount: glanceDetails.glanceInteractionDetails.likeCount,
shareCount: glanceDetails.glanceInteractionDetails.shareCount)
}
}
......@@ -7,12 +7,12 @@
import Foundation
public struct GlanceIteractionDetails: Codable {
struct GlanceInteractionDetails: Codable {
let likeCount: Int
let shareCount: Int
}
public struct GlanceDetails: Codable {
struct GlanceDetails: Codable {
public let id: String
public let image: GlanceImage
public let updatedAtInSecs: TimeInterval
......@@ -21,5 +21,5 @@ public struct GlanceDetails: Codable {
public let shareURL: URL?
public let peekData: PeekData
public let peek: Peek
public let glanceIteractionDetails: GlanceIteractionDetails
public let glanceInteractionDetails: GlanceInteractionDetails
}
......@@ -7,13 +7,13 @@
import Foundation
public struct GlanceImageFormat: Codable {
struct GlanceImageFormat: Codable {
let width:Int
let height:Int
let url:URL
}
public struct GlanceImage: Codable {
struct GlanceImage: Codable {
let id:String
let supportedImages:[GlanceImageFormat]
}
......@@ -7,7 +7,7 @@
import Foundation
public struct Peek: Codable {
struct Peek: Codable {
let articlePeek: ArticlePeek
}
......@@ -17,7 +17,7 @@ struct ArticlePeek: Codable {
}
struct GlanceCTA: Codable {
let url: URL
let url: URL?
let text: String
}
......@@ -7,10 +7,10 @@
import Foundation
public struct PeekData: Codable {
public let title:String
public let sourceName:String
public let heartCount:Int
public let shortURL:URL?
public let ctaText:String
struct PeekData: Codable {
let title:String
let sourceName:String
let heartCount:Int
let shortURL:URL?
let ctaText:String
}
......@@ -23,6 +23,8 @@
CD2D55E0265537DC007B70F4 /* NWSAlertInfoBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2D55DF265537DC007B70F4 /* NWSAlertInfoBlock.swift */; };
CD3883972657AFE00070FD6F /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD615FCD265529DE00B717DB /* Settings.swift */; };
CD3883EC2657B83D0070FD6F /* FIPSResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD3883EB2657B83D0070FD6F /* FIPSResponse.swift */; };
CD427D19266F5DCE00B4350A /* ShortsSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD427D18266F5DCE00B4350A /* ShortsSource.swift */; };
CD427D1C266F5F2800B4350A /* ShortsItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD427D1B266F5F2800B4350A /* ShortsItem.swift */; };
CD550FBA265531A100257FB5 /* RadarLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD550FB52655318D00257FB5 /* RadarLayer.swift */; };
CD550FBB265531A100257FB5 /* RadarLayerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD550FB62655318D00257FB5 /* RadarLayerType.swift */; };
CD550FBC265531A100257FB5 /* WeatherLayerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD550FB72655318D00257FB5 /* WeatherLayerType.swift */; };
......@@ -112,6 +114,8 @@
CD2D55DC2655377F007B70F4 /* NWSSeverityLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NWSSeverityLevel.swift; sourceTree = "<group>"; };
CD2D55DF265537DC007B70F4 /* NWSAlertInfoBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NWSAlertInfoBlock.swift; sourceTree = "<group>"; };
CD3883EB2657B83D0070FD6F /* FIPSResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FIPSResponse.swift; sourceTree = "<group>"; };
CD427D18266F5DCE00B4350A /* ShortsSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortsSource.swift; sourceTree = "<group>"; };
CD427D1B266F5F2800B4350A /* ShortsItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortsItem.swift; sourceTree = "<group>"; };
CD550FB52655318D00257FB5 /* RadarLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadarLayer.swift; sourceTree = "<group>"; };
CD550FB62655318D00257FB5 /* RadarLayerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadarLayerType.swift; sourceTree = "<group>"; };
CD550FB72655318D00257FB5 /* WeatherLayerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherLayerType.swift; sourceTree = "<group>"; };
......@@ -227,6 +231,14 @@
path = FIPS;
sourceTree = "<group>";
};
CD427D1A266F5F0500B4350A /* Shorts */ = {
isa = PBXGroup;
children = (
CD427D1B266F5F2800B4350A /* ShortsItem.swift */,
);
path = Shorts;
sourceTree = "<group>";
};
CD550FB92655318D00257FB5 /* RadarLayers */ = {
isa = PBXGroup;
children = (
......@@ -345,6 +357,7 @@
CD615F912655269200B717DB /* Health */,
CD615F932655269200B717DB /* Notifications */,
CD3883EA2657B82A0070FD6F /* FIPS */,
CD427D1A266F5F0500B4350A /* Shorts */,
);
path = ModelObjects;
sourceTree = "<group>";
......@@ -443,6 +456,7 @@
CD615F802655243C00B717DB /* WeatherSource.swift */,
CDFE459526566D860021A29F /* FIPSSource.swift */,
CDFE459326566D7B0021A29F /* HealthSource.swift */,
CD427D18266F5DCE00B4350A /* ShortsSource.swift */,
);
path = Sources;
sourceTree = "<group>";
......@@ -631,6 +645,7 @@
CD615FC52655295C00B717DB /* CLAuthorizationStatus+Localized.swift in Sources */,
CD615FC62655295C00B717DB /* UIApplication+Settings.swift in Sources */,
CD8E48A526651414008E7F8D /* NWSCurrentEventsReponse.swift in Sources */,
CD427D19266F5DCE00B4350A /* ShortsSource.swift in Sources */,
CD2D55D8265533F4007B70F4 /* UserDefaultsWrapper.swift in Sources */,
CD615FC72655295C00B717DB /* UITabBarController+Hide.swift in Sources */,
CDD2F8F62665117400B48322 /* NWSAlertsManager.swift in Sources */,
......@@ -659,6 +674,7 @@
CD615FA0265526E700B717DB /* HealthStatus.swift in Sources */,
CD615FA1265526E700B717DB /* Pollutant.swift in Sources */,
CD615FA2265526E700B717DB /* Notifications.swift in Sources */,
CD427D1C266F5F2800B4350A /* ShortsItem.swift in Sources */,
CD615F812655243C00B717DB /* WeatherSource.swift in Sources */,
CD11AFEB26651D1D00EC4BA0 /* Constants.swift in Sources */,
);
......
......@@ -9,12 +9,6 @@ import Foundation
import CoreLocation
import UIKit
import OneWeatherAnalytics
//import MoEngage
//import WDTWeatherSource
//import BlendHealthSource
//import BlendFIPSSource
//import CoreDataStorage
//import DelayedSaveStorage
public protocol LocationManagerDelegate: AnyObject {
func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?)
......
//
// ShortsItem.swift
// OneWeatherCore
//
// Created by Dmitry Stepanets on 08.06.2021.
//
import Foundation
public struct ShortsItemImage {
public init(width: Int, height: Int, url: URL) {
self.width = width
self.height = height
self.url = url
}
let width:Int
let height:Int
let url:URL
}
public struct ShortsItem {
public init(id: String, images: [ShortsItemImage], updatedAtInSecs: TimeInterval, startsAtInSecs: TimeInterval, endsAtInSecs: TimeInterval, shareURL: URL?, title: String, summaryText: String, sourceName: String, heartCount: Int, shortURL: URL?, ctaText: String, ctaURL: URL?, likeCount: Int, shareCount: Int) {
self.id = id
self.images = images
self.updatedAtInSecs = updatedAtInSecs
self.startsAtInSecs = startsAtInSecs
self.endsAtInSecs = endsAtInSecs
self.shareURL = shareURL
self.title = title
self.summaryText = summaryText
self.sourceName = sourceName
self.heartCount = heartCount
self.shortURL = shortURL
self.ctaText = ctaText
self.ctaURL = ctaURL
self.likeCount = likeCount
self.shareCount = shareCount
}
public let id:String
public let images: [ShortsItemImage]
public let updatedAtInSecs: TimeInterval
public let startsAtInSecs: TimeInterval
public let endsAtInSecs: TimeInterval
public let shareURL: URL?
public let title:String
public let summaryText:String
public let sourceName:String
public let heartCount:Int
public let shortURL:URL?
public let ctaText:String
public let ctaURL:URL?
public let likeCount:Int
public let shareCount:Int
}
//
// ShortsSource.swift
// OneWeatherCore
//
// Created by Dmitry Stepanets on 08.06.2021.
//
import Foundation
public typealias ShortsSourceCompletion = ([ShortsItem]?, Error?) -> ()
public protocol ShortSource {
func updateShorts(completion: @escaping ShortsSourceCompletion)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment