Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx messenger iOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
xx messenger iOS
Commits
63e84eb2
Commit
63e84eb2
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add MakeAppScreenshot functor
parent
db5438d6
No related branches found
No related tags found
3 merge requests
!71
Releasing v1.1.5 (214)
,
!69
Implemented filtering for banned/blocked users and reporting
,
!67
v1.1.5 b(203)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Package.swift
+3
-1
3 additions, 1 deletion
Package.swift
Sources/ReportingFeature/MakeAppScreenshot.swift
+53
-0
53 additions, 0 deletions
Sources/ReportingFeature/MakeAppScreenshot.swift
with
56 additions
and
1 deletion
Package.swift
+
3
−
1
View file @
63e84eb2
...
@@ -746,7 +746,9 @@ let package = Package(
...
@@ -746,7 +746,9 @@ let package = Package(
),
),
.
target
(
.
target
(
name
:
"ReportingFeature"
,
name
:
"ReportingFeature"
,
dependencies
:
[]
dependencies
:
[
.
product
(
name
:
"XCTestDynamicOverlay"
,
package
:
"xctest-dynamic-overlay"
),
]
),
),
]
]
)
)
This diff is collapsed.
Click to expand it.
Sources/ReportingFeature/MakeAppScreenshot.swift
0 → 100644
+
53
−
0
View file @
63e84eb2
import
Foundation
import
UIKit
import
XCTestDynamicOverlay
public
struct
MakeAppScreenshot
{
public
enum
Error
:
Swift
.
Error
,
Equatable
{
case
unableToGetForegroundWindowScene
case
unableToGetKeyWindow
}
public
var
run
:
()
throws
->
UIImage
public
func
callAsFunction
()
throws
->
UIImage
{
try
run
()
}
}
extension
MakeAppScreenshot
{
public
static
let
live
=
MakeAppScreenshot
{
let
scene
:
UIWindowScene
?
=
UIApplication
.
shared
.
connectedScenes
.
filter
{
$0
.
activationState
==
.
foregroundActive
}
.
compactMap
{
$0
as?
UIWindowScene
}
.
first
guard
let
scene
=
scene
else
{
throw
Error
.
unableToGetForegroundWindowScene
}
let
window
:
UIWindow
?
=
scene
.
windows
.
first
(
where
:
\
.
isKeyWindow
)
guard
let
keyWindow
=
window
else
{
throw
Error
.
unableToGetKeyWindow
}
let
rendererFormat
=
UIGraphicsImageRendererFormat
()
rendererFormat
.
scale
=
scene
.
screen
.
scale
let
renderer
=
UIGraphicsImageRenderer
(
bounds
:
keyWindow
.
bounds
,
format
:
rendererFormat
)
return
renderer
.
image
{
ctx
in
keyWindow
.
layer
.
render
(
in
:
ctx
.
cgContext
)
}
}
}
extension
MakeAppScreenshot
{
public
static
let
unimplemented
=
MakeAppScreenshot
(
run
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment