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
4b7269bf
Commit
4b7269bf
authored
Feb 21, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished sun animation
parent
fb34be35
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
17 deletions
+37
-17
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
1Weather/UI/View controllers/Today/Cells/CitySunCell.swift
+22
-15
1Weather/UI/View controllers/Today/TodayViewController.swift
+8
-0
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+7
-2
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
View file @
4b7269bf
No preview for this file type
1Weather/UI/View controllers/Today/Cells/CitySunCell.swift
View file @
4b7269bf
...
@@ -48,7 +48,6 @@ class CitySunCell: UITableViewCell {
...
@@ -48,7 +48,6 @@ class CitySunCell: UITableViewCell {
private
let
maxUvLabel
=
UILabel
()
private
let
maxUvLabel
=
UILabel
()
//Computed
//Computed
private
var
dashLinePath
=
UIBezierPath
()
private
var
earthCircleSegment
:
CircleSegment
{
private
var
earthCircleSegment
:
CircleSegment
{
return
.
init
(
chord
:
earthImageView
.
frame
.
width
,
return
.
init
(
chord
:
earthImageView
.
frame
.
width
,
height
:
earthImageView
.
frame
.
height
)
height
:
earthImageView
.
frame
.
height
)
...
@@ -74,7 +73,6 @@ class CitySunCell: UITableViewCell {
...
@@ -74,7 +73,6 @@ class CitySunCell: UITableViewCell {
super
.
layoutSubviews
()
super
.
layoutSubviews
()
drawDashLine
()
drawDashLine
()
updateSunPosition
()
}
}
required
init
?(
coder
:
NSCoder
)
{
required
init
?(
coder
:
NSCoder
)
{
...
@@ -82,35 +80,44 @@ class CitySunCell: UITableViewCell {
...
@@ -82,35 +80,44 @@ class CitySunCell: UITableViewCell {
}
}
private
func
drawDashLine
()
{
private
func
drawDashLine
()
{
infographicDashLine
.
path
=
dashLinePath
(
progress
:
1.0
)
.
cgPath
}
private
func
dashLinePath
(
progress
:
CGFloat
)
->
UIBezierPath
{
var
pathProgress
=
max
(
0
,
progress
)
pathProgress
=
min
(
1
,
pathProgress
)
let
segment
=
dashCircleSegment
let
segment
=
dashCircleSegment
let
start
=
-
(
.
pi
-
segment
.
alpha
)
let
start
=
-
(
.
pi
-
segment
.
alpha
)
let
end
=
-
segment
.
alpha
let
end
=
-
segment
.
alpha
let
percent
=
(
start
-
end
)
*
0.4
let
percent
=
(
start
-
end
)
*
pathProgress
dashLinePath
=
UIBezierPath
(
arcCenter
:
.
init
(
x
:
infographicContainer
.
frame
.
width
/
2
,
let
path
=
UIBezierPath
(
arcCenter
:
.
init
(
x
:
earthImageView
.
center
.
x
,
y
:
earthImageView
.
frame
.
origin
.
y
+
segment
.
radius
-
kDashLineTopInset
),
y
:
earthImageView
.
frame
.
origin
.
y
+
segment
.
radius
-
kDashLineTopInset
),
radius
:
segment
.
radius
,
radius
:
segment
.
radius
,
startAngle
:
start
,
startAngle
:
start
,
endAngle
:
start
-
percent
,
endAngle
:
start
-
percent
,
clockwise
:
true
)
clockwise
:
true
)
infographicDashLine
.
path
=
dashLinePath
.
cgP
ath
return
p
ath
}
}
@objc
private
func
handleArrowButton
()
{
}
//Public
public
func
updateSunPosition
()
{
public
func
updateSunPosition
()
{
sunImageView
.
layer
.
removeA
llAnimations
(
)
sunImageView
.
layer
.
removeA
nimation
(
forKey
:
"sun.position"
)
sunImageView
.
frame
.
origin
=
.
init
(
x
:
20
-
sunImageView
.
frame
.
width
/
2
,
sunImageView
.
frame
.
origin
=
.
init
(
x
:
20
-
sunImageView
.
frame
.
width
/
2
,
y
:
infographicContainer
.
frame
.
height
-
sunImageView
.
frame
.
height
/
2
)
y
:
infographicContainer
.
frame
.
height
-
sunImageView
.
frame
.
height
/
2
)
let
animation
=
CAKeyframeAnimation
(
keyPath
:
"position"
)
let
animation
=
CAKeyframeAnimation
(
keyPath
:
"position"
)
animation
.
path
=
self
.
dashLinePath
.
cgPath
animation
.
path
=
self
.
dashLinePath
(
progress
:
0.7
)
.
cgPath
animation
.
calculationMode
=
.
paced
animation
.
calculationMode
=
.
paced
animation
.
duration
=
2
animation
.
duration
=
1.3
animation
.
rotationMode
=
.
rotateAuto
animation
.
rotationMode
=
.
rotateAuto
animation
.
isRemovedOnCompletion
=
true
animation
.
isRemovedOnCompletion
=
false
sunImageView
.
layer
.
add
(
animation
,
forKey
:
nil
)
animation
.
fillMode
=
.
forwards
}
sunImageView
.
layer
.
add
(
animation
,
forKey
:
"sun.position"
)
@objc
private
func
handleArrowButton
()
{
}
}
}
}
...
@@ -176,7 +183,7 @@ private extension CitySunCell {
...
@@ -176,7 +183,7 @@ private extension CitySunCell {
infographicContainer
.
addSubview
(
earthImageView
)
infographicContainer
.
addSubview
(
earthImageView
)
earthImageView
.
snp
.
makeConstraints
{
(
make
)
in
earthImageView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
right
.
equalToSuperview
()
.
inset
(
37
)
make
.
centerX
.
equalToSuperview
(
)
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
}
}
...
...
1Weather/UI/View controllers/Today/TodayViewController.swift
View file @
4b7269bf
...
@@ -34,6 +34,14 @@ class TodayViewController: UIViewController {
...
@@ -34,6 +34,14 @@ class TodayViewController: UIViewController {
prepareTableView
()
prepareTableView
()
}
}
override
func
viewWillTransition
(
to
size
:
CGSize
,
with
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransition
(
to
:
size
,
with
:
coordinator
)
coordinator
.
animate
{
_
in
self
.
tableView
.
reloadData
()
}
}
@objc
private
func
handleCityButton
()
{
@objc
private
func
handleCityButton
()
{
print
(
"Handle city button"
)
print
(
"Handle city button"
)
}
}
...
...
Pods/Pods.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
4b7269bf
...
@@ -18,19 +18,24 @@
...
@@ -18,19 +18,24 @@
<
k
e
y
>
orderHint
<
/k
e
y
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
1
<
/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
>
Localize-Swift.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
3
<
/int
e
g
e
r
>
<
/
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
>
3
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
2
<
/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