-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructured settings and introduced update check
- Loading branch information
1 parent
d788f33
commit f4768f5
Showing
8 changed files
with
172 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/stacks/default/tabs/settings/screens/DeveloperScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { | ||
Button, | ||
Card, | ||
Divider, | ||
Icon, | ||
Layout, | ||
List, | ||
ListItem, | ||
TopNavigation, | ||
TopNavigationAction | ||
} from "@ui-kitten/components"; | ||
import React, {useState} from "react"; | ||
import {Alert, ListRenderItemInfo, StyleSheet, View} from "react-native"; | ||
import {useNavigation, useRoute} from "@react-navigation/native"; | ||
import renderTopNavigationTitle from "../../../../../common/components/renderTopNavigationTitle"; | ||
import {SettingsTabNavigationProp, SettingsTabRoute, SettingsTabRouteProp} from "../SettingsTabRoute"; | ||
import i18n from "../../../../../i18n"; | ||
import renderCardHeader from "../../../../../common/components/renderCardHeader"; | ||
import Constants from 'expo-constants'; | ||
import CardListContainer from "../../../../../common/components/CardListContainer"; | ||
import GrowBuddyDatabaseService from "../../../../../services/database/GrowBuddyDatabaseService"; | ||
import * as Updates from 'expo-updates'; | ||
|
||
export default () => { | ||
|
||
const navigation = useNavigation<SettingsTabNavigationProp<SettingsTabRoute.SETTINGS_BACKUP_DETAIL>>(); | ||
const route = useRoute<SettingsTabRouteProp<SettingsTabRoute.SETTINGS_BACKUP_DETAIL>>(); | ||
|
||
const back = () => { | ||
navigation.goBack(); | ||
} | ||
|
||
const checkForOTAUpdate = () => { | ||
Updates.checkForUpdateAsync().then((result) => { | ||
if (result.isAvailable) { | ||
Alert.alert( | ||
'OTA Aktualisierung', | ||
`Version ${result.manifest.version} ist verfügbar`, | ||
[ | ||
{ | ||
text: 'Jetzt übernehmen', | ||
onPress: () => { | ||
Updates.fetchUpdateAsync().then(() => { | ||
Updates.reloadAsync(); | ||
}); | ||
} | ||
}, | ||
{text: 'Ignorieren'} | ||
] | ||
); | ||
} else { | ||
Alert.alert( | ||
'OTA Aktualisierung', | ||
`Version ${Constants.manifest.version} ist die aktuellste Version`, | ||
[{text: 'OK'}] | ||
); | ||
} | ||
}); | ||
} | ||
|
||
const versions = [ | ||
{ | ||
key: 'App Version', | ||
value: Constants.manifest.version | ||
}, | ||
{ | ||
key: 'Native App Version', | ||
value: Constants.nativeAppVersion | ||
} | ||
] | ||
|
||
const BackIcon = (props: any) => ( | ||
<Icon {...props} name='arrow-back'/> | ||
); | ||
|
||
const BackAction = () => ( | ||
<TopNavigationAction icon={BackIcon} onPress={back}/> | ||
); | ||
|
||
const renderVersionItem = ({item}: ListRenderItemInfo<any>) => { | ||
return ( | ||
<ListItem title={item.value} description={item.key} disabled={true}/> | ||
) | ||
} | ||
|
||
const Footer = (props: any) => ( | ||
<View {...props}> | ||
<Button onPress={checkForOTAUpdate}> | ||
Auf OTA Aktualisierungen prüfen | ||
</Button> | ||
</View> | ||
) | ||
|
||
return ( | ||
<React.Fragment> | ||
<TopNavigation title={renderTopNavigationTitle(i18n.t('DEVELOPER'))} | ||
alignment="center" | ||
accessoryLeft={BackAction}/> | ||
<Divider/> | ||
<Layout style={styles.layout} level="2"> | ||
<Card header={renderCardHeader('App Version')} style={styles.card} footer={Footer}> | ||
<CardListContainer> | ||
<List data={versions} renderItem={renderVersionItem} | ||
ItemSeparatorComponent={Divider}/> | ||
</CardListContainer> | ||
</Card> | ||
<Card header={renderCardHeader('Danger zone')}> | ||
<Button onPress={() => GrowBuddyDatabaseService.resetDatabase()} status="danger"> | ||
Datenbank zurücksetzen | ||
</Button> | ||
</Card> | ||
</Layout> | ||
<Divider/> | ||
</React.Fragment> | ||
) | ||
|
||
} | ||
|
||
const styles = StyleSheet.create({ | ||
layout: { | ||
flex: 1, | ||
padding: 15 | ||
}, | ||
card: { | ||
marginBottom: 15 | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters