Skip to content

Commit

Permalink
Setup realmdb
Browse files Browse the repository at this point in the history
  • Loading branch information
wendreof committed Jul 2, 2019
1 parent 6f6fdeb commit d2a6d1d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pages/Main/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import React from 'react';
import React, {useState} from 'react';
import Icon from 'react-native-vector-icons/MaterialIcons';
import Repository from '~/components/Repository';
import {
Container, Form, Input, Submit, Title, List
Container, Form, Input, Submit, Title, List,
} from './styles';

export default function Main() {

const [input, setInput] = useState('');

function handleAddRepository(){
console.
}

return (
<Container>
<Title>Repositories</Title>
<Form>
<Input
value={input}
onChangeText={setInput}
autoCapitalize="none"
autoCorrect={false}
placeholder="Procurar repositório..."
/>
<Submit onPress={() => {}}>
<Submit onPress={handleAddRepository}>
<Icon name="add" size={22} color="#FFF" />
</Submit>
</Form>
Expand Down
14 changes: 14 additions & 0 deletions src/schemas/RepositorySchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default class RepositorySchema{
static schema = {
name: 'Repository',
primaryKey: 'id',
properties:{
id: { type: 'int', indexed: true},
name: 'string',
fullName: 'string',
description: 'string',
stars: 'int',
forks: 'int',
},
};
}
9 changes: 9 additions & 0 deletions src/services/realm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Realm from 'realm';

import RepositorySchema from '../schemas/RepositorySchema';

export default function getRealm(){
return Realm.open({
schema: [RepositorySchema],
});
}

0 comments on commit d2a6d1d

Please sign in to comment.