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
05c77760
Commit
05c77760
authored
Jun 10, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished shorts UI on TodayViewController
parent
977103af
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
26 deletions
+57
-26
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
+1
-1
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+0
-18
1Weather/AppDelegate.swift
+4
-0
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
+4
-0
1Weather/UI/View controllers/Today/Shorts/ShortsCollectionViewCell.swift
+26
-6
1Weather/UI/View controllers/Today/Shorts/ShortsView.swift
+21
-1
1Weather/ViewModels/TodayViewModel.swift
+1
-0
No files found.
1Weather.xcodeproj/xcuserdata/dstepanets.xcuserdatad/xcschemes/xcschememanagement.plist
View file @
05c77760
...
...
@@ -12,7 +12,7 @@
<
k
e
y
>
OneWeatherNotificationServiceExtension.xcscheme_
^#
shared
#^
_
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
orderHint
<
/k
e
y
>
<
int
e
g
e
r
>
6
7
<
/int
e
g
e
r
>
<
int
e
g
e
r
>
6
1
<
/int
e
g
e
r
>
<
/
d
i
c
t
>
<
k
e
y
>
PG
(
Playground
)
1.xcscheme
<
/k
e
y
>
<
d
i
c
t
>
...
...
1Weather.xcworkspace/xcuserdata/dstepanets.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
05c77760
...
...
@@ -3,22 +3,4 @@
uuid =
"55281C35-FE9F-4CED-865E-FBED0E7393F6"
type =
"0"
version =
"2.0"
>
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID =
"Xcode.Breakpoint.FileBreakpoint"
>
<BreakpointContent
uuid =
"0549A927-B58A-4D08-9945-911E661668C3"
shouldBeEnabled =
"Yes"
ignoreCount =
"0"
continueAfterRunningActions =
"No"
filePath =
"1Weather/UI/View controllers/Today/Shorts/ShortsCollectionViewCell.swift"
startingColumnNumber =
"9223372036854775807"
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"34"
endingLineNumber =
"34"
landmarkName =
"configure(shorts:)"
landmarkType =
"7"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
1Weather/AppDelegate.swift
View file @
05c77760
...
...
@@ -16,6 +16,7 @@ import DTBiOSSDK
import
OneWeatherCore
import
AppsFlyerLib
import
OneWeatherAnalytics
import
NukeWebPPlugin
#warning("Fix ASAP")
import
WDTWeatherSource
...
...
@@ -48,6 +49,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
log
.
debug
(
"Launch options: -"
)
}
//Nuke WebP plugin
WebPImageDecoder
.
enable
()
//LocationManager
#warning("Fix ASAP")
LocationManager
.
shared
=
LocationManager
(
weatherUpdateSource
:
WdtWeatherSource
(),
...
...
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
View file @
05c77760
...
...
@@ -217,6 +217,10 @@ class TodayCellFactory: CellFactoryProtocol {
rowsToHide
.
insert
(
.
moon
)
}
if
location
?
.
countryCode
!=
"US"
||
todayViewModel
.
shorts
.
isEmpty
{
rowsToHide
.
insert
(
.
shorts
)
}
todaySection
.
hiddenRows
=
rowsToHide
}
}
1Weather/UI/View controllers/Today/Shorts/ShortsCollectionViewCell.swift
View file @
05c77760
...
...
@@ -9,12 +9,19 @@ import UIKit
import
Nuke
import
OneWeatherCore
protocol
ShortsCollectionCellDelegate
:
AnyObject
{
func
averageColor
(
forImage
image
:
UIImage
,
identifier
:
String
)
->
UIColor
?
}
class
ShortsCollectionViewCell
:
UICollectionViewCell
{
//Private
private
let
imageView
=
UIImageView
()
private
let
footerView
=
UIView
()
private
let
footerLabel
=
UILabel
()
//Public
weak
var
delegate
:
ShortsCollectionCellDelegate
?
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
...
...
@@ -23,20 +30,26 @@ class ShortsCollectionViewCell: UICollectionViewCell {
prepareFooter
()
}
func
configure
(
shorts
:
ShortsItem
)
{
footerLabel
.
text
=
shorts
.
title
if
let
image
=
self
.
bestImageForCellSize
(
images
:
shorts
.
images
)
{
func
configure
(
shorts
Item
:
ShortsItem
)
{
footerLabel
.
text
=
shorts
Item
.
title
if
let
image
=
self
.
bestImageForCellSize
(
images
:
shorts
Item
.
images
)
{
let
resizeOptions
=
ImageProcessors
.
Resize
(
size
:
self
.
bounds
.
size
,
crop
:
true
)
let
cornerRadius
=
ImageProcessors
.
RoundedCorners
(
radius
:
12
)
let
imageRequest
=
ImageRequest
(
url
:
image
.
url
,
processors
:
[
resizeOptions
,
cornerRadius
])
Nuke
.
loadImage
(
with
:
imageRequest
,
into
:
imageView
)
{[
weak
self
]
result
in
print
(
"break"
)
switch
result
{
case
.
success
(
let
imageResponse
):
onMain
{
self
?
.
imageView
.
image
=
imageResponse
.
image
self
?
.
footerView
.
backgroundColor
=
imageResponse
.
image
.
averageColor
if
let
cachedColor
=
self
?
.
delegate
?
.
averageColor
(
forImage
:
imageResponse
.
image
,
identifier
:
image
.
url
.
absoluteString
)
{
self
?
.
footerView
.
backgroundColor
=
cachedColor
}
else
{
self
?
.
footerView
.
backgroundColor
=
ThemeManager
.
currentTheme
.
containerBackgroundColor
}
}
default
:
break
...
...
@@ -53,6 +66,11 @@ class ShortsCollectionViewCell: UICollectionViewCell {
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
prepareForReuse
()
{
super
.
prepareForReuse
()
self
.
footerView
.
backgroundColor
=
.
clear
}
private
func
bestImageForCellSize
(
images
:[
ShortsItemImage
])
->
ShortsItemImage
?
{
guard
!
images
.
isEmpty
&&
self
.
frame
!=
.
zero
else
{
return
nil
...
...
@@ -73,7 +91,9 @@ class ShortsCollectionViewCell: UICollectionViewCell {
//MARK:- Prepare
private
extension
ShortsCollectionViewCell
{
func
prepare
()
{
contentView
.
backgroundColor
=
.
clear
contentView
.
clipsToBounds
=
true
contentView
.
layer
.
cornerRadius
=
12
contentView
.
backgroundColor
=
ThemeManager
.
currentTheme
.
containerBackgroundColor
}
func
prepareImage
()
{
...
...
1Weather/UI/View controllers/Today/Shorts/ShortsView.swift
View file @
05c77760
...
...
@@ -13,6 +13,7 @@ class ShortsView: UIView {
private
let
headingLabel
=
UILabel
()
private
let
collectionView
=
UICollectionView
(
frame
:
.
zero
,
collectionViewLayout
:
ShortsCollectionViewLayout
())
private
var
shorts
=
[
ShortsItem
]()
private
var
averageColorCache
=
[
AnyHashable
:
UIColor
]()
init
()
{
super
.
init
(
frame
:
.
zero
)
...
...
@@ -58,7 +59,26 @@ extension ShortsView: UICollectionViewDataSource {
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
ShortsCollectionViewCell
.
kIdentifier
,
for
:
indexPath
)
as!
ShortsCollectionViewCell
cell
.
configure
(
shorts
:
shorts
[
indexPath
.
row
])
cell
.
delegate
=
self
cell
.
configure
(
shortsItem
:
shorts
[
indexPath
.
row
])
return
cell
}
}
//MARK:- ShortsCollectionCell Delegate
extension
ShortsView
:
ShortsCollectionCellDelegate
{
func
averageColor
(
forImage
image
:
UIImage
,
identifier
:
String
)
->
UIColor
?
{
if
let
cachedColor
=
self
.
averageColorCache
[
identifier
]
{
return
cachedColor
}
else
{
if
let
color
=
image
.
averageColor
{
self
.
averageColorCache
[
identifier
]
=
color
return
color
}
else
{
return
nil
}
}
}
}
1Weather/ViewModels/TodayViewModel.swift
View file @
05c77760
...
...
@@ -62,6 +62,7 @@ class TodayViewModel: ViewModelProtocol {
self
.
shorts
.
removeAll
()
self
.
shorts
=
fetchedShorts
onMain
{
self
.
todayCellFactory
.
setNeedsUpdate
()
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
case
.
failure
(
let
error
):
...
...
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