Skip to content

Commit

Permalink
adapt for dark and light backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
felixgabler committed May 5, 2021
1 parent 98a56d0 commit 55c7716
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
88 changes: 45 additions & 43 deletions lib/resources/screens.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
ios:
# 4.0inch:
# devices:
# - iPhone 5
# - iPhone 5c
# - iPhone 5S
# - iPhone SE
# - iPhone iPod Touch (5th generation)
# - iPhone iPod Touch (6th generation)
# - iPhone iPod Touch (7th generation)
# 4.7inch:
# devices:
# - iPhone 6
# - iPhone 6S
# - iPhone 7
# - iPhone 8
# 4.0inch:
# devices:
# - iPhone 5
# - iPhone 5c
# - iPhone 5S
# - iPhone SE
# - iPhone iPod Touch (5th generation)
# - iPhone iPod Touch (6th generation)
# - iPhone iPod Touch (7th generation)
# 4.7inch:
# devices:
# - iPhone 6
# - iPhone 6S
# - iPhone 7
# - iPhone 8
5.5inch:
size: 1242x2208
resize: 75%
Expand Down Expand Up @@ -42,9 +42,9 @@ ios:
- iPhone X
- iPhone XS
- iPhone Xs
# 6.1inch:
# devices:
# - iPhone XR
# 6.1inch:
# devices:
# - iPhone XR
6.5inch:
size: 1242x2688
resize: 87%
Expand All @@ -62,27 +62,27 @@ ios:
- iPhone Xs Max
- iPhone 11 Pro Max
- iPhone 12 Pro Max
# 7.9inches:
# devices:
# - iPad Mini
# - iPad Mini 2
# - iPad Mini 3
# - iPad Mini 4
# - iPad Mini 5
# 9.7inch:
# devices:
# - iPad (1st generation)
# - iPad 2
# - iPad (3rd generation)
# - iPad (4th generation)
# - iPad (5th generation)
# - iPad (6th generation)
# - iPad Air
# - iPad Air 2
# - iPad Pro
# 10.5inch:
# devices:
# - iPad Pro (10.5-inch) (1st generation)
# 7.9inches:
# devices:
# - iPad Mini
# - iPad Mini 2
# - iPad Mini 3
# - iPad Mini 4
# - iPad Mini 5
# 9.7inch:
# devices:
# - iPad (1st generation)
# - iPad 2
# - iPad (3rd generation)
# - iPad (4th generation)
# - iPad (5th generation)
# - iPad (6th generation)
# - iPad Air
# - iPad Air 2
# - iPad Pro
# 10.5inch:
# devices:
# - iPad Pro (10.5-inch) (1st generation)
12.9inch:
size: 2048x2732
resize: 86%
Expand Down Expand Up @@ -121,8 +121,8 @@ android:
destName: phone
devices:
- Nexus 5X
# destName: sevenInch
# destName: tenInch
# destName: sevenInch
# destName: tenInch
5.7inch:
size: 1440x2560
resize: 80%
Expand All @@ -138,7 +138,8 @@ android:
- Nexus 6P
6.2inch:
size: 1440x3200
background: '#202020'
background light: '#e4e4e4'
background dark: '#202020'
resize: 80%
resources:
statusbar: resources/android/1440/samsung_statusbar_white.png
Expand All @@ -155,7 +156,8 @@ android:
- Samsung Galaxy S20
8.9inch:
size: 1536x2048
background: '#202020'
background light: '#e4e4e4'
background dark: '#202020'
resize: 80%
resources:
statusbar: resources/android/1536/statusbar.png
Expand Down
8 changes: 5 additions & 3 deletions lib/src/image_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,14 @@ class ImageProcessor {
Map screen,
String screenshotPath,
) {
final statusBarOffset = screen['background'];
if (statusBarOffset != null) {
final background = im.isThresholdExceeded(screenshotPath, _kCrop)
? screen['background dark']
: screen['background light'];
if (background != null) {
im.resizeWithCanvas(
firstImagePath: screenshotPath,
size: screen['size'],
backgroundColor: screen['background'],
backgroundColor: background,
padding: screen['statusbar offset'],
destinationPath: screenshotPath,
);
Expand Down

0 comments on commit 55c7716

Please sign in to comment.