Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amundsf-p4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Amund Skuggevik Foss
amundsf-p4
Merge requests
!2
(
#2
) connect with backend
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
(
#2
) connect with backend
(#2)_connect_with_backend
into
master
Overview
0
Commits
3
Pipelines
0
Changes
7
Merged
Amund Skuggevik Foss
requested to merge
(#2)_connect_with_backend
into
master
3 years ago
Overview
0
Commits
3
Pipelines
0
Changes
7
Expand
1
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
5fd47bf7
3 commits,
3 years ago
7 files
+
299
−
37
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
components/PokemonCard.tsx
+
58
−
19
Options
import
React
from
'
react
'
;
import
{
StyleSheet
,
Image
,
Alert
,
Text
,
View
,
Button
,
Pressable
}
from
'
react-native
'
;
import
{
useMutation
}
from
'
@apollo/react-hooks
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
Image
,
Text
,
View
,
Pressable
,
TouchableWithoutFeedback
}
from
'
react-native
'
;
import
{
MUTATE_POKEMON
}
from
'
../graphql/get-pokemons
'
;
import
{
Pokemon
}
from
"
../types/types
"
;
const
PokemonCard
=
()
=>
{
return
(
const
PokemonCard
:
React
.
FC
<
{
pokemon
:
Pokemon
}
>
=
({
pokemon
})
=>
{
const
[
clicked
,
setClicked
]
=
useState
(
false
);
const
[
capturedPokemons
,
setCapturedPokemons
]
=
useState
(
pokemon
.
captured
);
const
[
updateDatabase
]
=
useMutation
(
MUTATE_POKEMON
,
{
variables
:
{
pokemonId
:
{
id
:
pokemon
.
id
}
}
})
const
handleClick
=
()
=>
{
setClicked
(
!
clicked
)
};
const
updateDatabaseFunction
=
()
=>
{
setCapturedPokemons
(
!
capturedPokemons
)
updateDatabase
()
}
return
(
//touchablewithoutfeedback for mer info knappen
<
View
style
=
{
styles
.
pokemon
}
>
<
View
style
=
{
styles
.
pokemon__name
}
>
<
Text
>
Kristin Hestnes
</
Text
>
<
Text
>
{
pokemon
.
name
}
</
Text
>
</
View
>
<
View
style
=
{
styles
.
pokemon__meta
}
>
<
Text
style
=
{
styles
.
pokemon__meta_text
}
>
# 69
</
Text
>
</
View
>
<
View
style
=
{
styles
.
pokemon__image
}
>
<
Image
style
=
{
styles
.
pokemon__image_img
}
source
=
{
{
uri
:
'
https://assets.pokemon.com/assets/cms2/img/pokedex/full/004.png
'
}
}
/>
</
View
>
{
clicked
&&
<
View
style
=
{
styles
.
pokemon__meta
}
>
<
Text
style
=
{
styles
.
pokemon__meta_text
}
>
#
{
pokemon
.
id
}
</
Text
>
</
View
>
}
<
TouchableWithoutFeedback
onPress
=
{
handleClick
}
>
<
View
style
=
{
styles
.
pokemon__image
}
>
<
Image
style
=
{
styles
.
pokemon__image_img
}
source
=
{
{
uri
:
pokemon
.
imgUrl
}
}
/>
</
View
>
</
TouchableWithoutFeedback
>
{
clicked
&&
<
View
style
=
{
styles
.
pokemon__type
}
>
<
Text
style
=
{
styles
.
pokemon__type_text
}
>
Alcoholic
</
Text
>
<
Text
style
=
{
styles
.
pokemon__type_text
}
>
Attacker
</
Text
>
{
pokemon
.
pokemonTypes
.
map
((
t
:
string
)
=>
(<
Text
style
=
{
styles
.
pokemon__type_text
}
key
=
{
t
}
>
{
t
}
</
Text
>))
}
</
View
>
<
View
>
<
Pressable
style
=
{
styles
.
button
}
onPress
=
{
()
=>
Alert
.
alert
(
"
REJECTED, NOT HOT ENOUGH!
"
)
}
>
<
Text
style
=
{
{
fontSize
:
30
,
color
:
'
white
'
}
}
>
Hit on me?
</
Text
>
}
<
View
>
<
Pressable
style
=
{
[
capturedPokemons
?
styles
.
buttonPressed
:
styles
.
buttonNotPressed
]
}
onPress
=
{
updateDatabaseFunction
}
>
<
Text
style
=
{
{
fontSize
:
30
,
color
:
'
white
'
}
}
>
{
capturedPokemons
?
"
Captured!
"
:
"
Catch me!
"
}
</
Text
>
</
Pressable
>
</
View
>
@@ -111,7 +141,7 @@ const styles = StyleSheet.create({
textAlign
:
'
center
'
,
},
button
:
{
button
NotPressed
:
{
backgroundColor
:
'
#17c589
'
,
width
:
"
100%
"
,
paddingTop
:
0
,
@@ -120,6 +150,15 @@ const styles = StyleSheet.create({
justifyContent
:
'
center
'
,
},
buttonPressed
:
{
backgroundColor
:
'
#FF6347
'
,
width
:
"
100%
"
,
paddingTop
:
0
,
paddingBottom
:
5
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
}
});
Loading