tmp : update install controller for home screen folders
This commit is contained in:
parent
3f38eff393
commit
a596f7a646
3 changed files with 82 additions and 16 deletions
|
|
@ -33,7 +33,7 @@ class InstallController {
|
|||
_.forEach(response.data.datas, function (value, key) {
|
||||
switch (key) {
|
||||
case "MainColor":
|
||||
Setting.add({ key: key, value: value });
|
||||
Setting.upsert({ key: key, value: value });
|
||||
break;
|
||||
case "SquaredLogo":
|
||||
case "RectangleLogo":
|
||||
|
|
@ -55,13 +55,44 @@ class InstallController {
|
|||
});
|
||||
Alert.alert(i18n.t("alert.info"), i18n.t("install.install_complete"));
|
||||
} else {
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("alert.error_has_occurred"));
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("alert.error_has_occurred"));
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||
})
|
||||
} else {
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getAppConfig(url) {
|
||||
NetInfo.fetch().then(state => {
|
||||
if (state.isConnected) {
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: url + '/api/app',
|
||||
responseType: 'json',
|
||||
params: {
|
||||
token: api_token
|
||||
},
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.data) {
|
||||
if (response.data.status === "OK") {
|
||||
Setting.upsert({ key: 'HomeFolders', value: JSON.stringify(response.data.datas.folders) });
|
||||
Alert.alert(i18n.t("alert.info"), i18n.t("install.install_complete"));
|
||||
} else {
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||
})
|
||||
} else {
|
||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet"));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SettingModel {
|
|||
add(data) {
|
||||
this.realm.write(() => {
|
||||
if (data.id === undefined) {
|
||||
let id: any = this.realm.objects(this.schema).max('id');
|
||||
let id = this.realm.objects(this.schema).max('id');
|
||||
data.id = id === undefined ? 1 : id + 1;
|
||||
}
|
||||
try {
|
||||
|
|
@ -18,6 +18,30 @@ class SettingModel {
|
|||
});
|
||||
}
|
||||
|
||||
upsert(data) {
|
||||
let tmp = this.get(data.key);
|
||||
if (tmp === false || tmp === undefined) {
|
||||
this.add(data);
|
||||
} else {
|
||||
if (data.id === undefined) {
|
||||
data.id = tmp.id;
|
||||
}
|
||||
this.realm.write(() => {
|
||||
this.realm.create(this.schema, data, 'modified');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
let tmp = this.realm.objects(this.schema);
|
||||
if (tmp.length === 0) {
|
||||
return false;
|
||||
} else {
|
||||
tmp = tmp.filtered('key = "' + key + '"')[0];
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SettingModel;
|
||||
|
|
|
|||
|
|
@ -8,24 +8,21 @@ import styles from '../../Resources/Styles/HomeStyle';
|
|||
import i18n from "../../I18n";
|
||||
// FileSytem
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
// Database
|
||||
import { Setting } from "../../Database";
|
||||
import _ from 'lodash';
|
||||
|
||||
class HomeScreen extends React.Component {
|
||||
|
||||
render() {
|
||||
let buttons = Setting.get("HomeFolders");
|
||||
buttons = JSON.parse(buttons.value);
|
||||
//console.log(typeof Object.values(buttons))
|
||||
const arr = [1, 2, 3]
|
||||
return (
|
||||
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background}>
|
||||
<View style={styles.container}>
|
||||
<TouchableOpacity onPress={() => { }} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('home_s.1')}</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => { }} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('home_s.2')}</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => { }} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('home_s.3')}</Text>
|
||||
</TouchableOpacity>
|
||||
{/* {this.getHomeButton()} */}
|
||||
<TouchableOpacity onPress={() => { }} style={styles.button}>
|
||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
||||
|
|
@ -38,6 +35,20 @@ class HomeScreen extends React.Component {
|
|||
</ImageBackground>
|
||||
);
|
||||
}
|
||||
|
||||
getHomeButtons() {
|
||||
let buttons = Setting.get("HomeFolders");
|
||||
if (buttons) {
|
||||
buttons = JSON.parse(buttons.value);
|
||||
_.forEach(buttons, function (value, key) {
|
||||
console.log(JSON.parse(value.name).fr)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
openFolder(id) {
|
||||
console.log(id)
|
||||
}
|
||||
}
|
||||
|
||||
export default HomeScreen;
|
||||
Loading…
Add table
Reference in a new issue