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
071c1424
Commit
071c1424
authored
Sep 28, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished GraphQL integration
parent
fa853f3c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
40 deletions
+9
-40
1Weather/UI/View controllers/Shorts/ShortsViewController.swift
+4
-4
InMobiGraphQLSource/InMobiGraphQLSource/InMobiGraphQLSource.swift
+1
-14
InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift
+1
-7
OneWeatherCore/OneWeatherCore/ModelObjects/Shorts/ShortsItem.swift
+3
-15
No files found.
1Weather/UI/View controllers/Shorts/ShortsViewController.swift
View file @
071c1424
...
...
@@ -398,16 +398,16 @@ extension ShortsViewController: ViewModelDelegate {
//MARK:- ShortsItemCell Delegate
extension
ShortsViewController
:
ShortsItemCellDelegate
{
private
func
bottomPart
(
of
sourceImage
:
UIImage
)
->
UIImage
?
{
let
dy
:
CGFloat
=
10
//10pt from bottom
let
dy
:
CGFloat
=
10
*
sourceImage
.
scale
//10pt from bottom
let
area
=
CGRect
(
x
:
0
,
y
:
sourceImage
.
size
.
height
-
dy
,
width
:
sourceImage
.
size
.
width
,
y
:
sourceImage
.
size
.
height
*
sourceImage
.
scale
-
dy
,
width
:
sourceImage
.
size
.
width
*
sourceImage
.
scale
,
height
:
dy
)
guard
let
crop
=
sourceImage
.
cgImage
?
.
cropping
(
to
:
area
)
else
{
return
nil
}
return
UIImage
(
cgImage
:
crop
,
scale
:
UIScreen
.
main
.
scale
,
orientation
:
.
up
)
return
UIImage
(
cgImage
:
crop
)
}
func
averageColor
(
for
short
:
ShortsItem
,
shortImage
:
UIImage
,
completion
:
@escaping
(
UIColor
?,
String
?)
->
Void
)
{
...
...
InMobiGraphQLSource/InMobiGraphQLSource/InMobiGraphQLSource.swift
View file @
071c1424
...
...
@@ -47,8 +47,6 @@ public class InMobiGraphQLSource: ShortSource {
{"
query
":"
query
{
weatherCardObjectCollection
(
where
:
{
AND
:
[
{
expiredAt_gte
:
\\
"
\(
dateString
)\\
"
}
],
})
{
items
{
shortsCategories
,
sourceUrl
,
buttonText
,
publishedAt
mediaArrayObjectCollection
{
items
{
...
on
WImageObject
{
title
,
summary
image
}
}
}
sys
{
id
}
}
}
}
"}
"""
do
{
// let jsonData = try JSONEncoder().encode(graphQLString)
guard
let
bodyData
=
graphQLString
.
data
(
using
:
.
utf8
)
else
{
completion
(
nil
,
InMobiGraphQLSourceError
.
dataEncodingError
(
"Invalid GraphQL body"
))
...
...
@@ -84,11 +82,6 @@ public class InMobiGraphQLSource: ShortSource {
}
dataTask
.
resume
()
}
catch
{
self
.
log
.
error
(
"Encoding error:
\(
error
)
"
)
completion
(
nil
,
InMobiGraphQLSourceError
.
dataEncodingError
(
error
.
localizedDescription
))
}
}
private
func
toAppModel
(
item
:
WeatherCardItem
)
->
ShortsItem
{
let
lowImageSize
=
CGSize
(
width
:
440
,
height
:
783
)
...
...
@@ -122,18 +115,12 @@ public class InMobiGraphQLSource: ShortSource {
return
ShortsItem
(
id
:
item
.
id
,
images
:
baseImages
,
overlayImages
:
overlayImages
,
updatedAtInSecs
:
0
,
startsAtInSecs
:
0
,
endsAtInSecs
:
0
,
shareURL
:
item
.
sourceUrl
,
title
:
item
.
mediaArrayObjectCollection
.
items
.
first
?
.
title
??
""
,
summaryText
:
item
.
mediaArrayObjectCollection
.
items
.
first
?
.
summary
??
""
,
sourceName
:
""
,
heartCount
:
0
,
shortURL
:
item
.
sourceUrl
,
ctaText
:
item
.
buttonText
,
ctaURL
:
item
.
sourceUrl
,
likeCount
:
0
,
shareCount
:
0
)
ctaURL
:
item
.
sourceUrl
)
}
}
InMobiShortsSource/InMobiShortsSource/InMobiShortSource.swift
View file @
071c1424
...
...
@@ -128,18 +128,12 @@ public class InMobiShortSource: ShortSource {
ShortsItem
(
id
:
glanceDetails
.
id
,
images
:
glanceDetails
.
image
.
supportedImages
.
map
{
.
init
(
width
:
$0
.
width
,
height
:
$0
.
height
,
url
:
$0
.
url
)
},
overlayImages
:
glanceDetails
.
overlayImage
.
supportedImages
.
map
{
.
init
(
width
:
$0
.
width
,
height
:
$0
.
height
,
url
:
$0
.
url
)
},
updatedAtInSecs
:
glanceDetails
.
updatedAtInSecs
,
startsAtInSecs
:
glanceDetails
.
startsAtInSecs
,
endsAtInSecs
:
glanceDetails
.
endsAtInSecs
,
shareURL
:
glanceDetails
.
encodedShareURL
,
title
:
glanceDetails
.
peekData
.
title
,
summaryText
:
glanceDetails
.
peek
.
articlePeek
.
summary
,
sourceName
:
glanceDetails
.
peekData
.
sourceName
,
heartCount
:
glanceDetails
.
peekData
.
heartCount
,
shortURL
:
glanceDetails
.
peekData
.
encodedShortURL
,
ctaText
:
glanceDetails
.
peekData
.
ctaText
,
ctaURL
:
glanceDetails
.
peek
.
articlePeek
.
cta
.
encodedUrl
,
likeCount
:
glanceDetails
.
glanceInteractionDetails
.
likeCount
,
shareCount
:
glanceDetails
.
glanceInteractionDetails
.
shareCount
)
ctaURL
:
glanceDetails
.
peek
.
articlePeek
.
cta
.
encodedUrl
)
}
}
OneWeatherCore/OneWeatherCore/ModelObjects/Shorts/ShortsItem.swift
View file @
071c1424
...
...
@@ -23,42 +23,30 @@ public struct ShortsItem {
public
let
id
:
String
public
let
images
:
[
ShortsItemImage
]
public
let
overlayImages
:
[
ShortsItemImage
]
public
let
updatedAtInSecs
:
TimeInterval
public
let
startsAtInSecs
:
TimeInterval
public
let
endsAtInSecs
:
TimeInterval
public
let
shareURL
:
URL
?
public
let
title
:
String
public
let
summaryText
:
String
public
let
sourceName
:
String
public
let
heartCount
:
Int
public
let
shortURL
:
URL
?
public
let
ctaText
:
String
public
let
ctaURL
:
URL
?
public
let
likeCount
:
Int
public
let
shareCount
:
Int
public
var
isLiked
:
Bool
=
false
public
var
viewDate
:
Date
?
public
init
(
id
:
String
,
images
:
[
ShortsItemImage
],
overlayImages
:
[
ShortsItemImage
],
updatedAtInSecs
:
TimeInterval
,
startsAtInSecs
:
TimeInterval
,
endsAtInSecs
:
TimeInterval
,
shareURL
:
URL
?,
title
:
String
,
summaryText
:
String
,
sourceName
:
String
,
heartCount
:
Int
,
shortURL
:
URL
?,
ctaText
:
String
,
ctaURL
:
URL
?,
likeCount
:
Int
,
shareCount
:
Int
)
{
public
init
(
id
:
String
,
images
:
[
ShortsItemImage
],
overlayImages
:
[
ShortsItemImage
],
shareURL
:
URL
?,
title
:
String
,
summaryText
:
String
,
sourceName
:
String
,
shortURL
:
URL
?,
ctaText
:
String
,
ctaURL
:
URL
?
)
{
self
.
id
=
id
self
.
images
=
images
self
.
overlayImages
=
overlayImages
self
.
updatedAtInSecs
=
updatedAtInSecs
self
.
startsAtInSecs
=
startsAtInSecs
self
.
endsAtInSecs
=
endsAtInSecs
self
.
shareURL
=
shareURL
self
.
title
=
title
self
.
summaryText
=
summaryText
self
.
sourceName
=
sourceName
self
.
heartCount
=
heartCount
self
.
shortURL
=
shortURL
self
.
ctaText
=
ctaText
self
.
ctaURL
=
ctaURL
self
.
likeCount
=
likeCount
self
.
shareCount
=
shareCount
}
public
func
getImage
(
for
width
:
CGFloat
)
->
ShortsItemImage
?
{
public
func
getImage
(
for
width
:
CGFloat
)
->
ShortsItemImage
?
{
guard
!
self
.
images
.
isEmpty
&&
width
>
0
else
{
return
nil
}
...
...
@@ -73,7 +61,7 @@ public struct ShortsItem {
return
image
}
public
func
getOverlayImage
(
for
width
:
CGFloat
)
->
ShortsItemImage
?
{
public
func
getOverlayImage
(
for
width
:
CGFloat
)
->
ShortsItemImage
?
{
guard
!
self
.
overlayImages
.
isEmpty
&&
width
>
0
else
{
return
nil
}
...
...
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