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
e69ff80b
Commit
e69ff80b
authored
Mar 03, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed graph drawning
parent
42c32561
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
18 deletions
+48
-18
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
1Weather/Resources/en.lproj/Localizable.strings
+3
-0
1Weather/UI/View controllers/Today/Cells/CityForecastCell.swift
+1
-1
1Weather/UI/View controllers/Today/Cells/CityForecastTimePeriod/CityForecastTimePeriodCell.swift
+12
-6
1Weather/UI/View controllers/Today/Cells/CityForecastTimePeriod/PeriodForecastButton.swift
+19
-0
1Weather/ViewModels/TodayViewModel.swift
+8
-6
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+5
-5
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
View file @
e69ff80b
No preview for this file type
1Weather/Resources/en.lproj/Localizable.strings
View file @
e69ff80b
...
@@ -30,6 +30,9 @@
...
@@ -30,6 +30,9 @@
"forecast.smoke" = "Smoke";
"forecast.smoke" = "Smoke";
"forecast.unknown" = "Unknown";
"forecast.unknown" = "Unknown";
//Day
"day.today" = "Today";
//Day time
//Day time
"dayTime.morning" = "Morning";
"dayTime.morning" = "Morning";
"dayTime.noon" = "Noon";
"dayTime.noon" = "Noon";
...
...
1Weather/UI/View controllers/Today/Cells/CityForecastCell.swift
View file @
e69ff80b
...
@@ -34,7 +34,7 @@ class CityForecastCell: UITableViewCell {
...
@@ -34,7 +34,7 @@ class CityForecastCell: UITableViewCell {
}
}
public
func
configure
(
with
location
:
Location
)
{
public
func
configure
(
with
location
:
Location
)
{
cityImageView
.
image
=
UIImage
(
named
:
location
.
imageName
)
cityImageView
.
image
=
UIImage
(
named
:
location
.
imageName
??
""
)
temperatureLabel
.
text
=
location
.
today
?
.
temp
?
.
shortString
temperatureLabel
.
text
=
location
.
today
?
.
temp
?
.
shortString
let
maxTemp
=
location
.
today
?
.
maxTemp
?
.
shortString
??
"--"
let
maxTemp
=
location
.
today
?
.
maxTemp
?
.
shortString
??
"--"
let
minTemp
=
location
.
today
?
.
minTemp
?
.
shortString
??
"--"
let
minTemp
=
location
.
today
?
.
minTemp
?
.
shortString
??
"--"
...
...
1Weather/UI/View controllers/Today/Cells/CityForecastTimePeriod/CityForecastTimePeriodCell.swift
View file @
e69ff80b
...
@@ -40,6 +40,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
...
@@ -40,6 +40,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
private
let
graphView
=
GraphView
()
private
let
graphView
=
GraphView
()
private
var
graphIsDrawn
=
false
private
var
graphIsDrawn
=
false
//MARK:- Cell life cycle
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
...
@@ -62,7 +63,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
...
@@ -62,7 +63,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
}
}
public
func
drawGraphIfNeeded
()
{
public
func
drawGraphIfNeeded
()
{
guard
!
graphIsDrawn
else
{
return
}
guard
graphIsDrawn
==
false
else
{
return
}
//Checking for correct height
//Checking for correct height
guard
guard
...
@@ -74,7 +75,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
...
@@ -74,7 +75,7 @@ class CityForecastTimePeriodCell: UITableViewCell {
graphView
.
frame
=
.
init
(
x
:
0
,
graphView
.
frame
=
.
init
(
x
:
0
,
y
:
periodButton
.
graphRect
.
origin
.
y
,
y
:
periodButton
.
graphRect
.
origin
.
y
,
width
:
s
crollView
.
contentSiz
e
.
width
,
width
:
s
tackView
.
fram
e
.
width
,
height
:
periodButton
.
graphRect
.
height
)
height
:
periodButton
.
graphRect
.
height
)
updateGraphPoints
()
updateGraphPoints
()
...
@@ -162,7 +163,11 @@ class CityForecastTimePeriodCell: UITableViewCell {
...
@@ -162,7 +163,11 @@ class CityForecastTimePeriodCell: UITableViewCell {
self
.
graphView
.
tintMainDotAt
(
point
:
maxTempPoints
[
button
.
index
])
self
.
graphView
.
tintMainDotAt
(
point
:
maxTempPoints
[
button
.
index
])
self
.
graphView
.
tintAdditionalDotAt
(
point
:
minTempsPoints
[
button
.
index
])
self
.
graphView
.
tintAdditionalDotAt
(
point
:
minTempsPoints
[
button
.
index
])
case
.
hourly
:
case
.
hourly
:
break
guard
let
points
=
hourlyGraphPoints
?
.
points
else
{
return
}
self
.
graphView
.
tintGraphFrom
(
startPointX
:
button
.
frame
.
origin
.
x
,
endPointX
:
button
.
frame
.
origin
.
x
+
button
.
bounds
.
width
)
self
.
graphView
.
tintMainDotAt
(
point
:
points
[
button
.
index
])
}
}
}
}
...
@@ -235,10 +240,11 @@ class CityForecastTimePeriodCell: UITableViewCell {
...
@@ -235,10 +240,11 @@ class CityForecastTimePeriodCell: UITableViewCell {
let
levelsCount
=
CGFloat
(
Set
(
temps
)
.
count
)
let
levelsCount
=
CGFloat
(
Set
(
temps
)
.
count
)
let
levelHeight
=
(
graphView
.
frame
.
height
/
CGFloat
(
levelsCount
))
.
rounded
(
.
down
)
let
levelHeight
=
(
graphView
.
frame
.
height
/
CGFloat
(
levelsCount
))
.
rounded
(
.
down
)
let
tempFrame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
graphView
.
frame
.
width
,
height
:
levelsCount
*
levelH
eight
)
let
tempFrame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
graphView
.
frame
.
width
,
height
:
graphView
.
frame
.
h
eight
)
var
pointLevel
=
tempFrame
.
origin
.
y
+
((
maxTemp
-
temps
[
index
])
*
levelHeight
)
+
levelHeight
var
pointLevel
=
tempFrame
.
origin
.
y
+
((
maxTemp
-
temps
[
index
])
*
levelHeight
)
pointLevel
=
min
(
pointLevel
,
tempFrame
.
height
+
5
)
pointLevel
=
max
(
pointLevel
,
tempFrame
.
origin
.
y
+
10
)
pointLevel
=
min
(
tempFrame
.
height
-
10
,
pointLevel
)
points
.
append
(
.
init
(
x
:
buttonCenterX
,
y
:
pointLevel
))
points
.
append
(
.
init
(
x
:
buttonCenterX
,
y
:
pointLevel
))
}
}
...
...
1Weather/UI/View controllers/Today/Cells/CityForecastTimePeriod/PeriodForecastButton.swift
View file @
e69ff80b
...
@@ -9,6 +9,16 @@ import UIKit
...
@@ -9,6 +9,16 @@ import UIKit
class
PeriodForecastButton
:
UIControl
{
class
PeriodForecastButton
:
UIControl
{
//Private
//Private
private
static
let
hourlyFormatter
:
DateFormatter
=
{
let
fmt
=
DateFormatter
()
fmt
.
dateFormat
=
"h a"
return
fmt
}()
private
static
let
dailyFormatter
:
DateFormatter
=
{
let
fmt
=
DateFormatter
()
fmt
.
dateFormat
=
"d, E"
return
fmt
}()
private
let
kGraphInset
:
CGFloat
=
10
private
let
kGraphInset
:
CGFloat
=
10
private
let
forecastImageView
=
UIImageView
()
private
let
forecastImageView
=
UIImageView
()
private
let
tempLabel
=
UILabel
()
private
let
tempLabel
=
UILabel
()
...
@@ -73,11 +83,20 @@ class PeriodForecastButton: UIControl {
...
@@ -73,11 +83,20 @@ class PeriodForecastButton: UIControl {
public
func
configure
(
dailyWeather
:
DailyWeather
)
{
public
func
configure
(
dailyWeather
:
DailyWeather
)
{
self
.
tempLabel
.
text
=
dailyWeather
.
maxTemp
?
.
shortString
self
.
tempLabel
.
text
=
dailyWeather
.
maxTemp
?
.
shortString
self
.
minTempLabel
.
text
=
dailyWeather
.
minTemp
?
.
shortString
self
.
minTempLabel
.
text
=
dailyWeather
.
minTemp
?
.
shortString
self
.
indicatorImageView
.
image
=
nil
if
Calendar
.
current
.
isDateInToday
(
dailyWeather
.
date
)
{
self
.
timeLabel
.
text
=
"day.today"
.
localized
()
}
else
{
self
.
timeLabel
.
text
=
PeriodForecastButton
.
dailyFormatter
.
string
(
from
:
dailyWeather
.
date
)
}
}
}
public
func
configure
(
hourlyWeather
:
HourlyWeather
)
{
public
func
configure
(
hourlyWeather
:
HourlyWeather
)
{
self
.
tempLabel
.
text
=
hourlyWeather
.
temp
?
.
shortString
self
.
tempLabel
.
text
=
hourlyWeather
.
temp
?
.
shortString
self
.
minTempLabel
.
text
=
nil
self
.
minTempLabel
.
text
=
nil
self
.
indicatorImageView
.
image
=
nil
self
.
timeLabel
.
text
=
PeriodForecastButton
.
hourlyFormatter
.
string
(
from
:
hourlyWeather
.
date
)
}
}
}
}
...
...
1Weather/ViewModels/TodayViewModel.swift
View file @
e69ff80b
...
@@ -55,8 +55,9 @@ class TodayViewModel {
...
@@ -55,8 +55,9 @@ class TodayViewModel {
moonState
:
.
normal
)
moonState
:
.
normal
)
var
daily
=
[
DailyWeather
]()
var
daily
=
[
DailyWeather
]()
var
dailyStartDate
=
Date
()
-
TimeInterval
(
3600
*
24
)
for
index
in
0
..<
7
{
for
index
in
0
..<
7
{
let
day
=
DailyWeather
(
date
:
Date
()
,
let
day
=
DailyWeather
(
date
:
dailyStartDate
,
timeZone
:
.
current
,
timeZone
:
.
current
,
weekDay
:
weekDay
(
byIndex
:
index
),
weekDay
:
weekDay
(
byIndex
:
index
),
type
:
WeatherType
.
allCases
.
randomElement
()
??
.
unknown
,
type
:
WeatherType
.
allCases
.
randomElement
()
??
.
unknown
,
...
@@ -65,17 +66,18 @@ class TodayViewModel {
...
@@ -65,17 +66,18 @@ class TodayViewModel {
windSpeed
:
.
init
(
value
:
Double
.
random
(
in
:
0
..<
10
),
unit
:
.
milesPerHour
),
windSpeed
:
.
init
(
value
:
Double
.
random
(
in
:
0
..<
10
),
unit
:
.
milesPerHour
),
windDirection
:
WindDirection
.
allCases
.
randomElement
()
??
.
east
,
windDirection
:
WindDirection
.
allCases
.
randomElement
()
??
.
east
,
precipitationProbability
:
.
some
(
UInt
.
random
(
in
:
0
..<
100
)),
precipitationProbability
:
.
some
(
UInt
.
random
(
in
:
0
..<
100
)),
sunrise
:
.
init
(
hours
:
5
,
minutes
:
23
)
,
sunrise
:
nil
,
sunset
:
.
init
(
hours
:
17
,
minutes
:
40
)
,
sunset
:
nil
,
sunState
:
.
normal
,
sunState
:
.
normal
,
moonrise
:
.
init
(
hours
:
22
,
minutes
:
15
)
,
moonrise
:
nil
,
moonset
:
.
init
(
hours
:
2
,
minutes
:
30
)
,
moonset
:
nil
,
moonState
:
.
normal
)
moonState
:
.
normal
)
dailyStartDate
=
dailyStartDate
+
TimeInterval
(
3600
*
24
)
daily
.
append
(
day
)
daily
.
append
(
day
)
}
}
var
hourly
=
[
HourlyWeather
]()
var
hourly
=
[
HourlyWeather
]()
var
startDate
=
Date
()
var
startDate
=
Date
()
-
TimeInterval
(
3600
)
for
_
in
0
..<
24
{
for
_
in
0
..<
24
{
let
hour
=
HourlyWeather
(
date
:
startDate
,
let
hour
=
HourlyWeather
(
date
:
startDate
,
timeZone
:
TimeZone
(
abbreviation
:
"EST"
)
??
.
current
,
timeZone
:
TimeZone
(
abbreviation
:
"EST"
)
??
.
current
,
...
...
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
e69ff80b
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<
k
e
y
>
Cirque.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
k
e
y
>
Cirque.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
6
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
Localize-Swift.xcscheme
<
/k
e
y
>
<
k
e
y
>
Localize-Swift.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
...
@@ -33,26 +33,26 @@
...
@@ -33,26 +33,26 @@
<
k
e
y
>
Localize-Swift.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
k
e
y
>
Localize-Swift.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
5
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
Pods-1Weather.xcscheme
<
/k
e
y
>
<
k
e
y
>
Pods-1Weather.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
1
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
SnapKit.xcscheme
<
/k
e
y
>
<
k
e
y
>
SnapKit.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
k
e
y
>
isShown
<
/k
e
y
>
<
fa
ls
e
/
>
<
fa
ls
e
/
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
2
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
XMLCoder.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
k
e
y
>
XMLCoder.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
6
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
4
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
k
e
y
>
SuppressBuildableAutocreation
<
/k
e
y
>
<
k
e
y
>
SuppressBuildableAutocreation
<
/k
e
y
>
...
...
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