Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Improve dark mode support.
Browse files Browse the repository at this point in the history
  • Loading branch information
GoNative Release Bot committed Aug 1, 2022
1 parent 8f55c2a commit bd96d3c
Show file tree
Hide file tree
Showing 26 changed files with 542 additions and 113 deletions.
114 changes: 53 additions & 61 deletions GoNativeIOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions LeanIOS/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.431",
"green" : "0.286",
"red" : "0.118"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.914",
"green" : "0.808",
"red" : "0.686"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.431",
"green" : "0.286",
"red" : "0.118"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.914",
"green" : "0.808",
"red" : "0.686"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.000",
"blue" : "0.000",
"green" : "0.000",
"red" : "0.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
38 changes: 38 additions & 0 deletions LeanIOS/Assets.xcassets/tabBarTintColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.431",
"green" : "0.286",
"red" : "0.118"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.914",
"green" : "0.808",
"red" : "0.686"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
71 changes: 47 additions & 24 deletions LeanIOS/GoNativeJSBridgeLibrary.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
// this function returns a promise and also supports callback as params.callback
// this function accepts a callback function as params.callback that will be called with the command results
// if a callback is not provided it returns a promise that will resolve with the command results
function addCommandCallback(command, params, persistCallback) {
var tempFunctionName = '_gonative_temp_' + Math.random().toString(36).slice(2);
var callback;
if(params) callback = params.callback;
else {
params = {
'callback': tempFunctionName
};
}
return new Promise(function(resolve, reject) {
// declare a temporary function
window[tempFunctionName] = function(data) {
resolve(data);
if (typeof callback === 'function') {
callback(data);
} else if (typeof callback === 'string' &&
typeof window[callback] === 'function'){
window[callback](data);
}
if(!persistCallback){ // if callback is used just once
if(params && params.callback){
// execute command with provided callback function
addCommand(command, params, persistCallback);
} else {
// create a temporary function and return a promise that executes command
var tempFunctionName = '_gonative_temp_' + Math.random().toString(36).slice(2);
if(!params) params = {};
params.callback = tempFunctionName;
return new Promise(function(resolve, reject) {
// declare a temporary function
window[tempFunctionName] = function(data) {
resolve(data);
delete window[tempFunctionName];
}
}
// execute command
addCommand(command, params);
});
// execute command
addCommand(command, params);
});
}
}

function addCallbackFunction(callbackFunction, persistCallback){
Expand Down Expand Up @@ -167,6 +161,9 @@ gonative.navigationLevels = {
gonative.statusbar = {
set: function (params){
addCommand("gonative://statusbar/set", params);
},
matchBodyBackgroundColor: function (params){
addCommand("gonative://statusbar/matchBodyBackgroundColor", params);
}
};

Expand All @@ -177,6 +174,11 @@ gonative.screen = {
params = {brightness: data};
}
addCommand("gonative://screen/setBrightness", params);
},
setMode: function(params) {
if (params.mode) {
addCommand("gonative://screen/setMode", params);
}
}
};

Expand Down Expand Up @@ -314,3 +316,24 @@ gonative.android.audio = {
addCommand("gonative://audio/requestFocus", params);
}
};

//////////////////////////////////////
//// Webpage Helper Functions ////
//////////////////////////////////////

function gonative_match_statusbar_to_body_background_color() {
let rgb = window.getComputedStyle(document.body, null).getPropertyValue('background-color');
let sep = rgb.indexOf(",") > -1 ? "," : " ";
rgb = rgb.substring(rgb.indexOf('(')+1).split(")")[0].split(sep).map(function(x) { return x * 1; });
if(rgb.length === 4){
rgb = rgb.map(function(x){ return parseInt(x * rgb[3]); })
}
let hex = '#' + rgb[0].toString(16).padStart(2,'0') + rgb[1].toString(16).padStart(2,'0') + rgb[2].toString(16).padStart(2,'0');
let luma = 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]; // per ITU-R BT.709
if(luma > 40){
gonative.statusbar.set({'style': 'dark', 'color': hex});
}
else{
gonative.statusbar.set({'style': 'light', 'color': hex});
}
}
6 changes: 3 additions & 3 deletions LeanIOS/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
51 changes: 42 additions & 9 deletions LeanIOS/Images.xcassets/HeaderImage.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,56 @@
{
"images" : [
{
"filename" : "header.png",
"idiom" : "universal",
"scale" : "1x",
"filename" : "header.png"
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "headerDark.png",
"idiom" : "universal",
"scale" : "2x",
"filename" : "header@2x.png"
"scale" : "1x"
},
{
"filename" : "header@2x.png",
"idiom" : "universal",
"scale" : "3x",
"filename" : "header@3x.png"
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "headerDark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "header@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "headerDark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 34 additions & 3 deletions LeanIOS/Images.xcassets/LaunchBackground.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,48 @@
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "2xDark.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bd96d3c

Please sign in to comment.