-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd6c3fb
commit 62ecec1
Showing
5 changed files
with
209 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, {Component} from 'react'; | ||
import { | ||
View, | ||
Text, | ||
StyleSheet | ||
} from 'react-native'; | ||
import analytics from '@store/analytics'; | ||
import SelectMultiple from 'react-native-select-multiple' | ||
|
||
import {observer} from 'mobx-react/native'; | ||
import {toJS} from 'mobx'; | ||
import CategoryStore from '@store/category'; | ||
|
||
const categories = ['tech', 'games', 'books']; | ||
|
||
@observer | ||
class Screen extends Component { | ||
|
||
static navigationOptions = { | ||
tabBarLabel: 'Settings' | ||
}; | ||
|
||
componentDidMount() { | ||
analytics.logEvent("View Settings Page"); | ||
} | ||
|
||
onSelectionsChange = (selected) => { | ||
let categories = []; | ||
selected.forEach(function (category) { | ||
categories.push(category.value); | ||
}); | ||
CategoryStore.update(categories); | ||
} | ||
|
||
render() { | ||
let selected = [].concat(toJS(CategoryStore.categories)); | ||
return ( | ||
<View style={styles.mainContainer}> | ||
<Text style={styles.title}>Add Topics</Text> | ||
<SelectMultiple | ||
items={categories} | ||
selectedItems={selected} | ||
labelStyle={styles.button_text} | ||
onSelectionsChange={this.onSelectionsChange}/> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
mainContainer: { | ||
flex: 1, | ||
padding: 15, | ||
borderTopWidth: 1, | ||
borderTopColor: '#e3e3e3', | ||
backgroundColor: "white" | ||
}, | ||
button_text: { | ||
marginLeft: 10, | ||
color: '#3F51B5', | ||
fontSize: 15, | ||
fontFamily: "SFRegular" | ||
}, | ||
title: { | ||
fontSize: 30, | ||
color: "#1a1a1a", | ||
fontFamily: "SFBold" | ||
} | ||
}); | ||
|
||
export default Screen |
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,94 @@ | ||
import React, {Component} from "react"; | ||
import {observable} from "mobx"; | ||
import {TabNavigator} from 'react-navigation'; | ||
import { | ||
AsyncStorage | ||
} from "react-native"; | ||
|
||
import { | ||
ACTIVE_BACKGROUND_COLOR, | ||
INACTIVE_BACKGROUND_COLOR, | ||
ACTIVE_TINT_COLOR, | ||
INACTIVE_TINT_COLOR | ||
} from '@theme/light'; | ||
import MainScreen from '@scene/mainScreen'; | ||
import AboutScreen from '@scene/about'; | ||
import ManageScreen from '@scene/settings'; | ||
|
||
const tabOptions = { | ||
scrollEnabled: true, | ||
lazy: true, | ||
activeBackgroundColor: ACTIVE_BACKGROUND_COLOR, | ||
inactiveBackgroundColor: INACTIVE_BACKGROUND_COLOR, | ||
inactiveTintColor: INACTIVE_TINT_COLOR, | ||
activeTintColor: ACTIVE_TINT_COLOR, | ||
labelStyle: { | ||
fontSize: 12, | ||
fontFamily: 'SFBold' | ||
}, | ||
tabStyle: { | ||
width: 120, | ||
height: 40 | ||
}, | ||
style: { | ||
backgroundColor: ACTIVE_BACKGROUND_COLOR | ||
}, | ||
indicatorStyle: { | ||
backgroundColor: ACTIVE_TINT_COLOR | ||
} | ||
}; | ||
|
||
class Store { | ||
|
||
navigation = {}; | ||
@observable isLoading = true; | ||
@observable categories = []; | ||
@observable tabs = {}; | ||
|
||
constructor() { | ||
let self = this; | ||
const screens = {}; | ||
|
||
AsyncStorage | ||
.getItem('categories') | ||
.then((categories) => { | ||
if (categories) { | ||
self.categories = JSON.parse(categories); | ||
} else { | ||
self.categories = ['tech', 'games']; | ||
} | ||
self.categories.forEach((category, i) => { | ||
screens[self.categories[i]] = { | ||
screen: () => <MainScreen navigation={self.navigation} screenProps={{category: category}}/> | ||
}; | ||
}); | ||
screens['settings'] = {screen: ManageScreen}; | ||
screens['about'] = {screen: AboutScreen}; | ||
self.tabs = TabNavigator(screens, {tabBarOptions: tabOptions}); | ||
self.isLoading = false; | ||
}); | ||
} | ||
|
||
update(categories) { | ||
let self = this; | ||
this.isLoading = true; | ||
this.categories = categories; | ||
const screens = {}; | ||
this.categories.forEach((category, i) => { | ||
screens[this.categories[i]] = { | ||
screen: () => <MainScreen screenProps={{category: category}}/> | ||
}; | ||
}); | ||
screens['settings'] = {screen: ManageScreen}; | ||
screens['about'] = {screen: AboutScreen}; | ||
this.tabs = TabNavigator(screens, {tabBarOptions: tabOptions}); | ||
AsyncStorage | ||
.setItem('categories', JSON.stringify(categories)) | ||
.then(() => { | ||
self.isLoading = false; | ||
}) | ||
} | ||
|
||
} | ||
|
||
export default store = new Store |
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