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
e38fdf8f
Commit
e38fdf8f
authored
Jul 05, 2021
by
Demid Merzlyakov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-101: WIP: top part of the medium temperature widget.
parent
25fcd8d2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
5 deletions
+112
-5
1Weather/Resources/en.lproj/Localizable.strings
+3
-0
OneWeatherWidget/Assets.xcassets/Colors/SeparatorColor.colorset/Contents.json
+38
-0
OneWeatherWidget/Data/WeatherEntry.swift
+2
-1
OneWeatherWidget/UI/WidgetViews/MediumTemperatureWidgetView.swift
+45
-1
OneWeatherWidget/UI/WidgetViews/SmallTemperatureWidgetView.swift
+3
-3
OneWeatherWidget/ViewModels/ForecastWidgetViewModel.swift
+21
-0
No files found.
1Weather/Resources/en.lproj/Localizable.strings
View file @
e38fdf8f
...
...
@@ -272,3 +272,6 @@
// Ads
"ads.native.sponsored" = "Sponsored";
"ads.placeholder" = "Advertisement";
// Widget
"widget.lastUpdatedTemplate" = "Last updated #LAST_UPDATED ago.";
OneWeatherWidget/Assets.xcassets/Colors/SeparatorColor.colorset/Contents.json
0 → 100644
View file @
e38fdf8f
{
"colors"
:
[
{
"color"
:
{
"color-space"
:
"display-p3"
,
"components"
:
{
"alpha"
:
"1.000"
,
"blue"
:
"0.827"
,
"green"
:
"0.815"
,
"red"
:
"0.812"
}
},
"idiom"
:
"universal"
},
{
"appearances"
:
[
{
"appearance"
:
"luminosity"
,
"value"
:
"dark"
}
],
"color"
:
{
"color-space"
:
"display-p3"
,
"components"
:
{
"alpha"
:
"1.000"
,
"blue"
:
"0.839"
,
"green"
:
"0.839"
,
"red"
:
"0.839"
}
},
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
OneWeatherWidget/Data/WeatherEntry.swift
View file @
e38fdf8f
...
...
@@ -11,12 +11,13 @@ import OneWeatherCore
struct
WeatherEntry
:
TimelineEntry
{
static
let
defaultLocation
=
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
(),
today
:
.
init
(
lastTimeUpdated
:
Date
(
timeIntervalSinceNow
:
-
4
*
3600
),
date
:
Date
(),
timeZone
:
TimeZone
.
current
,
weekDay
:
.
monday
,
...
...
OneWeatherWidget/UI/WidgetViews/MediumTemperatureWidgetView.swift
View file @
e38fdf8f
...
...
@@ -16,13 +16,57 @@ struct MediumTemperatureWidgetView: View {
var
body
:
some
View
{
GeometryReader
{
geometry
in
VStack
{
VStack
(
alignment
:
.
leading
)
{
HStack
{
HStack
(
spacing
:
8
)
{
Text
(
widgetViewModel
.
temperature
)
.
font
(
AppFont
.
SFProDisplay
.
light
(
size
:
32
)
.
font
)
.
textColor
(
for
:
colorScheme
)
Divider
()
.
padding
(
.
top
,
8
)
.
padding
(
.
bottom
,
8
)
Text
(
widgetViewModel
.
weatherType
)
.
font
(
AppFont
.
SFProDisplay
.
regular
(
size
:
12
)
.
font
)
.
textColor
(
for
:
colorScheme
)
.
lineLimit
(
2
)
Image
(
uiImage
:
widgetViewModel
.
weatherIcon
)
.
resizable
()
.
aspectRatio
(
contentMode
:
.
fit
)
.
frame
(
width
:
30
,
height
:
30
,
alignment
:
.
center
)
.
shadow
(
color
:
Color
.
black
.
opacity
(
0.23
),
radius
:
16
,
x
:
2
,
y
:
0
)
.
padding
(
.
trailing
,
4
)
}
Spacer
()
VStack
(
spacing
:
2
)
{
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
HighLowTemperatureView
(
highTemperature
:
widgetViewModel
.
highTemperature
,
lowTemperature
:
widgetViewModel
.
lowTemperature
)
}
.
frame
(
height
:
35
)
}
.
frame
(
height
:
35
)
.
padding
(
.
top
,
12
)
HStack
(
alignment
:
.
top
)
{
Text
(
"SmartText"
)
.
font
(
AppFont
.
SFProDisplay
.
regular
(
size
:
12
)
.
font
)
Spacer
()
if
widgetViewModel
.
showLastTimeUpdated
{
Text
(
widgetViewModel
.
lastTimeUpdatedText
)
.
font
(
AppFont
.
SFProDisplay
.
regular
(
size
:
9
)
.
font
)
}
}
Spacer
()
// TODO: implement
}
.
padding
([
.
leading
,
.
trailing
],
10
)
}
}
...
...
OneWeatherWidget/UI/WidgetViews/SmallTemperatureWidgetView.swift
View file @
e38fdf8f
...
...
@@ -74,8 +74,8 @@ struct SmallTemperatureWidgetView: View {
}
//MARK: Appearence extension
private
extension
View
{
func
shadow
(
for
colorScheme
:
ColorScheme
)
->
some
View
{
extension
View
{
public
func
shadow
(
for
colorScheme
:
ColorScheme
)
->
some
View
{
switch
colorScheme
{
case
.
light
:
return
self
.
shadow
(
color
:
Color
.
black
.
opacity
(
0.5
),
radius
:
16
,
x
:
2
,
y
:
0
)
...
...
@@ -86,7 +86,7 @@ private extension View {
}
}
func
textColor
(
for
colorScheme
:
ColorScheme
)
->
some
View
{
public
func
textColor
(
for
colorScheme
:
ColorScheme
)
->
some
View
{
switch
colorScheme
{
case
.
light
:
return
self
.
foregroundColor
(
ThemeManager
.
currentTheme
.
secondaryTextColor
.
color
)
...
...
OneWeatherWidget/ViewModels/ForecastWidgetViewModel.swift
View file @
e38fdf8f
...
...
@@ -9,6 +9,8 @@ import SwiftUI
import
OneWeatherCore
struct
ForecastWidgetViewModel
{
let
showLastTimeUpdated
:
Bool
let
lastTimeUpdatedText
:
String
let
cityName
:
String
let
temperature
:
String
let
weatherType
:
String
...
...
@@ -25,5 +27,24 @@ struct ForecastWidgetViewModel {
self
.
highTemperature
=
location
.
today
?
.
maxTemp
?
.
shortString
??
"--"
self
.
lowTemperature
=
location
.
today
?
.
minTemp
?
.
shortString
??
"--"
self
.
isDeviceLocation
=
location
.
deviceLocation
if
let
lastTimeUpdated
=
location
.
lastWeatherUpdateDate
{
let
oneHour
=
TimeInterval
(
3600
)
let
timeSinceLastUpdate
=
Date
()
.
timeIntervalSince
(
lastTimeUpdated
)
self
.
showLastTimeUpdated
=
timeSinceLastUpdate
>
3
*
oneHour
let
dateComponentsFormatter
=
DateComponentsFormatter
()
dateComponentsFormatter
.
allowedUnits
=
[
.
hour
,
.
day
]
dateComponentsFormatter
.
zeroFormattingBehavior
=
.
dropAll
dateComponentsFormatter
.
unitsStyle
=
.
short
let
formattedTimeAgo
=
dateComponentsFormatter
.
string
(
from
:
timeSinceLastUpdate
)
??
"--"
self
.
lastTimeUpdatedText
=
"widget.lastUpdatedTemplate"
.
localized
()
.
replacingOccurrences
(
of
:
"#LAST_UPDATED"
,
with
:
formattedTimeAgo
)
}
else
{
self
.
showLastTimeUpdated
=
false
lastTimeUpdatedText
=
""
}
}
}
Dmitriy Stepanets
@DStepanets
mentioned in commit
e5533185
Aug 30, 2021
mentioned in commit
e5533185
mentioned in commit e55331851cb5a0cfd64f1d7bdeff36b0c87b91a8
Toggle commit list
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