-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add storage size information and more timings (#1129)
- Loading branch information
1 parent
00eec20
commit f4bb919
Showing
15 changed files
with
153 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { StyleSheet, View, ScrollView } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
|
||
import boundActions from '../boundActions'; | ||
import { Screen } from '../common'; | ||
import OptionButton from '../settings/OptionButton'; | ||
|
||
const styles = StyleSheet.create({ | ||
divider: { | ||
height: 16, | ||
}, | ||
}); | ||
|
||
class DiagnosticsScreen extends PureComponent { | ||
render() { | ||
const { actions } = this.props; | ||
return ( | ||
<Screen title="Diagnostics"> | ||
<ScrollView> | ||
<OptionButton label="Variables" onPress={actions.navigateToVariables} /> | ||
<View style={styles.divider} /> | ||
<OptionButton label="Timing" onPress={actions.navigateToTiming} /> | ||
<View style={styles.divider} /> | ||
<OptionButton label="Storage" onPress={actions.navigateToStorage} /> | ||
</ScrollView> | ||
</Screen> | ||
); | ||
} | ||
} | ||
|
||
export default connect(null, boundActions)(DiagnosticsScreen); |
File renamed without changes.
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,40 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { RawLabel } from '../common'; | ||
|
||
const styles = StyleSheet.create({ | ||
item: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
padding: 8, | ||
borderBottomWidth: 1, | ||
borderColor: 'rgba(127, 127, 127, 0.25)', | ||
}, | ||
key: {}, | ||
size: { | ||
fontWeight: 'bold', | ||
}, | ||
}); | ||
|
||
export default class SizeItem extends PureComponent { | ||
props: { | ||
text: string, | ||
size: number, | ||
}; | ||
|
||
render() { | ||
const { text, size } = this.props; | ||
|
||
return ( | ||
<View style={styles.item}> | ||
<RawLabel style={styles.key} text={text} /> | ||
<RawLabel | ||
style={styles.size} | ||
text={size.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')} | ||
/> | ||
</View> | ||
); | ||
} | ||
} |
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,36 @@ | ||
/* @flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { FlatList } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { Screen } from '../common'; | ||
import SizeItem from './SizeItem'; | ||
|
||
const calculateKeyStorageSizes = obj => | ||
Object.keys(obj) | ||
.map(key => ({ | ||
key, | ||
size: JSON.stringify(obj[key]).length * 2, | ||
})) | ||
.sort((a, b) => b.size - a.size); | ||
|
||
class StorageScreen extends PureComponent { | ||
render() { | ||
const { state } = this.props; | ||
const storageSizes = calculateKeyStorageSizes(state); | ||
|
||
return ( | ||
<Screen title="Storage"> | ||
<FlatList | ||
data={storageSizes} | ||
keyExtractor={item => item.key} | ||
renderItem={({ item }) => <SizeItem text={item.key} size={item.size} />} | ||
/> | ||
</Screen> | ||
); | ||
} | ||
} | ||
|
||
export default connect(state => ({ | ||
state, | ||
}))(StorageScreen); |
File renamed without changes.
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
/* @flow */ | ||
/* TODO flow */ | ||
import React, { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import boundActions from '../boundActions'; | ||
import { getAuth } from '../selectors'; | ||
import { Screen } from '../common'; | ||
import SettingsContainer from './SettingsContainer'; | ||
import SettingsCard from './SettingsCard'; | ||
|
||
export default class SettingsScreen extends PureComponent { | ||
class SettingsScreen extends PureComponent { | ||
render() { | ||
return ( | ||
<Screen title="Settings"> | ||
<SettingsContainer /> | ||
<SettingsCard {...this.props} /> | ||
</Screen> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ({ | ||
offlineNotification: state.settings.offlineNotification, | ||
onlineNotification: state.settings.onlineNotification, | ||
theme: state.settings.theme, | ||
auth: getAuth(state), | ||
}), | ||
boundActions, | ||
)(SettingsScreen); |