Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ReactNativeToDo2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Isaac Solomon
ReactNativeToDo2
Commits
b957368d
Commit
b957368d
authored
2 months ago
by
isaacwsolomon
Browse files
Options
Downloads
Patches
Plain Diff
Added input text box and added some styling
parent
6547c89f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/screens/list.tsx
+32
-6
32 additions, 6 deletions
app/screens/list.tsx
with
32 additions
and
6 deletions
app/screens/list.tsx
+
32
−
6
View file @
b957368d
import
{
addDoc
,
collection
}
from
'
firebase/firestore
'
;
import
{
addDoc
,
collection
}
from
'
firebase/firestore
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
{
View
,
Text
,
Button
}
from
'
react-native
'
;
import
{
View
,
Text
,
Button
,
TextInput
,
StyleSheet
}
from
'
react-native
'
;
import
{
FIRESTORE_DB
}
from
'
../../firebaseConfig
'
;
import
{
FIRESTORE_DB
}
from
'
../../firebaseConfig
'
;
const
List
=
({
navigation
}
:
any
)
=>
{
const
List
=
({
navigation
}
:
any
)
=>
{
const
[
todos
,
setTodos
]
=
useState
<
any
[]
>
([]);
const
[
todo
,
setTodo
]
=
useState
(
''
);
useEffect
(()
=>
{},
[]);
useEffect
(()
=>
{},
[]);
const
addTodo
=
async
()
=>
{
const
addTodo
=
async
()
=>
{
console
.
log
(
'
ADD
'
);
console
.
log
(
'
ADD
'
);
const
doc
=
addDoc
(
collection
(
FIRESTORE_DB
,
'
todos
'
),
{
title
:
'
I am a test
'
,
done
:
false
});
const
doc
=
await
addDoc
(
collection
(
FIRESTORE_DB
,
'
todos
'
),
{
title
:
'
I am a test
'
,
done
:
false
});
console
.
log
(
'
📝 ~ file: List.tsx:12 ~ addTodo ~ doc:
'
,
doc
);
console
.
log
(
'
📝 ~ file: List.tsx:12 ~ addTodo ~ doc:
'
,
doc
);
};
};
return
(
return
(
<
View
>
<
View
style
=
{
styles
.
container
}
>
<
Button
onPress
=
{
()
=>
addTodo
()
}
title
=
"Add Todo"
/>
<
View
style
=
{
styles
.
form
}
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"Add new todo"
onChangeText
=
{
(
text
:
string
)
=>
setTodo
(
text
)
}
value
=
{
todo
}
/>
<
Button
onPress
=
{
addTodo
}
title
=
"Add Todo"
disabled
=
{
todo
===
''
}
/>
</
View
>
</
View
>
</
View
>
);
);
}
}
export
default
List
;
export
default
List
;
\ No newline at end of file
const
styles
=
StyleSheet
.
create
({
container
:
{
marginHorizontal
:
20
,
},
form
:
{
marginVertical
:
10
,
flexDirection
:
'
row
'
,
alignItems
:
'
center
'
,
},
input
:
{
flex
:
1
,
height
:
40
,
borderWidth
:
1
,
borderRadius
:
1
,
padding
:
10
,
backgroundColor
:
'
#fff
'
,
}
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment