Commit f6966433 by Dmitriy Stepanets

Widget UI changes

parent c95b5ee6
...@@ -163,6 +163,13 @@ ...@@ -163,6 +163,13 @@
CDE2BF222609D4250085C930 /* ForecastWindSpeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE2BF212609D4250085C930 /* ForecastWindSpeedCell.swift */; }; CDE2BF222609D4250085C930 /* ForecastWindSpeedCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE2BF212609D4250085C930 /* ForecastWindSpeedCell.swift */; };
CDE2BF252609D9140085C930 /* ForecastWindButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE2BF242609D9140085C930 /* ForecastWindButton.swift */; }; CDE2BF252609D9140085C930 /* ForecastWindButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE2BF242609D9140085C930 /* ForecastWindButton.swift */; };
CDEE8AD725DA882200C289DE /* ForecastPeriodButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */; }; CDEE8AD725DA882200C289DE /* ForecastPeriodButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */; };
CDEF70E6266E17BC00BA40D6 /* OneWeatherCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDEF70E2266E10B600BA40D6 /* OneWeatherCore.framework */; };
CDEF70E9266E18D600BA40D6 /* BlendFIPSSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */; };
CDEF70EB266E18D600BA40D6 /* BlendHealthSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD3883C12657B6A10070FD6F /* BlendHealthSource.framework */; };
CDEF70ED266E18D700BA40D6 /* CoreDataStorage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD3884542657BA8B0070FD6F /* CoreDataStorage.framework */; };
CDEF70EF266E18D700BA40D6 /* DelayedSaveStorage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD3884822657BBCC0070FD6F /* DelayedSaveStorage.framework */; };
CDEF70F2266E192200BA40D6 /* WDTWeatherSource.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDFE45BB26566EF50021A29F /* WDTWeatherSource.framework */; };
CDEF70F6266E25E400BA40D6 /* VectorImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDEF70F5266E25E400BA40D6 /* VectorImage.swift */; };
CDF63D29266779D8003DE569 /* AdLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF63D28266779D8003DE569 /* AdLogger.swift */; }; CDF63D29266779D8003DE569 /* AdLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF63D28266779D8003DE569 /* AdLogger.swift */; };
CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F129262089A200DB384A /* MapTimeView.swift */; }; CDF8F12A262089A200DB384A /* MapTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F129262089A200DB384A /* MapTimeView.swift */; };
CDF8F12D26208E7B00DB384A /* MapCurrentTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F12C26208E7B00DB384A /* MapCurrentTimeView.swift */; }; CDF8F12D26208E7B00DB384A /* MapCurrentTimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF8F12C26208E7B00DB384A /* MapCurrentTimeView.swift */; };
...@@ -421,6 +428,8 @@ ...@@ -421,6 +428,8 @@
CDE2BF212609D4250085C930 /* ForecastWindSpeedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastWindSpeedCell.swift; sourceTree = "<group>"; }; CDE2BF212609D4250085C930 /* ForecastWindSpeedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastWindSpeedCell.swift; sourceTree = "<group>"; };
CDE2BF242609D9140085C930 /* ForecastWindButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastWindButton.swift; sourceTree = "<group>"; }; CDE2BF242609D9140085C930 /* ForecastWindButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastWindButton.swift; sourceTree = "<group>"; };
CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPeriodButton.swift; sourceTree = "<group>"; }; CDEE8AD625DA882200C289DE /* ForecastPeriodButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForecastPeriodButton.swift; sourceTree = "<group>"; };
CDEF70E2266E10B600BA40D6 /* OneWeatherCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CDEF70F5266E25E400BA40D6 /* VectorImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VectorImage.swift; sourceTree = "<group>"; };
CDF1F9342668D09C004F5D61 /* OneWeatherCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CDF1F9342668D09C004F5D61 /* OneWeatherCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OneWeatherCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CDF63D28266779D8003DE569 /* AdLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdLogger.swift; sourceTree = "<group>"; }; CDF63D28266779D8003DE569 /* AdLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdLogger.swift; sourceTree = "<group>"; };
CDF8F129262089A200DB384A /* MapTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeView.swift; sourceTree = "<group>"; }; CDF8F129262089A200DB384A /* MapTimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTimeView.swift; sourceTree = "<group>"; };
...@@ -501,8 +510,14 @@ ...@@ -501,8 +510,14 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
CDEF70EB266E18D600BA40D6 /* BlendHealthSource.framework in Frameworks */,
CD1B713D2660F95000916E71 /* SwiftUI.framework in Frameworks */, CD1B713D2660F95000916E71 /* SwiftUI.framework in Frameworks */,
CDEF70E9266E18D600BA40D6 /* BlendFIPSSource.framework in Frameworks */,
CDEF70ED266E18D700BA40D6 /* CoreDataStorage.framework in Frameworks */,
CDEF70E6266E17BC00BA40D6 /* OneWeatherCore.framework in Frameworks */,
CD1B713B2660F95000916E71 /* WidgetKit.framework in Frameworks */, CD1B713B2660F95000916E71 /* WidgetKit.framework in Frameworks */,
CDEF70F2266E192200BA40D6 /* WDTWeatherSource.framework in Frameworks */,
CDEF70EF266E18D700BA40D6 /* DelayedSaveStorage.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -731,6 +746,7 @@ ...@@ -731,6 +746,7 @@
CD5293D7266908DB009547C8 /* WidgetPlaceholderView.swift */, CD5293D7266908DB009547C8 /* WidgetPlaceholderView.swift */,
CD415D9C2668FDB400177515 /* SmallWidgetView.swift */, CD415D9C2668FDB400177515 /* SmallWidgetView.swift */,
CD5293EB266A5BC2009547C8 /* UIColor+Color.swift */, CD5293EB266A5BC2009547C8 /* UIColor+Color.swift */,
CDEF70F5266E25E400BA40D6 /* VectorImage.swift */,
); );
path = UI; path = UI;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1267,6 +1283,7 @@ ...@@ -1267,6 +1283,7 @@
DBFD169AA2AA6A3CB5B68BB5 /* Frameworks */ = { DBFD169AA2AA6A3CB5B68BB5 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
CDEF70E2266E10B600BA40D6 /* OneWeatherCore.framework */,
CE30E37E2668FBE3006DF5CD /* OneWeatherAnalytics.framework */, CE30E37E2668FBE3006DF5CD /* OneWeatherAnalytics.framework */,
CDF1F9342668D09C004F5D61 /* OneWeatherCore.framework */, CDF1F9342668D09C004F5D61 /* OneWeatherCore.framework */,
CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */, CEEF40FF265E47FF00425D8F /* BlendFIPSSource.framework */,
...@@ -1765,6 +1782,7 @@ ...@@ -1765,6 +1782,7 @@
CD5293EC266A5BC2009547C8 /* UIColor+Color.swift in Sources */, CD5293EC266A5BC2009547C8 /* UIColor+Color.swift in Sources */,
CD415DA32668FFF300177515 /* WeatherProvider.swift in Sources */, CD415DA32668FFF300177515 /* WeatherProvider.swift in Sources */,
CD5293DA2669094E009547C8 /* WeatherEntry.swift in Sources */, CD5293DA2669094E009547C8 /* WeatherEntry.swift in Sources */,
CDEF70F6266E25E400BA40D6 /* VectorImage.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key> <key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>53</integer> <integer>52</integer>
</dict> </dict>
<key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key> <key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>57</integer> <integer>59</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
...@@ -10,8 +10,10 @@ import WidgetKit ...@@ -10,8 +10,10 @@ import WidgetKit
import OneWeatherCore import OneWeatherCore
struct SmallWidgetView: View { struct SmallWidgetView: View {
//Public
let widgetViewModel: SmallWidgetViewModel let widgetViewModel: SmallWidgetViewModel
//Private
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
private var interfaceStyle:AppInterfaceStyle { private var interfaceStyle:AppInterfaceStyle {
switch Settings.shared.appTheme { switch Settings.shared.appTheme {
...@@ -37,10 +39,9 @@ struct SmallWidgetView: View { ...@@ -37,10 +39,9 @@ struct SmallWidgetView: View {
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.font(AppFont.SFProDisplay.regular(size: 12).font) .font(AppFont.SFProDisplay.regular(size: 12).font)
.foregroundColor(ThemeManager.currentTheme.graphTintColor.color) .foregroundColor(ThemeManager.currentTheme.graphTintColor.color)
Image("location_arrow") VectorImage(name: "location_arrow",
.resizable() contentMode: .scaleAspectFit,
.frame(width: 8, height: 8, alignment: .center) tintColor: ThemeManager.currentTheme.graphTintColor)
.foregroundColor(ThemeManager.currentTheme.graphTintColor.color)
.opacity(widgetViewModel.isDeviceLocation ? 1 : 0) .opacity(widgetViewModel.isDeviceLocation ? 1 : 0)
Spacer() Spacer()
} }
...@@ -52,9 +53,11 @@ struct SmallWidgetView: View { ...@@ -52,9 +53,11 @@ struct SmallWidgetView: View {
Text(widgetViewModel.temperature) Text(widgetViewModel.temperature)
.font(AppFont.SFProDisplay.light(size: 32).font) .font(AppFont.SFProDisplay.light(size: 32).font)
.padding(.leading, 10) .padding(.leading, 10)
.textColor(for: interfaceStyle)
Text(widgetViewModel.weatherType) Text(widgetViewModel.weatherType)
.font(AppFont.SFProDisplay.regular(size: 12).font) .font(AppFont.SFProDisplay.regular(size: 12).font)
.frame(width: geometry.size.width * 0.5, alignment: .leading) .frame(width: geometry.size.width * 0.5, alignment: .leading)
.textColor(for: interfaceStyle)
.padding(.leading, 10) .padding(.leading, 10)
Spacer(minLength: 0) Spacer(minLength: 0)
} }
...@@ -62,8 +65,6 @@ struct SmallWidgetView: View { ...@@ -62,8 +65,6 @@ struct SmallWidgetView: View {
Spacer(minLength: 0) Spacer(minLength: 0)
widgetViewModel.weatherIcon widgetViewModel.weatherIcon
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 70, height: 70, alignment: .center) .frame(width: 70, height: 70, alignment: .center)
.shadow(for: interfaceStyle) .shadow(for: interfaceStyle)
.padding(.trailing, 4) .padding(.trailing, 4)
...@@ -72,8 +73,10 @@ struct SmallWidgetView: View { ...@@ -72,8 +73,10 @@ struct SmallWidgetView: View {
HStack { HStack {
Text("H \(widgetViewModel.highTemperature)") Text("H \(widgetViewModel.highTemperature)")
.font(AppFont.SFProDisplay.regular(size: 12).font) .font(AppFont.SFProDisplay.regular(size: 12).font)
.footerTextColor(for: interfaceStyle)
Text("L \(widgetViewModel.lowTemperature)") Text("L \(widgetViewModel.lowTemperature)")
.font(AppFont.SFProDisplay.regular(size: 12).font) .font(AppFont.SFProDisplay.regular(size: 12).font)
.footerTextColor(for: interfaceStyle)
Spacer() Spacer()
} }
.padding(.top, 20) .padding(.top, 20)
...@@ -83,6 +86,7 @@ struct SmallWidgetView: View { ...@@ -83,6 +86,7 @@ struct SmallWidgetView: View {
} }
} }
//MARK: Appearence extension
private extension View { private extension View {
func shadow(for interfaceStyle:AppInterfaceStyle) -> some View { func shadow(for interfaceStyle:AppInterfaceStyle) -> some View {
switch interfaceStyle { switch interfaceStyle {
...@@ -92,6 +96,24 @@ private extension View { ...@@ -92,6 +96,24 @@ private extension View {
return self.shadow(color: Color.white.opacity(0.24), radius: 16, x: 2, y: 0) return self.shadow(color: Color.white.opacity(0.24), radius: 16, x: 2, y: 0)
} }
} }
func textColor(for interfaceStyle:AppInterfaceStyle) -> some View {
switch interfaceStyle {
case .light:
return self.foregroundColor(ThemeManager.currentTheme.secondaryTextColor.color)
case .dark:
return self.foregroundColor(ThemeManager.currentTheme.primaryTextColor.color)
}
}
func footerTextColor(for interfaceStyle:AppInterfaceStyle) -> some View {
switch interfaceStyle {
case .light:
return self.foregroundColor(UIColor(hex: 0xA6ACbe).color)
case .dark:
return self.foregroundColor(UIColor(hex: 0xA9BAC5).color)
}
}
} }
struct SmallWidget_Preview: PreviewProvider { struct SmallWidget_Preview: PreviewProvider {
......
//
// VectorImage.swift
// OneWeatherWidgetExtension
//
// Created by Dmitry Stepanets on 07.06.2021.
//
import SwiftUI
struct VectorImage: UIViewRepresentable {
typealias UIViewType = UIImageView
var name:String
var contentMode: UIView.ContentMode = .scaleAspectFit
var tintColor:UIColor = .black
private var image:UIImage?
init(image:UIImage, contentMode: UIView.ContentMode = .scaleAspectFit, tintColor:UIColor = .black) {
self.image = image
self.contentMode = contentMode
self.tintColor = tintColor
self.name = ""
}
init(name:String, contentMode: UIView.ContentMode = .scaleAspectFit, tintColor:UIColor = .black) {
self.name = name
self.contentMode = contentMode
self.tintColor = tintColor
}
func makeUIView(context: Context) -> UIImageView {
let imageView = UIImageView()
imageView.setContentCompressionResistancePriority(.fittingSizeLevel,
for: .vertical)
return imageView
}
func updateUIView(_ uiView: UIImageView, context: Context) {
uiView.contentMode = contentMode
uiView.tintColor = tintColor
if self.image != nil {
uiView.image = self.image
}
else {
uiView.image = UIImage(named: name)
}
}
}
...@@ -12,7 +12,7 @@ struct SmallWidgetViewModel { ...@@ -12,7 +12,7 @@ struct SmallWidgetViewModel {
let cityName:String let cityName:String
let temperature:String let temperature:String
let weatherType:String let weatherType:String
let weatherIcon:Image let weatherIcon:VectorImage
let highTemperature:String let highTemperature:String
let lowTemperature:String let lowTemperature:String
let isDeviceLocation:Bool let isDeviceLocation:Bool
...@@ -21,7 +21,7 @@ struct SmallWidgetViewModel { ...@@ -21,7 +21,7 @@ struct SmallWidgetViewModel {
self.cityName = location.cityName ?? "--" self.cityName = location.cityName ?? "--"
self.temperature = "\(location.today?.temp?.shortString ?? "--")" self.temperature = "\(location.today?.temp?.shortString ?? "--")"
self.weatherType = location.today?.type.localized(isDay: location.today?.isDay ?? true) ?? "--" self.weatherType = location.today?.type.localized(isDay: location.today?.isDay ?? true) ?? "--"
self.weatherIcon = Image(uiImage: location.today?.type.image(isDay: location.today?.isDay ?? true) ?? UIImage()) self.weatherIcon = VectorImage(image: location.today?.type.image(isDay: location.today?.isDay ?? true) ?? UIImage())
self.highTemperature = location.today?.maxTemp?.shortString ?? "--" self.highTemperature = location.today?.maxTemp?.shortString ?? "--"
self.lowTemperature = location.today?.minTemp?.shortString ?? "--" self.lowTemperature = location.today?.minTemp?.shortString ?? "--"
self.isDeviceLocation = location.deviceLocation self.isDeviceLocation = location.deviceLocation
......
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