Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the background colour as an xcasset color set #896

Merged
merged 2 commits into from
Jun 11, 2020

Conversation

dpogue
Copy link
Member

@dpogue dpogue commented Jun 10, 2020

Platforms affected

iOS

Motivation and Context

Resolves #890 where the splashscreen UIView defaults to a transparent background if no BackgroundColor preference is specified in config.xml.

Description

Add a named color set to Images.xcassets named BackgroundColor which defaults to the system background colour (respecting dark mode). On prepare, it will be set to the value specified in config.xml. Set the LaunchScreen Storyboard to use that as the background colour, and also ensure the WebView and SplashScreen UIView also use it as the background colour.

This also hypothetically opens the door for people to (via <resource-file> tags) provide their own color set content with different values for different devices or different light/dark modes. Caveat that this is not in the realm of supported Cordova behaviour, and we do not make any guarantees about this working.

If you're embedding the Cordova ViewController in another app or otherwise don't have a BackgroundColor color set in xcassets, it will fallback to white.

Testing

  • Manual testing against a simulator.
  • Added spec tests for the BackgroundColor preference parsing in prepare.spec.js

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)

@dpogue dpogue requested a review from erisu June 10, 2020 06:27
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit Test Error

Failures:
1) prepare after plugin add Test 001 : should not overwrite plugin metadata added by "addPlugin"
  Message:
    Error: ENOENT: no such file or directory, open '/tmp/cordova-ios/tests/spec/unit/fixtures/dummyProj/platforms/ios/SampleApp/Images.xcassets/BackgroundColor.colorset/Contents.json'
  Stack:
    error properties: Object({ errno: -2, syscall: 'open', code: 'ENOENT', path: '/tmp/cordova-ios/tests/spec/unit/fixtures/dummyProj/platforms/ios/SampleApp/Images.xcassets/BackgroundColor.colorset/Contents.json' })
    Error: ENOENT: no such file or directory, open '/tmp/cordova-ios/tests/spec/unit/fixtures/dummyProj/platforms/ios/SampleApp/Images.xcassets/BackgroundColor.colorset/Contents.json'
        at Object.openSync (fs.js:461:3)
        at Object.writeFileSync (fs.js:1387:35)
        at updateBackgroundColor (/tmp/cordova-ios/bin/templates/scripts/cordova/lib/prepare.js:88:838)
        at /tmp/cordova-ios/bin/templates/scripts/cordova/lib/prepare.js:22:326

Manual Testing

  • navigator.splashscreen.show() has an unexpected behaviour.

It will fade into what I presume to be the SplashScreen but it only shows a white screen.

  • navigator.splashscreen.hide() works as expected.

Fades back into the application.

Trying to take a snapshot of the view doesn't seem to result in the
image actually being present in the snapshot, but we can just render the
view itself from the storyboard file.

However, we do need to make sure that we don't allow the view to grow in
size, otherwise it will expand to the size of the image instead of
remaining the size of the screen bounds.
@codecov-commenter
Copy link

Codecov Report

Merging #896 into master will increase coverage by 0.08%.
The diff coverage is 78.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #896      +/-   ##
==========================================
+ Coverage   74.40%   74.48%   +0.08%     
==========================================
  Files          13       13              
  Lines        1676     1713      +37     
==========================================
+ Hits         1247     1276      +29     
- Misses        429      437       +8     
Impacted Files Coverage Δ
bin/templates/scripts/cordova/lib/prepare.js 84.78% <78.37%> (-0.63%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 062b91d...9b3e078. Read the comment docs.

@dpogue
Copy link
Member Author

dpogue commented Jun 11, 2020

@erisu Thanks for catching that. I've fixed the missing test fixture, and also added a second commit to address the SplashScreen being blank. It should work as intended now 😁

@dpogue dpogue added this to the 6.0.1 milestone Jun 11, 2020
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed & now it LGTM 👍

  • ran npm t
  • ran cordova platform add
  • ran cordova build
  • ran simulator
  • tested navigator.splashscreen.show()
  • tested navigator.splashscreen.hide()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with splashscreen and cordova-ios 6.0.0
3 participants