-
Notifications
You must be signed in to change notification settings - Fork 10
Ht7 #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
viprogramm
wants to merge
3
commits into
romabelka:master
Choose a base branch
from
viprogramm:HT7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ht7 #30
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,17 @@ | ||
| import { initializeApp } from 'firebase/app' | ||
| import 'firebase/auth' | ||
| import 'firebase/database' | ||
|
|
||
| export const appName = 'advreact-25-06' | ||
|
|
||
| const config = { | ||
| apiKey: 'AIzaSyBnWMvhTYPpwSnVwYvrWTrsS7TlHwu1wHg', | ||
| authDomain: 'advreact-25-06.firebaseapp.com', | ||
| databaseURL: 'https://advreact-25-06.firebaseio.com', | ||
| projectId: 'advreact-25-06', | ||
| storageBucket: '', | ||
| messagingSenderId: '371151529375' | ||
| } | ||
|
|
||
|
|
||
| export default () => initializeApp(config) |
This file contains hidden or 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 hidden or 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,12 @@ | ||
| import firebase from 'firebase/app' | ||
| import stores from '../stores' | ||
|
|
||
| export const LoggedIn = (email, password) => { | ||
| const firebaseAuth = firebase.auth() | ||
| const { auth } = stores | ||
| return firebaseAuth.signInWithEmailAndPassword(email, password) | ||
| .then(({user})=> auth.setUser(user)) | ||
| .catch((e) => console.error(e)) | ||
| } | ||
|
|
||
|
|
This file contains hidden or 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,16 @@ | ||
| import firebase from 'firebase/app' | ||
| import stores from '../stores' | ||
|
|
||
| const LoadEvents = () => { | ||
| stores.events.toggleLoading() | ||
| const ref = firebase.database().ref('events') | ||
| ref.once('value') | ||
| .then(snapshot => { | ||
| const events = Object.entries(snapshot.val()).map(([uid, event]) => ({...event, uid})) | ||
| stores.events.setData(events) | ||
| }) | ||
| .finally(()=>stores.events.toggleLoading()) | ||
| } | ||
|
|
||
|
|
||
| export default LoadEvents | ||
This file contains hidden or 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,17 @@ | ||
| import firebase from 'firebase/app' | ||
| import stores from '../stores' | ||
|
|
||
| const LoadPeople = () => { | ||
| stores.people.toggleLoading() | ||
| const ref = firebase.database().ref('people') | ||
| ref.once('value') | ||
| .then(snapshot => { | ||
| const people = Object.entries(snapshot.val()).map(([uid, people]) => ({...people, uid})) | ||
| console.log(people); | ||
| stores.people.setData(people) | ||
| }) | ||
| .finally(()=>stores.people.toggleLoading()) | ||
| } | ||
|
|
||
|
|
||
| export default LoadPeople |
This file contains hidden or 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,19 +1,32 @@ | ||
| import {createStackNavigator} from 'react-navigation' | ||
| import {createStackNavigator, createBottomTabNavigator, createSwitchNavigator} from 'react-navigation' | ||
| import AuthScreen from './screens/auth' | ||
| import EventListScreen from './screens/event-list' | ||
| import EventScreen from './screens/event' | ||
| import PeopleScreen from './screens/people' | ||
|
|
||
| export default createStackNavigator({ | ||
| auth: { | ||
| screen: AuthScreen | ||
| }, | ||
| eventList: { | ||
| screen: EventListScreen, | ||
| navigationOptions: { | ||
| title: 'events' | ||
| } | ||
| }, | ||
| event: { | ||
| screen: EventScreen | ||
| const EventListStack = createStackNavigator({ | ||
| eventList: { | ||
| screen: EventListScreen, | ||
| navigationOptions: { | ||
| title: 'events' | ||
| } | ||
| }, | ||
| event: EventScreen, | ||
| }); | ||
|
|
||
| const PeopleStack = createSwitchNavigator({ | ||
| people: PeopleScreen, | ||
| }); | ||
|
|
||
| const BottomStack = createBottomTabNavigator( | ||
| { | ||
| eventList: EventListStack, | ||
| people: PeopleStack, | ||
| } | ||
| ); | ||
|
|
||
| export default createStackNavigator({ | ||
| auth: AuthScreen, | ||
| eventList: BottomStack, | ||
| people: BottomStack | ||
| }) |
This file contains hidden or 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,23 @@ | ||
| import React, { Component } from 'react' | ||
| import {Text, StyleSheet} from 'react-native' | ||
| import Card from '../common/card' | ||
|
|
||
| class PeopleCard extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| render() { | ||
| const { people } = this.props | ||
| return ( | ||
| <Card> | ||
| <Text>{people.lastName} {people.firstName} {people.email}</Text> | ||
| </Card> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| }) | ||
|
|
||
| export default PeopleCard |
This file contains hidden or 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,41 @@ | ||
| import React, { Component } from 'react' | ||
| import {Text, StyleSheet, SectionList, TouchableOpacity} from 'react-native' | ||
| import PeopleCard from './people-card' | ||
| import groupBy from 'lodash/groupBy' | ||
|
|
||
| class PeopleList extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| render() { | ||
| const grouped = groupBy(this.props.people, people => people.lastName.charAt(0)) | ||
| const sections = Object.entries(grouped).map(([letter, list]) => ({ | ||
| title: `${letter}, ${list.length} people`, | ||
| data: list.map(people => ({key: people.uid, people})) | ||
| })) | ||
| return <SectionList | ||
| sections = {sections} | ||
| renderSectionHeader = {this.getSectionRenderer} | ||
| renderItem = {({item}) => <PeopleCard people = {item.people} />} | ||
| /> | ||
| } | ||
|
|
||
| getSectionRenderer = ({section}) => <Text style={styles.header}>{section.title}</Text> | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| header: { | ||
| backgroundColor: '#F0F0F0', | ||
| height: 40, | ||
| lineHeight: 40, | ||
| marginBottom: 5, | ||
| shadowOffset: { | ||
| height: 2, width: 0 | ||
| }, | ||
| shadowOpacity: 0.3, | ||
| elevation: 3 | ||
| } | ||
| }) | ||
|
|
||
| export default PeopleList |
This file contains hidden or 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 hidden or 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,31 @@ | ||
| import React, { Component } from 'react' | ||
| import {StyleSheet, Text} from 'react-native' | ||
| import {observer, inject} from 'mobx-react' | ||
| import PeopleList from '../people/people-list' | ||
| import data from '../../fixtures' | ||
| import loadPeople from '../../actions/people' | ||
|
|
||
| @inject('people') | ||
| @observer | ||
| class EventListScreen extends Component { | ||
| static propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| componentDidMount() { | ||
| loadPeople() | ||
| } | ||
|
|
||
| render() { | ||
| const {data, loading} = this.props.people | ||
| if(loading) { | ||
| return <Text>Loading...</Text> | ||
| } | ||
| return <PeopleList people = {data} /> | ||
| } | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| }) | ||
|
|
||
| export default EventListScreen |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все хорошо, но я предпочитаю такие вещи делать методами стора