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
962b7123
Commit
962b7123
authored
Feb 11, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gradient changes
parent
8ce654f0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
6 deletions
+84
-6
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
1Weather/Extensions/UIColor+Highlight.swift
+34
-0
1Weather/Resources/PrimaryColorsAsset.xcassets/primary_button_bg.colorset/Contents.json
+38
-0
1Weather/UI/Buttons/NeoButton.swift
+6
-5
1Weather/UI/Helpers/Themes/DefaultTheme.swift
+4
-0
1Weather/UI/Helpers/Themes/ThemeProtocol.swift
+1
-0
1Weather/UI/View controllers/Today/TodayViewController.swift
+1
-1
No files found.
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/UserInterfaceState.xcuserstate
View file @
962b7123
No preview for this file type
1Weather/Extensions/UIColor+Highlight.swift
View file @
962b7123
...
@@ -20,6 +20,40 @@ extension UIColor {
...
@@ -20,6 +20,40 @@ extension UIColor {
return
self
.
isDarkColor
?
self
.
adjust
(
by
:
30
)
:
self
.
adjust
(
by
:
-
30
)
return
self
.
isDarkColor
?
self
.
adjust
(
by
:
30
)
:
self
.
adjust
(
by
:
-
30
)
}
}
func
lighten
(
by
fraction
:
CGFloat
)
->
UIColor
{
var
red
:
CGFloat
=
0
var
green
:
CGFloat
=
0
var
blue
:
CGFloat
=
0
var
alpha
:
CGFloat
=
0
getRed
(
&
red
,
green
:
&
green
,
blue
:
&
blue
,
alpha
:
&
alpha
)
red
=
lightenColor
(
color
:
red
,
fraction
:
fraction
)
green
=
lightenColor
(
color
:
green
,
fraction
:
fraction
)
blue
=
lightenColor
(
color
:
blue
,
fraction
:
fraction
)
return
UIColor
(
red
:
red
,
green
:
green
,
blue
:
blue
,
alpha
:
alpha
)
}
func
darken
(
by
fraction
:
CGFloat
)
->
UIColor
{
var
red
:
CGFloat
=
0
var
green
:
CGFloat
=
0
var
blue
:
CGFloat
=
0
var
alpha
:
CGFloat
=
0
getRed
(
&
red
,
green
:
&
green
,
blue
:
&
blue
,
alpha
:
&
alpha
)
red
=
darkenColor
(
color
:
red
,
fraction
:
fraction
)
green
=
darkenColor
(
color
:
green
,
fraction
:
fraction
)
blue
=
darkenColor
(
color
:
blue
,
fraction
:
fraction
)
return
UIColor
(
red
:
red
,
green
:
green
,
blue
:
blue
,
alpha
:
alpha
)
}
private
func
lightenColor
(
color
:
CGFloat
,
fraction
:
CGFloat
)
->
CGFloat
{
return
min
(
color
+
(
1
-
color
)
*
fraction
,
1
)
}
private
func
darkenColor
(
color
:
CGFloat
,
fraction
:
CGFloat
)
->
CGFloat
{
return
max
(
color
-
color
*
fraction
,
0
)
}
private
func
adjust
(
by
percentage
:
CGFloat
=
30.0
)
->
UIColor
{
private
func
adjust
(
by
percentage
:
CGFloat
=
30.0
)
->
UIColor
{
var
r
:
CGFloat
=
0
,
g
:
CGFloat
=
0
,
b
:
CGFloat
=
0
,
a
:
CGFloat
=
0
;
var
r
:
CGFloat
=
0
,
g
:
CGFloat
=
0
,
b
:
CGFloat
=
0
,
a
:
CGFloat
=
0
;
if
(
self
.
getRed
(
&
r
,
green
:
&
g
,
blue
:
&
b
,
alpha
:
&
a
)){
if
(
self
.
getRed
(
&
r
,
green
:
&
g
,
blue
:
&
b
,
alpha
:
&
a
)){
...
...
1Weather/Resources/PrimaryColorsAsset.xcassets/primary_button_bg.colorset/Contents.json
0 → 100644
View file @
962b7123
{
"colors"
:
[
{
"color"
:
{
"color-space"
:
"srgb"
,
"components"
:
{
"alpha"
:
"1.000"
,
"blue"
:
"0xFB"
,
"green"
:
"0xF5"
,
"red"
:
"0xF4"
}
},
"idiom"
:
"universal"
},
{
"appearances"
:
[
{
"appearance"
:
"luminosity"
,
"value"
:
"dark"
}
],
"color"
:
{
"color-space"
:
"srgb"
,
"components"
:
{
"alpha"
:
"1.000"
,
"blue"
:
"1.000"
,
"green"
:
"1.000"
,
"red"
:
"1.000"
}
},
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
1Weather/UI/Buttons/NeoButton.swift
View file @
962b7123
...
@@ -20,6 +20,7 @@ class NeoButton: UIButton {
...
@@ -20,6 +20,7 @@ class NeoButton: UIButton {
private
var
cornerRadiusObserver
:
NSKeyValueObservation
?
private
var
cornerRadiusObserver
:
NSKeyValueObservation
?
private
var
highlightedObserver
:
NSKeyValueObservation
?
private
var
highlightedObserver
:
NSKeyValueObservation
?
//MARK:- NewButton life cycle
init
()
{
init
()
{
super
.
init
(
frame
:
.
zero
)
super
.
init
(
frame
:
.
zero
)
...
@@ -106,10 +107,11 @@ private extension NeoButton {
...
@@ -106,10 +107,11 @@ private extension NeoButton {
}
}
private
func
prepareHighlightedGradient
()
{
private
func
prepareHighlightedGradient
()
{
self
.
highlightedGradientLayer
.
colors
=
[
self
.
backgroundColor
!.
cgColor
,
self
.
darkColor
.
cgColor
]
self
.
highlightedGradientLayer
.
colors
=
[
ThemeManager
.
currentTheme
.
primaryButtonColor
.
darken
(
by
:
0.1
)
.
cgColor
,
ThemeManager
.
currentTheme
.
primaryButtonColor
.
lighten
(
by
:
0.04
)
.
cgColor
]
self
.
highlightedGradientLayer
.
startPoint
=
.
zero
self
.
highlightedGradientLayer
.
startPoint
=
.
zero
self
.
highlightedGradientLayer
.
endPoint
=
.
init
(
x
:
0
,
y
:
1
)
self
.
highlightedGradientLayer
.
endPoint
=
.
init
(
x
:
0
,
y
:
1
.0
)
self
.
highlightedGradientLayer
.
isHidden
=
tru
e
self
.
highlightedGradientLayer
.
isHidden
=
fals
e
backgroundLayer
.
addSublayer
(
self
.
highlightedGradientLayer
)
backgroundLayer
.
addSublayer
(
self
.
highlightedGradientLayer
)
}
}
...
@@ -117,7 +119,7 @@ private extension NeoButton {
...
@@ -117,7 +119,7 @@ private extension NeoButton {
private
func
prepareBorderLayer
()
{
private
func
prepareBorderLayer
()
{
borderGradient
.
colors
=
[
UIColor
.
white
.
cgColor
,
UIColor
.
white
.
withAlphaComponent
(
0.15
)
.
cgColor
]
borderGradient
.
colors
=
[
UIColor
.
white
.
cgColor
,
UIColor
.
white
.
withAlphaComponent
(
0.15
)
.
cgColor
]
borderLayer
.
lineWidth
=
1
/
UIScreen
.
main
.
scale
borderLayer
.
lineWidth
=
2
/
UIScreen
.
main
.
scale
borderLayer
.
strokeColor
=
UIColor
.
black
.
cgColor
borderLayer
.
strokeColor
=
UIColor
.
black
.
cgColor
borderLayer
.
fillColor
=
UIColor
.
clear
.
cgColor
borderLayer
.
fillColor
=
UIColor
.
clear
.
cgColor
borderGradient
.
mask
=
borderLayer
borderGradient
.
mask
=
borderLayer
...
@@ -131,7 +133,6 @@ private extension NeoButton {
...
@@ -131,7 +133,6 @@ private extension NeoButton {
self
.
borderGradient
.
cornerRadius
=
change
.
newValue
??
0
self
.
borderGradient
.
cornerRadius
=
change
.
newValue
??
0
})
})
highlightedObserver
=
observe
(
\
NeoButton
.
isHighlighted
,
options
:
.
new
,
changeHandler
:
{
(
button
,
change
)
in
highlightedObserver
=
observe
(
\
NeoButton
.
isHighlighted
,
options
:
.
new
,
changeHandler
:
{
(
button
,
change
)
in
print
(
"isHighlighted:
\(
change
.
newValue
)
"
)
guard
let
state
=
change
.
newValue
else
{
guard
let
state
=
change
.
newValue
else
{
return
return
}
}
...
...
1Weather/UI/Helpers/Themes/DefaultTheme.swift
View file @
962b7123
...
@@ -31,4 +31,8 @@ struct DefaultTheme: ThemeProtocol {
...
@@ -31,4 +31,8 @@ struct DefaultTheme: ThemeProtocol {
var
primaryTextColor
:
UIColor
{
var
primaryTextColor
:
UIColor
{
return
UIColor
(
named
:
"primary_font"
)
??
.
red
return
UIColor
(
named
:
"primary_font"
)
??
.
red
}
}
var
primaryButtonColor
:
UIColor
{
return
UIColor
(
named
:
"primary_button_bg"
)
??
.
red
}
}
}
1Weather/UI/Helpers/Themes/ThemeProtocol.swift
View file @
962b7123
...
@@ -14,4 +14,5 @@ protocol ThemeProtocol {
...
@@ -14,4 +14,5 @@ protocol ThemeProtocol {
var
tabBarTintColor
:
UIColor
{
get
}
var
tabBarTintColor
:
UIColor
{
get
}
var
tabBarBarTintColor
:
UIColor
{
get
}
var
tabBarBarTintColor
:
UIColor
{
get
}
var
primaryTextColor
:
UIColor
{
get
}
var
primaryTextColor
:
UIColor
{
get
}
var
primaryButtonColor
:
UIColor
{
get
}
}
}
1Weather/UI/View controllers/Today/TodayViewController.swift
View file @
962b7123
...
@@ -40,7 +40,7 @@ private extension TodayViewController {
...
@@ -40,7 +40,7 @@ private extension TodayViewController {
//Notification button
//Notification button
let
notificationButton
=
NeoButton
()
let
notificationButton
=
NeoButton
()
notificationButton
.
backgroundColor
=
UIColor
(
hex
:
0xf4f5fb
)
notificationButton
.
backgroundColor
=
ThemeManager
.
currentTheme
.
primaryButtonColor
notificationButton
.
setImage
(
UIImage
(
named
:
"bell"
),
for
:
.
normal
)
notificationButton
.
setImage
(
UIImage
(
named
:
"bell"
),
for
:
.
normal
)
notificationButton
.
tintColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
notificationButton
.
tintColor
=
ThemeManager
.
currentTheme
.
primaryTextColor
notificationButton
.
frame
=
.
init
(
origin
:
.
zero
,
size
:
CGSize
(
width
:
42
,
height
:
42
))
notificationButton
.
frame
=
.
init
(
origin
:
.
zero
,
size
:
CGSize
(
width
:
42
,
height
:
42
))
...
...
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