Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
b82c8b09
Commit
b82c8b09
authored
Jul 19, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on LargeTemperatureWidget
parent
dad43b2e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
89 additions
and
67 deletions
+89
-67
1Weather.xcodeproj/project.pbxproj
+10
-0
1Weather.xcodeproj/xcshareddata/xcschemes/OneWeatherWidgetExtension.xcscheme
+1
-1
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+2
-2
OneWeatherUI/OneWeatherUI.xcodeproj/project.pbxproj
+4
-4
OneWeatherUI/OneWeatherUI/Widgets/Precipitation/MediumPrecipitationWidgetView.swift
+1
-1
OneWeatherUI/OneWeatherUI/Widgets/SharedViews/WidgetTopView.swift
+17
-5
OneWeatherUI/OneWeatherUI/Widgets/Temperature/LargeTemperatureWidgetView.swift
+11
-38
OneWeatherUI/OneWeatherUI/Widgets/Temperature/MediumTemperatureWidgetView.swift
+1
-1
OneWeatherUI/OneWeatherUI/Widgets/ViewModels/WidgetViewModel.swift
+5
-5
OneWeatherUI/OneWeatherUI/Widgets/ViewModels/WidgetViewModelMock.swift
+5
-3
OneWeatherWidget/Data/WeatherEntry.swift
+13
-0
OneWeatherWidget/UI/WidgetPlaceholderView.swift
+1
-1
OneWeatherWidget/ViewModels/ForecastWidgetViewModel.swift
+16
-4
OneWeatherWidget/Widgets/TemperatureWidget.swift
+2
-2
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
b82c8b09
...
...
@@ -90,6 +90,9 @@
CD5692B62653D56700A3CDBE
/* splash.json in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD5692B52653D56700A3CDBE
/* splash.json */
;
};
CD58529026A01F0E00D61021
/* PrecipitationWidget.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD58528F26A01F0E00D61021
/* PrecipitationWidget.swift */
;
};
CD58529226A02B3200D61021
/* PromotionWidgetViewWrapper.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD58529126A02B3100D61021
/* PromotionWidgetViewWrapper.swift */
;
};
CD5909CE26A59A4B00448579
/* OneWeatherUI.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD5909CD26A59A4B00448579
/* OneWeatherUI.framework */
;
settings
=
{
ATTRIBUTES
=
(
Required
,
);
};
};
CD5909D026A59AAA00448579
/* OneWeatherUI.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD5909CF26A59AAA00448579
/* OneWeatherUI.framework */
;
settings
=
{
ATTRIBUTES
=
(
Weak
,
);
};
};
CD5909D126A59AAA00448579
/* OneWeatherUI.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD5909CF26A59AAA00448579
/* OneWeatherUI.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
CD593BC226088A5900C93428
/* TimePeriodOffsetHolder.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD593BC126088A5900C93428
/* TimePeriodOffsetHolder.swift */
;
};
CD593BCC2608A4F200C93428
/* ForecastDailyCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD593BCB2608A4F200C93428
/* ForecastDailyCell.swift */
;
};
CD593BCF2608A50900C93428
/* ForecastHourlyCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD593BCE2608A50900C93428
/* ForecastHourlyCell.swift */
;
};
...
...
@@ -283,6 +286,7 @@
CD3884562657BA8B0070FD6F
/* CoreDataStorage.framework in Embed Frameworks */
,
CD3883C32657B6A10070FD6F
/* BlendHealthSource.framework in Embed Frameworks */
,
CD3884842657BBCC0070FD6F
/* DelayedSaveStorage.framework in Embed Frameworks */
,
CD5909D126A59AAA00448579
/* OneWeatherUI.framework in Embed Frameworks */
,
);
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -397,6 +401,8 @@
CD5692B52653D56700A3CDBE
/* splash.json */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.json
;
path
=
splash.json
;
sourceTree
=
"<group>"
;
};
CD58528F26A01F0E00D61021
/* PrecipitationWidget.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PrecipitationWidget.swift
;
sourceTree
=
"<group>"
;
};
CD58529126A02B3100D61021
/* PromotionWidgetViewWrapper.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PromotionWidgetViewWrapper.swift
;
sourceTree
=
"<group>"
;
};
CD5909CD26A59A4B00448579
/* OneWeatherUI.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
OneWeatherUI.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
CD5909CF26A59AAA00448579
/* OneWeatherUI.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
OneWeatherUI.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
CD593BC126088A5900C93428
/* TimePeriodOffsetHolder.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TimePeriodOffsetHolder.swift
;
sourceTree
=
"<group>"
;
};
CD593BCB2608A4F200C93428
/* ForecastDailyCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastDailyCell.swift
;
sourceTree
=
"<group>"
;
};
CD593BCE2608A50900C93428
/* ForecastHourlyCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastHourlyCell.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -547,6 +553,7 @@
files
=
(
CE14445F2638B6CF008E2162
/* StoreKit.framework in Frameworks */
,
CD3883C22657B6A10070FD6F
/* BlendHealthSource.framework in Frameworks */
,
CD5909D026A59AAA00448579
/* OneWeatherUI.framework in Frameworks */
,
CE13B97B2626FB11007CBD4D
/* PSMLocationSDK.xcframework in Frameworks */
,
CDFE45BC26566EF50021A29F
/* WDTWeatherSource.framework in Frameworks */
,
CD3884552657BA8B0070FD6F
/* CoreDataStorage.framework in Frameworks */
,
...
...
@@ -565,6 +572,7 @@
files
=
(
CD1B713D2660F95000916E71
/* SwiftUI.framework in Frameworks */
,
CE7298CC267A34F5002745D0
/* BlendHealthSource.framework in Frameworks */
,
CD5909CE26A59A4B00448579
/* OneWeatherUI.framework in Frameworks */
,
CD1B713B2660F95000916E71
/* WidgetKit.framework in Frameworks */
,
CE7298D0267A34F8002745D0
/* DelayedSaveStorage.framework in Frameworks */
,
CE7298C9267A34F3002745D0
/* BlendFIPSSource.framework in Frameworks */
,
...
...
@@ -1390,6 +1398,8 @@
DBFD169AA2AA6A3CB5B68BB5
/* Frameworks */
=
{
isa
=
PBXGroup
;
children
=
(
CD5909CF26A59AAA00448579
/* OneWeatherUI.framework */
,
CD5909CD26A59A4B00448579
/* OneWeatherUI.framework */
,
CD5181BF269EEB61008E6B04
/* CoreLocation.framework */
,
CD7D3183268F1438000D01FA
/* OneWeatherUI.framework */
,
CDEF70E2266E10B600BA40D6
/* OneWeatherCore.framework */
,
...
...
1Weather.xcodeproj/xcshareddata/xcschemes/OneWeatherWidgetExtension.xcscheme
View file @
b82c8b09
...
...
@@ -90,7 +90,7 @@
</EnvironmentVariable>
<EnvironmentVariable
key =
"_XCWidgetFamily"
value =
"
medium
"
value =
"
large
"
isEnabled =
"YES"
>
</EnvironmentVariable>
</EnvironmentVariables>
...
...
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
b82c8b09
...
...
@@ -12,12 +12,12 @@
<
k
e
y
>
OneWeatherNotificationServiceExtension.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
OneWeatherWidgetExtension.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
7
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
PG
(
Playground
)
1.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
OneWeatherUI/OneWeatherUI.xcodeproj/project.pbxproj
View file @
b82c8b09
...
...
@@ -17,7 +17,7 @@
CD2E07BF269C5834001CBF40
/* SF-Pro-Display-Thin.otf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD2E07BE269C5834001CBF40
/* SF-Pro-Display-Thin.otf */
;
};
CD2E07C1269C5ABF001CBF40
/* HourlyTemperatureView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD2E07C0269C5ABF001CBF40
/* HourlyTemperatureView.swift */
;
};
CD3C83C326933ABD0087A225
/* MediumTemperatureWidgetView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD3C83C226933ABC0087A225
/* MediumTemperatureWidgetView.swift */
;
};
CD4319FA26A00E090019A232
/*
MediumWidgetTopView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD4319F926A00E090019A232
/* Medium
WidgetTopView.swift */
;
};
CD4319FA26A00E090019A232
/*
WidgetTopView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD4319F926A00E090019A232
/*
WidgetTopView.swift */
;
};
CD4319FC26A014CF0019A232
/* MediumPrecipitationWidgetView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD4319FB26A014CF0019A232
/* MediumPrecipitationWidgetView.swift */
;
};
CD50556126983C2F006776AB
/* CubicCurveAlgorithm.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD50556026983C2E006776AB
/* CubicCurveAlgorithm.swift */
;
};
CD7D3161268EEF49000D01FA
/* CityNameView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD7D315F268EEF48000D01FA
/* CityNameView.swift */
;
};
...
...
@@ -67,7 +67,7 @@
CD2E07BE269C5834001CBF40
/* SF-Pro-Display-Thin.otf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"SF-Pro-Display-Thin.otf"
;
sourceTree
=
"<group>"
;
};
CD2E07C0269C5ABF001CBF40
/* HourlyTemperatureView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
HourlyTemperatureView.swift
;
sourceTree
=
"<group>"
;
};
CD3C83C226933ABC0087A225
/* MediumTemperatureWidgetView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MediumTemperatureWidgetView.swift
;
sourceTree
=
"<group>"
;
};
CD4319F926A00E090019A232
/*
MediumWidgetTopView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Medium
WidgetTopView.swift
;
sourceTree
=
"<group>"
;
};
CD4319F926A00E090019A232
/*
WidgetTopView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
WidgetTopView.swift
;
sourceTree
=
"<group>"
;
};
CD4319FB26A014CF0019A232
/* MediumPrecipitationWidgetView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MediumPrecipitationWidgetView.swift
;
sourceTree
=
"<group>"
;
};
CD50556026983C2E006776AB
/* CubicCurveAlgorithm.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CubicCurveAlgorithm.swift
;
sourceTree
=
"<group>"
;
};
CD6F063D269854A7002A99C2
/* BezierKit.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
BezierKit.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
...
...
@@ -213,7 +213,7 @@
CDC3F85926946D0700AAE3BF
/* HourlyView.swift */
,
CD1BF3AE26981B5300F60E2E
/* TemperatureGraphView.swift */
,
CD2E07C0269C5ABF001CBF40
/* HourlyTemperatureView.swift */
,
CD4319F926A00E090019A232
/*
Medium
WidgetTopView.swift */
,
CD4319F926A00E090019A232
/* WidgetTopView.swift */
,
);
path
=
SharedViews
;
sourceTree
=
"<group>"
;
...
...
@@ -394,7 +394,7 @@
CD7D3187268F1F2E000D01FA
/* UIImage+Resize.swift in Sources */
,
CD1BF3B2269823BA00F60E2E
/* GraphViewModel.swift in Sources */
,
CD50556126983C2F006776AB
/* CubicCurveAlgorithm.swift in Sources */
,
CD4319FA26A00E090019A232
/*
Medium
WidgetTopView.swift in Sources */
,
CD4319FA26A00E090019A232
/* WidgetTopView.swift in Sources */
,
CD7D3178268EFB9E000D01FA
/* WidgetViewModelMock.swift in Sources */
,
CD7D316F268EF2BC000D01FA
/* WidgetViewModel.swift in Sources */
,
CD7D3182268F0C60000D01FA
/* OneWeatherUI+Global.swift in Sources */
,
...
...
OneWeatherUI/OneWeatherUI/Widgets/Precipitation/MediumPrecipitationWidgetView.swift
View file @
b82c8b09
...
...
@@ -18,7 +18,7 @@ public struct MediumPrecipitationWidgetView: View {
public
var
body
:
some
View
{
VStack
(
alignment
:
.
center
)
{
MediumWidgetTopView
(
widgetViewModel
:
widgetViewModel
)
WidgetTopView
(
widgetViewModel
:
widgetViewModel
,
style
:
.
medium
)
.
padding
(
.
top
,
12
)
HStack
(
spacing
:
10
)
{
ForEach
(
0
..<
widgetViewModel
.
hourlyWeather
.
count
)
{
index
in
...
...
OneWeatherUI/OneWeatherUI/Widgets/SharedViews/
Medium
WidgetTopView.swift
→
OneWeatherUI/OneWeatherUI/Widgets/SharedViews/WidgetTopView.swift
View file @
b82c8b09
//
//
Medium
WidgetTopView.swift
// WidgetTopView.swift
// OneWeatherUI
//
// Created by Dmitry Stepanets on 15.07.2021.
...
...
@@ -8,8 +8,15 @@
import
SwiftUI
@available(iOS 14, *)
struct
MediumWidgetTopView
:
View
{
internal
enum
WidgetTopStyle
{
case
medium
case
large
}
@available(iOS 14, *)
struct
WidgetTopView
:
View
{
let
widgetViewModel
:
WidgetViewModel
let
style
:
WidgetTopStyle
var
body
:
some
View
{
VStack
(
spacing
:
4
)
{
...
...
@@ -35,8 +42,13 @@ struct MediumWidgetTopView: View {
}
Spacer
()
VStack
(
spacing
:
2
)
{
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
if
style
==
.
medium
{
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
}
else
{
Spacer
()
}
HighLowTemperatureView
(
highTemperature
:
widgetViewModel
.
highTemperature
,
lowTemperature
:
widgetViewModel
.
lowTemperature
)
}
...
...
@@ -84,7 +96,7 @@ private struct Shadow: ViewModifier {
@available(iOS 14, *)
public
struct
MediumWidgetTopView_Preview
:
PreviewProvider
{
public
static
var
previews
:
some
View
{
MediumWidgetTopView
(
widgetViewModel
:
WidgetViewModelMock
()
)
WidgetTopView
(
widgetViewModel
:
WidgetViewModelMock
(),
style
:
.
medium
)
.
previewDevice
(
"iPhone 11"
)
.
preferredColorScheme
(
.
dark
)
.
background
(
WidgetColor
.
Name
(
"PrimaryBackground"
))
...
...
OneWeatherUI/OneWeatherUI/Widgets/Temperature/LargeTemperatureWidgetView.swift
View file @
b82c8b09
...
...
@@ -25,40 +25,11 @@ public struct LargeTemperatureWidgetView: View {
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
.
padding
(
.
top
,
12
)
HStack
{
HStack
(
spacing
:
8
)
{
Text
(
widgetViewModel
.
temperature
)
.
font
(
WidgetFont
.
SFProDisplay
.
light
(
size
:
32
)
.
font
)
.
foregroundColor
(
WidgetColor
.
Name
(
"PrimaryTextColor"
))
Divider
()
.
padding
(
.
top
,
8
)
.
padding
(
.
bottom
,
8
)
Text
(
widgetViewModel
.
weatherType
)
.
font
(
WidgetFont
.
SFProDisplay
.
regular
(
size
:
12
)
.
font
)
.
foregroundColor
(
WidgetColor
.
Name
(
"PrimaryTextColor"
))
.
lineLimit
(
2
)
weatherImage
(
uiImage
:
widgetViewModel
.
weatherIcon
)
.
aspectRatio
(
contentMode
:
.
fit
)
.
frame
(
width
:
30
,
height
:
30
,
alignment
:
.
center
)
.
shadow
(
for
:
colorScheme
)
.
padding
(
.
trailing
,
4
)
}
Spacer
()
VStack
{
Spacer
()
HighLowTemperatureView
(
highTemperature
:
widgetViewModel
.
highTemperature
,
lowTemperature
:
widgetViewModel
.
lowTemperature
)
}
.
frame
(
height
:
35
)
.
padding
(
.
bottom
,
8
)
}
.
padding
(
.
top
,
10
)
.
frame
(
height
:
35
)
WidgetTopView
(
widgetViewModel
:
widgetViewModel
,
style
:
.
large
)
.
padding
(
.
top
,
4
)
HourlyTemperatureView
(
hourlyWeather
:
widgetViewModel
.
hourlyWeather
)
.
padding
(
.
top
,
16
)
HStack
{
Text
(
"Next few Days"
)
...
...
@@ -72,19 +43,20 @@ public struct LargeTemperatureWidgetView: View {
.
padding
(
.
top
,
17
)
VStack
{
ForEach
(
0
..<
4
)
{
index
in
ForEach
(
0
..<
min
(
4
,
widgetViewModel
.
dailyWather
.
count
))
{
index
in
let
daily
=
widgetViewModel
.
dailyWather
[
index
]
HStack
{
Text
(
"6, Tuesday"
)
Text
(
daily
.
dateString
)
.
font
(
WidgetFont
.
SFProDisplay
.
thin
(
size
:
14
)
.
font
)
Spacer
()
weatherDayImage
(
uiImage
:
widgetViewModel
.
weatherIcon
)
weatherDayImage
(
uiImage
:
daily
.
weatherIcon
)
Spacer
()
.
frame
(
width
:
52
)
Text
(
"75°"
)
Text
(
daily
.
minTemp
)
.
font
(
WidgetFont
.
SFProDisplay
.
thin
(
size
:
14
)
.
font
)
Spacer
()
.
frame
(
width
:
52
)
Text
(
"81°"
)
Text
(
daily
.
maxTemp
)
.
font
(
WidgetFont
.
SFProDisplay
.
thin
(
size
:
14
)
.
font
)
Spacer
()
.
frame
(
width
:
28
)
...
...
@@ -92,6 +64,7 @@ public struct LargeTemperatureWidgetView: View {
}
}
.
padding
([
.
top
,
.
bottom
],
20
)
}
.
padding
([
.
leading
,
.
trailing
],
10
)
.
background
(
WidgetColor
.
Name
(
"PrimaryBackground"
))
...
...
OneWeatherUI/OneWeatherUI/Widgets/Temperature/MediumTemperatureWidgetView.swift
View file @
b82c8b09
...
...
@@ -20,7 +20,7 @@ public struct MediumTemperatureWidgetView: View {
public
var
body
:
some
View
{
VStack
(
alignment
:
.
leading
)
{
MediumWidgetTopView
(
widgetViewModel
:
widgetViewModel
)
WidgetTopView
(
widgetViewModel
:
widgetViewModel
,
style
:
.
medium
)
.
padding
(
.
top
,
10
)
HourlyTemperatureView
(
hourlyWeather
:
widgetViewModel
.
hourlyWeather
)
.
padding
(
.
bottom
,
10
)
...
...
OneWeatherUI/OneWeatherUI/Widgets/ViewModels/WidgetViewModel.swift
View file @
b82c8b09
...
...
@@ -34,18 +34,18 @@ public struct WidgetHourlyWeather {
@available(iOS 14, *)
public
struct
WidgetDailyWeather
{
let
date
:
Date
let
weekDay
:
String
let
dateString
:
String
let
isToday
:
Bool
let
minTemp
:
String
let
maxTemp
:
String
let
weatherIcon
:
UIImage
public
init
(
date
:
Date
,
weekDay
:
String
,
isToday
:
Bool
,
minTemp
:
String
,
maxTemp
:
String
)
{
self
.
date
=
date
self
.
weekDay
=
weekDay
public
init
(
dateString
:
String
,
isToday
:
Bool
,
minTemp
:
String
,
maxTemp
:
String
,
weatherIcon
:
UIImage
)
{
self
.
dateString
=
dateString
self
.
isToday
=
isToday
self
.
minTemp
=
minTemp
self
.
maxTemp
=
maxTemp
self
.
weatherIcon
=
weatherIcon
}
}
...
...
OneWeatherUI/OneWeatherUI/Widgets/ViewModels/WidgetViewModelMock.swift
View file @
b82c8b09
...
...
@@ -41,11 +41,13 @@ struct WidgetViewModelMock: WidgetViewModel {
let
dailyWather
:
[
WidgetDailyWeather
]
=
{
var
array
=
[
WidgetDailyWeather
]()
for
index
in
0
..<
4
{
let
daily
=
WidgetDailyWeather
(
date
:
Date
(),
weekDay
:
"Tuesday"
,
let
daily
=
WidgetDailyWeather
(
dateString
:
"19, Monday"
,
isToday
:
false
,
minTemp
:
"
\(
10
+
2
*
index
)
°"
,
maxTemp
:
"
\(
22
+
2
*
index
)
°"
)
maxTemp
:
"
\(
22
+
2
*
index
)
°"
,
weatherIcon
:
UIImage
(
named
:
"partlyCloudyDay"
,
in
:
OneWeatherUI
.
frameworkBundle
,
compatibleWith
:
nil
)
??
UIImage
())
array
.
append
(
daily
)
}
return
array
...
...
OneWeatherWidget/Data/WeatherEntry.swift
View file @
b82c8b09
...
...
@@ -37,6 +37,19 @@ struct WeatherEntry: TimelineEntry {
func
generateDaily
()
->
[
DailyWeather
]
{
var
array
=
[
DailyWeather
]()
let
daily
=
DailyWeather
(
lastTimeUpdated
:
Date
(),
date
:
Date
(),
timeZone
:
.
current
,
weekDay
:
.
monday
)
array
.
append
(
daily
)
// for index in 0..<4 {
// let daily = DailyWeather(lastTimeUpdated: Date(),
// date: Date(),
// timeZone: TimeZone(abbreviation: "PST")!,
// weekDay: .monday,
// type: .partlyCloudy,
// minTemp: .init(value: 69, unit: .fahrenheit),
// maxTemp: .init(value: 75, unit: .fahrenheit))
// array.append(daily)
// }
return
array
}
...
...
OneWeatherWidget/UI/WidgetPlaceholderView.swift
View file @
b82c8b09
...
...
@@ -33,6 +33,6 @@ struct WidgetPlaceholderView: View {
struct
WidgetPlaceholderView_Preview
:
PreviewProvider
{
static
var
previews
:
some
View
{
WidgetPlaceholderView
()
.
previewContext
(
WidgetPreviewContext
(
family
:
.
system
Small
))
.
previewContext
(
WidgetPreviewContext
(
family
:
.
system
Large
))
}
}
OneWeatherWidget/ViewModels/ForecastWidgetViewModel.swift
View file @
b82c8b09
...
...
@@ -16,13 +16,25 @@ private struct Formatter {
return
formatter
}()
private
static
var
largeFmt
:
DateFormatter
=
{
let
formatter
=
DateFormatter
()
formatter
.
dateFormat
=
"d, EEEE"
return
formatter
}()
static
func
set
(
timeZone
:
TimeZone
)
{
fmt
.
timeZone
=
timeZone
largeFmt
.
timeZone
=
timeZone
}
static
func
dateString
(
date
:
Date
)
->
String
{
return
fmt
.
string
(
from
:
date
)
}
static
func
largeDateString
(
date
:
Date
)
->
String
{
return
largeFmt
.
string
(
from
:
date
)
}
}
struct
ForecastWidgetViewModel
:
WidgetViewModel
{
...
...
@@ -68,12 +80,12 @@ struct ForecastWidgetViewModel: WidgetViewModel {
for
index
in
0
..<
min
(
modelDaily
.
count
,
4
)
{
let
daily
=
modelDaily
[
index
]
let
dailyHourly
=
WidgetDailyWeather
(
date
:
daily
.
date
,
weekDay
:
daily
.
weekDay
.
rawValue
,
let
widgetDaily
=
WidgetDailyWeather
(
dateString
:
Formatter
.
largeDateString
(
date
:
daily
.
date
),
isToday
:
daily
.
isToday
,
minTemp
:
daily
.
minTemp
?
.
settingsConverted
.
shortString
??
""
,
maxTemp
:
daily
.
maxTemp
?
.
settingsConverted
.
shortString
??
""
)
array
.
append
(
dailyHourly
)
maxTemp
:
daily
.
maxTemp
?
.
settingsConverted
.
shortString
??
""
,
weatherIcon
:
daily
.
type
.
image
(
isDay
:
true
))
array
.
append
(
widgetDaily
)
}
return
array
}
...
...
OneWeatherWidget/Widgets/TemperatureWidget.swift
View file @
b82c8b09
...
...
@@ -23,7 +23,7 @@ struct TemperatureWidget: Widget {
}
.
configurationDisplayName
(
"widget.temperature.title"
.
localized
())
.
description
(
"widget.temperature.description"
.
localized
())
.
supportedFamilies
([
.
systemSmall
,
.
systemMedium
])
.
supportedFamilies
([
.
systemSmall
,
.
systemMedium
,
.
systemLarge
])
}
}
...
...
@@ -53,7 +53,7 @@ struct WidgetView_Preview: PreviewProvider {
date
:
Date
()))
.
preferredColorScheme
(
.
dark
)
.
previewDevice
(
"iPhone 11"
)
.
previewContext
(
WidgetPreviewContext
(
family
:
.
system
Medium
))
.
previewContext
(
WidgetPreviewContext
(
family
:
.
system
Large
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment