Skip to content

Commit

Permalink
feat: allow labs and apps to work online and offline
Browse files Browse the repository at this point in the history
Apps and labs that are offline-ready will be downloaded and should
work offline.

closes #46
  • Loading branch information
juancarlosfarah committed May 1, 2019
1 parent 37bc8c4 commit 4209a41
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 131 deletions.
106 changes: 60 additions & 46 deletions src/components/phase/PhaseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,68 @@ import React from 'react';
import PropTypes from 'prop-types';
import './PhaseApp.css';

const PhaseApp = ({ uri }) => (
// state = {
// data: null,
// };
//
// constructor(props) {
// super(props);
// this.retrieveData();
// }
//
// storeData = async (key, value) => {
// try {
// await AsyncStorage.setItem(key, value);
// } catch (error) {
// // Error saving data
// }
// };
//
// retrieveData = async () => {
// const { id } = this.props;
// try {
// const data = await AsyncStorage.getItem(id);
// if (data !== null) {
// this.setState({
// data,
// });
// }
// } catch (error) {
// // Error retrieving data
// }
// };
//
// sendData = () => {
// const { data } = this.state;
// this.webView.postMessage(data, '*');
// };
//
// receiveData = (data) => {
// const { id } = this.props;
// this.storeData(id, data);
// };
<div className="AppDiv">
<iframe title={uri} className="App" sandbox="allow-scripts" src={uri} />
</div>
);
const PhaseApp = ({ url, asset, name }) => {
let uri = url;
if (asset) {
uri = `file://${asset}`;
}
return (
// state = {
// data: null,
// };
//
// constructor(props) {
// super(props);
// this.retrieveData();
// }
//
// storeData = async (key, value) => {
// try {
// await AsyncStorage.setItem(key, value);
// } catch (error) {
// // Error saving data
// }
// };
//
// retrieveData = async () => {
// const { id } = this.props;
// try {
// const data = await AsyncStorage.getItem(id);
// if (data !== null) {
// this.setState({
// data,
// });
// }
// } catch (error) {
// // Error retrieving data
// }
// };
//
// sendData = () => {
// const { data } = this.state;
// this.webView.postMessage(data, '*');
// };
//
// receiveData = (data) => {
// const { id } = this.props;
// this.storeData(id, data);
// };
<div className="AppDiv">
<iframe title={name} className="App" sandbox="allow-scripts" src={uri} />
</div>
);
};

PhaseApp.propTypes = {
uri: PropTypes.string.isRequired,
url: PropTypes.string,
asset: PropTypes.string,
name: PropTypes.string,
};

PhaseApp.defaultProps = {
url: null,
asset: null,
name: 'Image',
};

export default PhaseApp;
4 changes: 2 additions & 2 deletions src/components/phase/PhaseItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const renderResource = item => {
};

const renderPhaseItem = item => {
const { id, category, asset } = item;
const { id, category, asset, url, name } = item;
switch (category) {
case RESOURCE:
return renderResource(item);

case APPLICATION:
return <PhaseApp key={id} id={id} uri={`file://${asset}`} />;
return <PhaseApp key={id} id={id} url={url} asset={asset} name={name} />;

default:
return <div key={id} id={id} />;
Expand Down
15 changes: 0 additions & 15 deletions src/components/phase/PhaseLab.css

This file was deleted.

68 changes: 0 additions & 68 deletions src/components/phase/PhaseLab.js

This file was deleted.

0 comments on commit 4209a41

Please sign in to comment.