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
fc449841
Commit
fc449841
authored
May 06, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Settings / Theme Selection: images are tappable. An ability to disable automatic.
parent
339c720e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
1Weather/UI/View controllers/Settings/Cells/SettingsThemeCell.swift
+31
-3
No files found.
1Weather/UI/View controllers/Settings/Cells/SettingsThemeCell.swift
View file @
fc449841
...
...
@@ -68,16 +68,26 @@ class SettingsThemeCell: UITableViewCell {
@objc
private
func
handleThemeButton
(
button
:
UIButton
)
{
switch
button
{
case
lightThemeButton
:
Settings
.
shared
.
appTheme
=
.
light
selectLightTheme
()
case
darkThemeButton
:
Settings
.
shared
.
appTheme
=
.
dark
selectDarkTheme
()
default
:
break
}
}
@objc
private
func
handleAutomaticSwith
()
{
Settings
.
shared
.
appTheme
=
.
system
if
automaticSwitchButton
.
isOn
{
Settings
.
shared
.
appTheme
=
.
system
}
else
{
switch
interfaceStyle
{
case
.
light
:
Settings
.
shared
.
appTheme
=
.
light
case
.
dark
:
Settings
.
shared
.
appTheme
=
.
dark
}
}
}
//Public
...
...
@@ -104,13 +114,27 @@ private extension SettingsThemeCell {
}
}
@objc
private
func
selectLightTheme
()
{
Settings
.
shared
.
appTheme
=
.
light
}
@objc
private
func
selectDarkTheme
()
{
Settings
.
shared
.
appTheme
=
.
dark
}
func
prepareLightTheme
()
{
lightThemeImageView
.
clipsToBounds
=
true
lightThemeImageView
.
layer
.
cornerRadius
=
10
lightThemeImageView
.
contentMode
=
.
scaleAspectFill
lightThemeImageView
.
image
=
UIImage
(
named
:
"theme_sample_light"
)
lightThemeImageView
.
isUserInteractionEnabled
=
true
container
.
addSubview
(
lightThemeImageView
)
let
gesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
selectLightTheme
)
)
lightThemeImageView
.
addGestureRecognizer
(
gesture
)
lightThemeLabel
.
textAlignment
=
.
center
lightThemeLabel
.
setContentHuggingPriority
(
.
fittingSizeLevel
,
for
:
.
vertical
)
lightThemeLabel
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
16
)
...
...
@@ -145,8 +169,12 @@ private extension SettingsThemeCell {
darkThemeImageView
.
clipsToBounds
=
true
darkThemeImageView
.
contentMode
=
.
scaleAspectFill
darkThemeImageView
.
image
=
UIImage
(
named
:
"theme_sample_dark"
)
darkThemeImageView
.
isUserInteractionEnabled
=
true
container
.
addSubview
(
darkThemeImageView
)
let
gesture
=
UITapGestureRecognizer
(
target
:
self
,
action
:
#selector(
selectDarkTheme
)
)
darkThemeImageView
.
addGestureRecognizer
(
gesture
)
darkThemeLabel
.
textAlignment
=
.
center
darkThemeLabel
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
16
)
darkThemeLabel
.
text
=
"settings.theme.dark"
.
localized
()
...
...
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