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
24ea9f89
Commit
24ea9f89
authored
Jul 20, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished large temperature widget integration
parent
b82c8b09
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
74 deletions
+95
-74
1Weather.xcodeproj/project.pbxproj
+12
-2
1Weather/Info.plist
+1
-0
1Weather/UI/Helpers/AppFont.swift
+3
-0
1Weather/UI/View controllers/WidgetPromotion/WidgetPromotionController.swift
+1
-0
OneWeatherUI/OneWeatherUI/Widgets/Temperature/LargeTemperatureWidgetView.swift
+0
-4
OneWeatherWidget/Data/WeatherEntry.swift
+1
-66
OneWeatherWidget/Data/WeatherLocationMock.swift
+75
-0
OneWeatherWidget/Info.plist
+1
-0
OneWeatherWidget/Widgets/TemperatureWidget.swift
+1
-2
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
24ea9f89
...
@@ -155,6 +155,9 @@
...
@@ -155,6 +155,9 @@
CD8E041225F8F775001785B6
/* ForecastViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD8E041125F8F775001785B6
/* ForecastViewModel.swift */
;
};
CD8E041225F8F775001785B6
/* ForecastViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD8E041125F8F775001785B6
/* ForecastViewModel.swift */
;
};
CD8E041625F8F91B001785B6
/* ForecastCellFactory.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD8E041525F8F91B001785B6
/* ForecastCellFactory.swift */
;
};
CD8E041625F8F91B001785B6
/* ForecastCellFactory.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD8E041525F8F91B001785B6
/* ForecastCellFactory.swift */
;
};
CD9B6B1425DBCDE2001D9B80
/* GraphView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD9B6B1325DBCDE2001D9B80
/* GraphView.swift */
;
};
CD9B6B1425DBCDE2001D9B80
/* GraphView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CD9B6B1325DBCDE2001D9B80
/* GraphView.swift */
;
};
CDA02A1926A6F92F00A8F2F6
/* WeatherLocationMock.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA02A1826A6F92F00A8F2F6
/* WeatherLocationMock.swift */
;
};
CDA02A1D26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA02A1C26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf */
;
};
CDA02A1E26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA02A1C26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf */
;
};
CDA5542825EF734200A2E08C
/* TodayCellFactory.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA5542725EF734200A2E08C
/* TodayCellFactory.swift */
;
};
CDA5542825EF734200A2E08C
/* TodayCellFactory.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA5542725EF734200A2E08C
/* TodayCellFactory.swift */
;
};
CDA5542D25EF7C9700A2E08C
/* ReusableCellProtocol.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA5542C25EF7C9700A2E08C
/* ReusableCellProtocol.swift */
;
};
CDA5542D25EF7C9700A2E08C
/* ReusableCellProtocol.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDA5542C25EF7C9700A2E08C
/* ReusableCellProtocol.swift */
;
};
CDAC9B8526319B0500AC1BF4
/* MapTimeControlItem.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDAC9B8426319B0500AC1BF4
/* MapTimeControlItem.swift */
;
};
CDAC9B8526319B0500AC1BF4
/* MapTimeControlItem.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
CDAC9B8426319B0500AC1BF4
/* MapTimeControlItem.swift */
;
};
...
@@ -464,6 +467,8 @@
...
@@ -464,6 +467,8 @@
CD8E041125F8F775001785B6
/* ForecastViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastViewModel.swift
;
sourceTree
=
"<group>"
;
};
CD8E041125F8F775001785B6
/* ForecastViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastViewModel.swift
;
sourceTree
=
"<group>"
;
};
CD8E041525F8F91B001785B6
/* ForecastCellFactory.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastCellFactory.swift
;
sourceTree
=
"<group>"
;
};
CD8E041525F8F91B001785B6
/* ForecastCellFactory.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ForecastCellFactory.swift
;
sourceTree
=
"<group>"
;
};
CD9B6B1325DBCDE2001D9B80
/* GraphView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GraphView.swift
;
sourceTree
=
"<group>"
;
};
CD9B6B1325DBCDE2001D9B80
/* GraphView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
GraphView.swift
;
sourceTree
=
"<group>"
;
};
CDA02A1826A6F92F00A8F2F6
/* WeatherLocationMock.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
WeatherLocationMock.swift
;
sourceTree
=
"<group>"
;
};
CDA02A1C26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
name
=
"SF-Pro-Display-Thin.otf"
;
path
=
"OneWeatherUI/OneWeatherUI/Fonts/SF-Pro-Display-Thin.otf"
;
sourceTree
=
SOURCE_ROOT
;
};
CDA5542725EF734200A2E08C
/* TodayCellFactory.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TodayCellFactory.swift
;
sourceTree
=
"<group>"
;
};
CDA5542725EF734200A2E08C
/* TodayCellFactory.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TodayCellFactory.swift
;
sourceTree
=
"<group>"
;
};
CDA5542C25EF7C9700A2E08C
/* ReusableCellProtocol.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ReusableCellProtocol.swift
;
sourceTree
=
"<group>"
;
};
CDA5542C25EF7C9700A2E08C
/* ReusableCellProtocol.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ReusableCellProtocol.swift
;
sourceTree
=
"<group>"
;
};
CDAC9B8426319B0500AC1BF4
/* MapTimeControlItem.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MapTimeControlItem.swift
;
sourceTree
=
"<group>"
;
};
CDAC9B8426319B0500AC1BF4
/* MapTimeControlItem.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MapTimeControlItem.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -827,6 +832,7 @@
...
@@ -827,6 +832,7 @@
children
=
(
children
=
(
CD415DA22668FFF300177515
/* WeatherProvider.swift */
,
CD415DA22668FFF300177515
/* WeatherProvider.swift */
,
CD5293D92669094E009547C8
/* WeatherEntry.swift */
,
CD5293D92669094E009547C8
/* WeatherEntry.swift */
,
CDA02A1826A6F92F00A8F2F6
/* WeatherLocationMock.swift */
,
);
);
path
=
Data
;
path
=
Data
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -1177,6 +1183,7 @@
...
@@ -1177,6 +1183,7 @@
CDD0F1E3257240F300CF5017
/* Fonts */
=
{
CDD0F1E3257240F300CF5017
/* Fonts */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
CDA02A1C26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf */
,
CD483A9C2664E08200CA53AB
/* SF-Pro-Display-Regular.otf */
,
CD483A9C2664E08200CA53AB
/* SF-Pro-Display-Regular.otf */
,
CD483A992664DF7300CA53AB
/* SF-Pro-Display-Light.otf */
,
CD483A992664DF7300CA53AB
/* SF-Pro-Display-Light.otf */
,
87B66BF02667AF1900B9A59A
/* SF-Compact-Display-Light.otf */
,
87B66BF02667AF1900B9A59A
/* SF-Compact-Display-Light.otf */
,
...
@@ -1553,6 +1560,7 @@
...
@@ -1553,6 +1560,7 @@
CE13B88E26248A77007CBD4D
/* GoogleService-Info-Production.plist in Resources */
,
CE13B88E26248A77007CBD4D
/* GoogleService-Info-Production.plist in Resources */
,
CD1237CC255D5C5C00C98139
/* Assets.xcassets in Resources */
,
CD1237CC255D5C5C00C98139
/* Assets.xcassets in Resources */
,
CD483A9D2664E08200CA53AB
/* SF-Pro-Display-Regular.otf in Resources */
,
CD483A9D2664E08200CA53AB
/* SF-Pro-Display-Regular.otf in Resources */
,
CDA02A1D26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf in Resources */
,
CD822FFA25D6890900A05501
/* OneWeatherColorsAsset.xcassets in Resources */
,
CD822FFA25D6890900A05501
/* OneWeatherColorsAsset.xcassets in Resources */
,
);
);
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
...
@@ -1561,6 +1569,7 @@
...
@@ -1561,6 +1569,7 @@
isa
=
PBXResourcesBuildPhase
;
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
CDA02A1E26A7021D00A8F2F6
/* SF-Pro-Display-Thin.otf in Resources */
,
CD483A942664D64A00CA53AB
/* Assets.xcassets in Resources */
,
CD483A942664D64A00CA53AB
/* Assets.xcassets in Resources */
,
CD5293E9266A562F009547C8
/* OneWeatherColorsAsset.xcassets in Resources */
,
CD5293E9266A562F009547C8
/* OneWeatherColorsAsset.xcassets in Resources */
,
CD5293E0266A30EE009547C8
/* Localizable.strings in Resources */
,
CD5293E0266A30EE009547C8
/* Localizable.strings in Resources */
,
...
@@ -1943,6 +1952,7 @@
...
@@ -1943,6 +1952,7 @@
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
CD5293E1266A4258009547C8
/* AppFont.swift in Sources */
,
CD5293E1266A4258009547C8
/* AppFont.swift in Sources */
,
CDA02A1926A6F92F00A8F2F6
/* WeatherLocationMock.swift in Sources */
,
CD5293DF266A235F009547C8
/* ForecastWidgetViewModel.swift in Sources */
,
CD5293DF266A235F009547C8
/* ForecastWidgetViewModel.swift in Sources */
,
CD5293D8266908DB009547C8
/* WidgetPlaceholderView.swift in Sources */
,
CD5293D8266908DB009547C8
/* WidgetPlaceholderView.swift in Sources */
,
CD5293EA266A564E009547C8
/* ThemeProtocol.swift in Sources */
,
CD5293EA266A564E009547C8
/* ThemeProtocol.swift in Sources */
,
...
@@ -2230,7 +2240,7 @@
...
@@ -2230,7 +2240,7 @@
CURRENT_PROJECT_VERSION
=
SET_BY_BUILD_SCRIPT
;
CURRENT_PROJECT_VERSION
=
SET_BY_BUILD_SCRIPT
;
DEVELOPMENT_TEAM
=
24W4XMQ38L
;
DEVELOPMENT_TEAM
=
24W4XMQ38L
;
INFOPLIST_FILE
=
OneWeatherNotificationServiceExtension/Info.plist
;
INFOPLIST_FILE
=
OneWeatherNotificationServiceExtension/Info.plist
;
IPHONEOS_DEPLOYMENT_TARGET
=
1
4
.4
;
IPHONEOS_DEPLOYMENT_TARGET
=
1
1
.4
;
LD_RUNPATH_SEARCH_PATHS
=
(
LD_RUNPATH_SEARCH_PATHS
=
(
"$(inherited)"
,
"$(inherited)"
,
"@executable_path/Frameworks"
,
"@executable_path/Frameworks"
,
...
@@ -2254,7 +2264,7 @@
...
@@ -2254,7 +2264,7 @@
CURRENT_PROJECT_VERSION
=
SET_BY_BUILD_SCRIPT
;
CURRENT_PROJECT_VERSION
=
SET_BY_BUILD_SCRIPT
;
DEVELOPMENT_TEAM
=
24W4XMQ38L
;
DEVELOPMENT_TEAM
=
24W4XMQ38L
;
INFOPLIST_FILE
=
OneWeatherNotificationServiceExtension/Info.plist
;
INFOPLIST_FILE
=
OneWeatherNotificationServiceExtension/Info.plist
;
IPHONEOS_DEPLOYMENT_TARGET
=
1
4
.4
;
IPHONEOS_DEPLOYMENT_TARGET
=
1
1
.4
;
LD_RUNPATH_SEARCH_PATHS
=
(
LD_RUNPATH_SEARCH_PATHS
=
(
"$(inherited)"
,
"$(inherited)"
,
"@executable_path/Frameworks"
,
"@executable_path/Frameworks"
,
...
...
1Weather/Info.plist
View file @
24ea9f89
...
@@ -398,6 +398,7 @@
...
@@ -398,6 +398,7 @@
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
SF-Pro-Display-Light.otf
<
/string
>
<
string
>
SF-Pro-Display-Light.otf
<
/string
>
<
string
>
SF-Pro-Display-Regular.otf
<
/string
>
<
string
>
SF-Pro-Display-Regular.otf
<
/string
>
<
string
>
SF-Pro-Display-Thin.otf
<
/string
>
<
string
>
SF-Pro.ttf
<
/string
>
<
string
>
SF-Pro.ttf
<
/string
>
<
string
>
SF-Compact-Display-Light.otf
<
/string
>
<
string
>
SF-Compact-Display-Light.otf
<
/string
>
<
string
>
SF-Compact-Display-Regular.otf
<
/string
>
<
string
>
SF-Compact-Display-Regular.otf
<
/string
>
...
...
1Weather/UI/Helpers/AppFont.swift
View file @
24ea9f89
...
@@ -67,6 +67,9 @@ public struct AppFont {
...
@@ -67,6 +67,9 @@ public struct AppFont {
static
func
regular
(
size
:
CGFloat
)
->
UIFont
{
static
func
regular
(
size
:
CGFloat
)
->
UIFont
{
font
(
weigth
:
.
regular
,
size
:
size
)
font
(
weigth
:
.
regular
,
size
:
size
)
}
}
static
func
thin
(
size
:
CGFloat
)
->
UIFont
{
font
(
weigth
:
.
thin
,
size
:
size
)
}
}
}
public
struct
SFCompactDisplay
{
public
struct
SFCompactDisplay
{
...
...
1Weather/UI/View controllers/WidgetPromotion/WidgetPromotionController.swift
View file @
24ea9f89
...
@@ -197,6 +197,7 @@ private extension WidgetPromotionController {
...
@@ -197,6 +197,7 @@ private extension WidgetPromotionController {
stackView
.
addArrangedSubview
(
PromotionHeaderView
())
stackView
.
addArrangedSubview
(
PromotionHeaderView
())
stackView
.
addArrangedSubview
(
PromotionSmallWidgetView
())
stackView
.
addArrangedSubview
(
PromotionSmallWidgetView
())
stackView
.
addArrangedSubview
(
PromotionWidgetViewWrapper
(
widgetType
:
.
temperatureMedium
))
stackView
.
addArrangedSubview
(
PromotionWidgetViewWrapper
(
widgetType
:
.
temperatureMedium
))
stackView
.
addArrangedSubview
(
PromotionWidgetViewWrapper
(
widgetType
:
.
temperatureLarge
))
stackView
.
addArrangedSubview
(
PromotionWidgetViewWrapper
(
widgetType
:
.
precipitationMedium
))
stackView
.
addArrangedSubview
(
PromotionWidgetViewWrapper
(
widgetType
:
.
precipitationMedium
))
scrollView
.
addSubview
(
stackView
)
scrollView
.
addSubview
(
stackView
)
...
...
OneWeatherUI/OneWeatherUI/Widgets/Temperature/LargeTemperatureWidgetView.swift
View file @
24ea9f89
...
@@ -84,10 +84,6 @@ private extension View {
...
@@ -84,10 +84,6 @@ private extension View {
}
}
}
}
func
weatherImage
(
uiImage
:
UIImage
)
->
Image
{
return
Image
(
uiImage
:
uiImage
.
scalePreservingAspectRatio
(
targetSize
:
.
init
(
width
:
30
,
height
:
30
)))
}
func
weatherDayImage
(
uiImage
:
UIImage
)
->
Image
{
func
weatherDayImage
(
uiImage
:
UIImage
)
->
Image
{
return
Image
(
uiImage
:
uiImage
.
scalePreservingAspectRatio
(
targetSize
:
.
init
(
width
:
20
,
height
:
20
)))
return
Image
(
uiImage
:
uiImage
.
scalePreservingAspectRatio
(
targetSize
:
.
init
(
width
:
20
,
height
:
20
)))
}
}
...
...
OneWeatherWidget/Data/WeatherEntry.swift
View file @
24ea9f89
...
@@ -10,76 +10,11 @@ import WidgetKit
...
@@ -10,76 +10,11 @@ import WidgetKit
import
OneWeatherCore
import
OneWeatherCore
struct
WeatherEntry
:
TimelineEntry
{
struct
WeatherEntry
:
TimelineEntry
{
static
let
defaultLocation
:
Location
=
{
func
generateHourly
()
->
[
HourlyWeather
]
{
var
array
=
[
HourlyWeather
]()
for
index
in
1
...
7
{
let
hourly
=
HourlyWeather
(
lastTimeUpdated
:
Date
(),
date
:
Date
(
timeIntervalSinceNow
:
TimeInterval
(
index
*
3600
)),
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
,
weekDay
:
WeekDay
.
init
(
grigorianWeekDayNumber
:
index
)
??
.
monday
,
type
:
.
partlyCloudy
,
isDay
:
true
,
temp
:
.
init
(
value
:
69
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
dewPoint
:
.
init
(
value
:
69
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
apparentTemp
:
.
init
(
value
:
65
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
windSpeed
:
.
init
(
value
:
Double
(
8
+
index
),
unit
:
.
metersPerSecond
),
windDirection
:
.
northNorthEast
,
precipitationProbability
:
55
,
humidity
:
80
)
array
.
append
(
hourly
)
}
return
array
}
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
}
let
loc
=
Location
(
deviceLocation
:
true
,
lastWeatherUpdateDate
:
Date
(
timeIntervalSinceNow
:
-
4
*
3600
),
coordinates
:
.
init
(
latitude
:
37.3230
,
longitude
:
-
122.0322
),
countryName
:
"USA"
,
region
:
"US"
,
cityName
:
"Cupertino"
,
// Cupertino
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
,
today
:
.
init
(
lastTimeUpdated
:
Date
(
timeIntervalSinceNow
:
-
4
*
3600
),
date
:
Date
(),
timeZone
:
TimeZone
.
current
,
weekDay
:
.
monday
,
type
:
.
partlyCloudy
,
isDay
:
true
,
minTemp
:
.
init
(
value
:
89
,
unit
:
.
fahrenheit
),
maxTemp
:
.
init
(
value
:
97
,
unit
:
.
fahrenheit
),
temp
:
.
init
(
value
:
96
,
unit
:
.
fahrenheit
)),
daily
:
generateDaily
(),
hourly
:
generateHourly
(),
dayTimeForecast
:
[])
return
loc
}()
let
date
:
Date
let
date
:
Date
let
location
:
Location
let
location
:
Location
init
(
location
:
Location
?
=
nil
,
date
:
Date
=
Date
())
{
init
(
location
:
Location
?
=
nil
,
date
:
Date
=
Date
())
{
self
.
location
=
location
??
Weather
Entry
.
defaultL
ocation
self
.
location
=
location
??
Weather
LocationMock
()
.
l
ocation
self
.
date
=
date
self
.
date
=
date
}
}
}
}
OneWeatherWidget/Data/WeatherLocationMock.swift
0 → 100644
View file @
24ea9f89
//
// WeatherLocationMock.swift
// OneWeatherWidgetExtension
//
// Created by Dmitry Stepanets on 20.07.2021.
//
import
WidgetKit
import
OneWeatherCore
struct
WeatherLocationMock
{
let
location
:
Location
init
()
{
func
generateDaily
()
->
[
DailyWeather
]
{
var
array
=
[
DailyWeather
]()
for
index
in
0
..<
4
{
let
daily
=
DailyWeather
(
lastTimeUpdated
:
Date
(),
date
:
Date
(
timeIntervalSinceNow
:
TimeInterval
(
index
*
3600
*
24
)),
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
,
weekDay
:
WeekDay
(
grigorianWeekDayNumber
:
index
)
??
.
monday
,
type
:
.
partlyCloudy
,
minTemp
:
.
init
(
value
:
69
+
Double
(
index
),
unit
:
.
fahrenheit
),
maxTemp
:
.
init
(
value
:
75
+
Double
(
index
),
unit
:
.
fahrenheit
))
array
.
append
(
daily
)
}
return
array
}
func
generateHourly
()
->
[
HourlyWeather
]
{
var
array
=
[
HourlyWeather
]()
for
index
in
1
...
7
{
let
hourly
=
HourlyWeather
(
lastTimeUpdated
:
Date
(),
date
:
Date
(
timeIntervalSinceNow
:
TimeInterval
(
index
*
3600
)),
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
,
weekDay
:
WeekDay
.
init
(
grigorianWeekDayNumber
:
index
)
??
.
monday
,
type
:
.
partlyCloudy
,
isDay
:
true
,
temp
:
.
init
(
value
:
69
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
dewPoint
:
.
init
(
value
:
69
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
apparentTemp
:
.
init
(
value
:
65
+
Double
(
index
)
*
2
,
unit
:
.
fahrenheit
),
windSpeed
:
.
init
(
value
:
Double
(
8
+
index
),
unit
:
.
metersPerSecond
),
windDirection
:
.
northNorthEast
,
precipitationProbability
:
55
,
humidity
:
80
)
array
.
append
(
hourly
)
}
return
array
}
self
.
location
=
Location
(
deviceLocation
:
true
,
lastWeatherUpdateDate
:
Date
(
timeIntervalSinceNow
:
-
4
*
3600
),
coordinates
:
.
init
(
latitude
:
37.3230
,
longitude
:
-
122.0322
),
countryName
:
"USA"
,
region
:
"US"
,
cityName
:
"Cupertino"
,
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
,
today
:
.
init
(
lastTimeUpdated
:
Date
(
timeIntervalSinceNow
:
-
4
*
3600
),
date
:
Date
(),
timeZone
:
TimeZone
.
current
,
weekDay
:
.
monday
,
type
:
.
partlyCloudy
,
isDay
:
true
,
minTemp
:
.
init
(
value
:
89
,
unit
:
.
fahrenheit
),
maxTemp
:
.
init
(
value
:
97
,
unit
:
.
fahrenheit
),
temp
:
.
init
(
value
:
96
,
unit
:
.
fahrenheit
)),
daily
:
generateDaily
(),
hourly
:
generateHourly
(),
dayTimeForecast
:
[])
}
}
OneWeatherWidget/Info.plist
View file @
24ea9f89
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
UIAppFonts
<
/k
e
y
>
<
k
e
y
>
UIAppFonts
<
/k
e
y
>
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
SF-Pro-Display-Thin.otf
<
/string
>
<
string
>
SF-Pro-Display-Light.otf
<
/string
>
<
string
>
SF-Pro-Display-Light.otf
<
/string
>
<
string
>
SF-Pro-Display-Regular.otf
<
/string
>
<
string
>
SF-Pro-Display-Regular.otf
<
/string
>
<
string
>
SF-Pro.ttf
<
/string
>
<
string
>
SF-Pro.ttf
<
/string
>
...
...
OneWeatherWidget/Widgets/TemperatureWidget.swift
View file @
24ea9f89
...
@@ -49,8 +49,7 @@ private struct WidgetView: View {
...
@@ -49,8 +49,7 @@ private struct WidgetView: View {
struct
WidgetView_Preview
:
PreviewProvider
{
struct
WidgetView_Preview
:
PreviewProvider
{
public
static
var
previews
:
some
View
{
public
static
var
previews
:
some
View
{
WidgetView
(
entry
:
WeatherEntry
(
location
:
WeatherEntry
.
defaultLocation
,
WidgetView
(
entry
:
WeatherEntry
())
date
:
Date
()))
.
preferredColorScheme
(
.
dark
)
.
preferredColorScheme
(
.
dark
)
.
previewDevice
(
"iPhone 11"
)
.
previewDevice
(
"iPhone 11"
)
.
previewContext
(
WidgetPreviewContext
(
family
:
.
systemLarge
))
.
previewContext
(
WidgetPreviewContext
(
family
:
.
systemLarge
))
...
...
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