Commit d6a371ca by Demid Merzlyakov

IOS-183: SmartTextProvider: support for custom smart text configuration.

parent 4ae087ec
...@@ -17,7 +17,7 @@ class TodayForecastCell: UITableViewCell { ...@@ -17,7 +17,7 @@ class TodayForecastCell: UITableViewCell {
private let forecastDescriptionLabel = UILabel() private let forecastDescriptionLabel = UILabel()
private let smartTextLabel = UILabel() private let smartTextLabel = UILabel()
private let forecastImageView = UIImageView() private let forecastImageView = UIImageView()
private let smartTextProvider = SmartTextProvider() private let smartTextProvider = SmartTextProvider(prioritizedSmartTexts: SmartTextProvider.defaultSmartTexts)
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
......
...@@ -108,7 +108,7 @@ public class WidgetManager { ...@@ -108,7 +108,7 @@ public class WidgetManager {
self.widgetOptions = WidgetOptions(rawValue: storedWidgetsOptions) self.widgetOptions = WidgetOptions(rawValue: storedWidgetsOptions)
} }
private let log = Logger(componentName: "WidgetManager") private let log = Logger(componentName: "WidgetManager")
private let smartTextProvider = SmartTextProvider() private let smartTextProvider = SmartTextProvider(prioritizedSmartTexts: SmartTextProvider.defaultSmartTexts)
private var widgetOptions: WidgetOptions = [] private var widgetOptions: WidgetOptions = []
public func refreshAnalytics() { public func refreshAnalytics() {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
public class SmartTextProvider { public class SmartTextProvider {
private var prioritizedSmartTexts: [SmartText] = [ public static let defaultSmartTexts: [SmartText] = [
OngoingPrecipitationSmartText(), OngoingPrecipitationSmartText(),
ApproachingPrecipitationSmartText(), ApproachingPrecipitationSmartText(),
WindSmartText(minAllowedWindSpeed: WindSpeed(value: 75, unit: .kilometersPerHour)), WindSmartText(minAllowedWindSpeed: WindSpeed(value: 75, unit: .kilometersPerHour)),
...@@ -17,8 +17,10 @@ public class SmartTextProvider { ...@@ -17,8 +17,10 @@ public class SmartTextProvider {
DefaultSmartText()] DefaultSmartText()]
public init() { private let prioritizedSmartTexts: [SmartText]
public init(prioritizedSmartTexts: [SmartText]) {
self.prioritizedSmartTexts = prioritizedSmartTexts
} }
public func smartText(for location: Location) -> String { public func smartText(for location: Location) -> String {
......
...@@ -121,7 +121,7 @@ struct ForecastWidgetViewModel: WidgetViewModel { ...@@ -121,7 +121,7 @@ struct ForecastWidgetViewModel: WidgetViewModel {
self.showLastTimeUpdated = false self.showLastTimeUpdated = false
lastTimeUpdatedText = "" lastTimeUpdatedText = ""
} }
let smartTextProvider = SmartTextProvider() let smartTextProvider = SmartTextProvider(prioritizedSmartTexts: SmartTextProvider.defaultSmartTexts)
self.smartText = smartTextProvider.smartText(for: location) self.smartText = smartTextProvider.smartText(for: location)
self.hourlyWeather = convertToWidgetHourly(modelHourly: location.hourly) self.hourlyWeather = convertToWidgetHourly(modelHourly: location.hourly)
......
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