Commit d6a371ca by Demid Merzlyakov

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

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