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

Commit

Permalink
📱 Added responsive orientation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
micahlt committed Sep 30, 2020
1 parent 32c839a commit 980739f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="org.scratchclient4.sc4mobile" version="0.1.7" android-versionCode="9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="org.scratchclient4.sc4mobile" version="0.1.8" android-versionCode="9" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Itchy</name>
<description>
A Scratch client for Android mobile devices.
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-screen-orientation": "^3.0.2",
"cordova-plugin-theme-detection": "^1.2.1",
"cordova-plugin-whitelist": "^1.3.4",
"cssnano": "^4.1.10",
"es6-promise-plugin": "^4.2.2",
"parcel-bundler": "^1.12.4",
"parcel-plugin-html-externals": "^0.2.0",
"sass": "^1.26.10",
Expand All @@ -36,7 +38,8 @@
"cordova-plugin-inappbrowser": {},
"cordova-plugin-device": {},
"cordova-plugin-browsertab": {},
"cordova-plugin-theme-detection": {}
"cordova-plugin-theme-detection": {},
"cordova-plugin-screen-orientation": {}
},
"platforms": [
"browser",
Expand Down
17 changes: 14 additions & 3 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ let setTheme = (toSwap) => {
}

let renderProject = (id, title, user) => {
if (device.platform == "Android") {
window.open = cordova.plugins.browsertab.openUrl;
}
let div = document.createElement('div');
div.classList.add('project');
div.classList.add('ripple');
Expand Down Expand Up @@ -132,6 +129,19 @@ document.getElementById('menuButton').addEventListener('click', (event) => {
document.addEventListener('deviceready', windowLoaded);

function windowLoaded() {
if (device.platform == "Android") {
window.open = cordova.plugins.browsertab.openUrl;
}
screen.orientation.addEventListener('change', function() {
console.log('orientation changed');
if (screen.orientation.type.includes('landscape')) {
document.getElementById('projects').style.gridTemplateColumns = "auto auto";
document.getElementById('projects').style.gridColumnGap = "3%";
} else if (screen.orientation.type.includes('portrait')) {
document.getElementById('projects').style.gridTemplateColumns = "auto";
document.getElementById('projects').style.gridColumnGap = "0";
}
})
document.getElementsByClassName('spinner')[0].style.display = 'block';
cordova.plugins.ThemeDetection.isDarkModeEnabled(
function(success) {
Expand Down Expand Up @@ -165,6 +175,7 @@ function windowLoaded() {
getRecentProjects(0);
} else if (scrollOptions[i].innerText == 'Messages') {
window.open('https://scratch.mit.edu/messages');
document.getElementsByClassName('spinner')[0].style.display = 'none';
} else {
getTaggedProjects(scrollOptions[i].innerText.toLowerCase(), 0)
}
Expand Down
2 changes: 2 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ body {
padding-right: 5%;
padding-bottom: 1em;
transform: translateX(-2px);
display: grid;
grid-template-columns: 1;
}

.project {
Expand Down

0 comments on commit 980739f

Please sign in to comment.