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
Commits
d78d9864
Commit
d78d9864
authored
3 years ago
by
Amund Skuggevik Foss
Browse files
Options
Downloads
Plain Diff
Merge branch '(
#6
)Structural_changes_to_files' into 'master'
Adjusting functions and styling, deleted searchBar See merge request
!6
parents
cb331ee0
2ef43c7e
No related branches found
No related tags found
1 merge request
!6
Adjusting functions and styling, deleted searchBar
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/Header.tsx
+108
-76
108 additions, 76 deletions
components/Header.tsx
components/SearchBar.tsx
+0
-47
0 additions, 47 deletions
components/SearchBar.tsx
containers/PokemonsContainer.tsx
+22
-22
22 additions, 22 deletions
containers/PokemonsContainer.tsx
with
130 additions
and
145 deletions
components/Header.tsx
+
108
−
76
View file @
d78d9864
import
{
textAlign
}
from
'
@mui/system
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
Image
,
Text
,
StyleSheet
,
View
}
from
"
react-native
"
;
import
{
Image
,
Text
,
TextInput
,
StyleSheet
,
View
}
from
"
react-native
"
;
import
SelectDropdown
from
'
react-native-select-dropdown
'
import
SelectDropdown
from
'
react-native-select-dropdown
'
import
{
SearchBar
}
from
'
./SearchBar
'
import
{
useRecoilState
}
from
'
recoil
'
import
{
useRecoilState
}
from
'
recoil
'
import
{
capturedFilterState
,
typeState
}
from
"
../atoms/atoms
"
;
import
{
searchState
,
capturedFilterState
,
typeState
}
from
"
../atoms/atoms
"
;
export
const
Header
=
()
=>
{
export
const
Header
=
()
=>
{
const
[
searchTextValue
,
setSearchTextValue
]
=
useRecoilState
(
searchState
)
const
[
captured
Sort
ing
,
setCaptured
Sort
ing
]
=
useRecoilState
(
capturedFilterState
)
const
[
captured
Filter
ing
,
setCaptured
Filter
ing
]
=
useRecoilState
(
capturedFilterState
)
const
[
type
,
setType
]
=
useRecoilState
(
typeState
)
const
[
type
,
setType
]
=
useRecoilState
(
typeState
)
const
filterTypes
=
[
"
All
"
,
"
Bug
"
,
"
Dark
"
,
"
Dragon
"
,
"
Electric
"
,
"
Fairy
"
,
"
Fighting
"
,
"
Fire
"
,
"
Flying
"
,
"
Ghost
"
,
"
Grass
"
,
"
Ground
"
,
"
Ice
"
,
"
Normal
"
,
"
Poison
"
,
"
Psychic
"
,
"
Rock
"
,
"
Steel
"
,
"
Water
"
];
useEffect
(()
=>
{
const
SearchChange
=
(
value
:
React
.
SetStateAction
<
string
>
)
=>
{
console
.
log
(
capturedSorting
)
setSearchTextValue
(
value
)
},
[
capturedSorting
])
};
useEffect
(()
=>
{
console
.
log
(
type
)
},
[
type
])
const
handleCapturedChange
=
(
value
:
React
.
SetStateAction
<
string
|
boolean
|
null
>
)
=>
{
const
filterTypes
=
[
"
All
"
,
"
Bug
"
,
"
Dark
"
,
"
Dragon
"
,
"
Electric
"
,
"
Fairy
"
,
"
Fighting
"
,
"
Fire
"
,
"
Flying
"
,
"
Ghost
"
,
"
Grass
"
,
"
Ground
"
,
"
Ice
"
,
"
Normal
"
,
"
Poison
"
,
"
Psychic
"
,
"
Rock
"
,
"
Steel
"
,
"
Water
"
];
const
CapturedChange
=
(
value
:
React
.
SetStateAction
<
string
|
boolean
|
null
>
)
=>
{
console
.
log
(
value
)
console
.
log
(
value
)
if
(
value
==
=
"
All
"
)
{
if
(
value
==
"
All
"
)
{
setCaptured
Sort
ing
(
null
);
setCaptured
Filter
ing
(
null
);
}
else
if
(
value
==
=
"
Captured
"
)
{
}
else
if
(
value
==
"
Captured
"
)
{
setCaptured
Sort
ing
(
true
)
setCaptured
Filter
ing
(
true
)
}
else
{
}
else
{
setCaptured
Sort
ing
(
false
)
setCaptured
Filter
ing
(
false
)
}
}
};
};
const
TypeChange
=
(
value
:
React
.
SetStateAction
<
string
>
)
=>
{
const
handleTypeChange
=
(
value
:
React
.
SetStateAction
<
string
>
)
=>
{
if
(
value
===
"
All
"
)
{
if
(
value
===
"
All
"
)
{
setType
(
""
);
setType
(
""
);
}
else
{
}
else
{
...
@@ -45,50 +62,54 @@ export const Header = () => {
...
@@ -45,50 +62,54 @@ export const Header = () => {
return
(
return
(
<
View
>
<
View
>
{
/* Image Container */
}
<
View
style
=
{
styles
.
imgContainer
}
>
<
View
style
=
{
styles
.
imgContainer
}
>
<
Image
style
=
{
styles
.
pokemonImg
}
source
=
{
require
(
"
../resources/pokemonLogo.png
"
)
}
/>
<
Image
style
=
{
styles
.
pokemonImg
}
source
=
{
require
(
"
../resources/pokemonLogo.png
"
)
}
/>
</
View
>
</
View
>
{
/* Search, Filtering and Sorting Container */
}
<
View
style
=
{
styles
.
filtering
Sorting
Container
}
>
<
View
style
=
{
styles
.
filteringContainer
}
>
<
Text
>
Types
</
Text
>
<
Text
style
=
{
{
fontSize
:
20
,
marginBottom
:
5
}
}
>
Types
</
Text
>
<
SelectDropdown
<
SelectDropdown
buttonStyle
=
{
styles
.
DropdownFilter
}
buttonStyle
=
{
styles
.
DropdownFilter
}
defaultValue
=
{
"
All
"
}
defaultValue
=
{
"
All
"
}
data
=
{
filterTypes
}
data
=
{
filterTypes
}
onSelect
=
{
(
selectedItem
,
index
)
=>
{
onSelect
=
{
(
selectedItem
)
=>
{
handle
TypeChange
(
selectedItem
)
TypeChange
(
selectedItem
)
}
}
}
}
buttonTextAfterSelection
=
{
(
selectedItem
,
index
)
=>
{
buttonTextAfterSelection
=
{
(
selectedItem
)
=>
{
// text represented after item is selected
// text represented after item is selected
return
selectedItem
return
selectedItem
}
}
}
}
rowTextForSelection
=
{
(
item
,
index
)
=>
{
rowTextForSelection
=
{
(
item
)
=>
{
// text represented for each item in dropdown
// text represented for each item in dropdown
return
item
return
item
}
}
}
}
/>
/>
<
Text
>
Status
</
Text
>
<
Text
style
=
{
{
fontSize
:
20
,
marginBottom
:
5
}
}
>
Status
</
Text
>
<
SelectDropdown
<
SelectDropdown
buttonStyle
=
{
styles
.
DropdownFilter
}
buttonStyle
=
{
styles
.
DropdownFilter
}
defaultValue
=
{
"
All
"
}
defaultValue
=
{
"
All
"
}
data
=
{
[
"
All
"
,
"
Captured
"
,
"
Not captured
"
]
}
data
=
{
[
"
All
"
,
"
Captured
"
,
"
Not captured
"
]
}
onSelect
=
{
(
selectedItem
,
index
)
=>
{
onSelect
=
{
(
selectedItem
)
=>
{
handle
CapturedChange
(
selectedItem
)
CapturedChange
(
selectedItem
)
}
}
}
}
buttonTextAfterSelection
=
{
(
selectedItem
,
index
)
=>
{
buttonTextAfterSelection
=
{
(
selectedItem
)
=>
{
// text represented after item is selected
return
selectedItem
return
selectedItem
}
}
}
}
rowTextForSelection
=
{
(
item
,
index
)
=>
{
rowTextForSelection
=
{
(
item
)
=>
{
// text represented for each item in dropdown
return
item
return
item
}
}
}
}
/>
/>
<
SearchBar
/>
<
TextInput
style
=
{
styles
.
searchBox
}
placeholder
=
{
"
Search Pokemons
"
}
value
=
{
searchTextValue
}
onChangeText
=
{
(
value
)
=>
SearchChange
(
value
)
}
></
TextInput
>
</
View
>
</
View
>
</
View
>
</
View
>
...
@@ -101,8 +122,7 @@ const styles = StyleSheet.create ({
...
@@ -101,8 +122,7 @@ const styles = StyleSheet.create ({
imgContainer
:
{
imgContainer
:
{
flex
:
1
,
flex
:
1
,
alignItems
:
"
center
"
,
alignItems
:
"
center
"
,
paddingBottom
:
15
,
margin
:
5
paddingTop
:
5
},
},
pokemonImg
:
{
pokemonImg
:
{
...
@@ -113,8 +133,8 @@ const styles = StyleSheet.create ({
...
@@ -113,8 +133,8 @@ const styles = StyleSheet.create ({
},
},
filtering
Sorting
Container
:
{
filteringContainer
:
{
b
ackgroundColor
:
"
#1E90FFFF
"
,
b
orderColor
:
"
black
"
,
maxWidth
:
"
100%
"
,
maxWidth
:
"
100%
"
,
minWidth
:
"
85%
"
,
minWidth
:
"
85%
"
,
flex
:
1
,
flex
:
1
,
...
@@ -123,10 +143,22 @@ const styles = StyleSheet.create ({
...
@@ -123,10 +143,22 @@ const styles = StyleSheet.create ({
},
},
DropdownFilter
:
{
DropdownFilter
:
{
marginBottom
:
5
,
marginBottom
:
5
,
borderColor
:
"
gray
"
,
borderColor
:
"
black
"
,
borderWidth
:
0.3
,
borderWidth
:
0.3
,
borderRadius
:
10
,
borderRadius
:
10
,
width
:
300
width
:
300
},
searchBox
:
{
borderColor
:
"
black
"
,
width
:
"
50%
"
,
borderWidth
:
0.3
,
borderRadius
:
10
,
padding
:
10
,
marginTop
:
10
,
marginBottom
:
10
,
backgroundColor
:
"
#FFE
"
,
height
:
50
,
textAlign
:
'
center
'
}
}
})
})
...
...
This diff is collapsed.
Click to expand it.
components/SearchBar.tsx
deleted
100644 → 0
+
0
−
47
View file @
cb331ee0
import
React
from
"
react
"
import
{
StyleSheet
,
TextInput
}
from
"
react-native
"
;
import
{
useRecoilState
}
from
"
recoil
"
;
import
{
searchState
}
from
"
../atoms/atoms
"
;
export
const
SearchBar
=
()
=>
{
const
[
searchText
,
setSearchText
]
=
useRecoilState
(
searchState
)
const
handleSearchChange
=
(
value
:
React
.
SetStateAction
<
string
>
)
=>
{
setSearchText
(
value
)
};
return
(
<
TextInput
style
=
{
styles
.
searchBar
}
placeholder
=
{
"
Search Pokemons
"
}
textAlign
=
{
'
center
'
}
value
=
{
searchText
}
onChangeText
=
{
(
value
)
=>
handleSearchChange
(
value
)
}
></
TextInput
>
)
}
const
styles
=
StyleSheet
.
create
({
searchBar
:
{
borderColor
:
"
gray
"
,
width
:
"
50%
"
,
borderWidth
:
0.3
,
borderRadius
:
10
,
padding
:
10
,
marginTop
:
10
,
marginBottom
:
10
,
backgroundColor
:
"
#FFE
"
,
height
:
50
}
})
export
default
SearchBar
\ No newline at end of file
This diff is collapsed.
Click to expand it.
containers/PokemonsContainer.tsx
+
22
−
22
View file @
d78d9864
...
@@ -14,7 +14,8 @@ export const PokemonsContainer = () => {
...
@@ -14,7 +14,8 @@ export const PokemonsContainer = () => {
const
searchText
=
useRecoilValue
(
searchState
)
const
searchText
=
useRecoilValue
(
searchState
)
const
typeText
=
useRecoilValue
(
typeState
)
const
typeText
=
useRecoilValue
(
typeState
)
const
capturedState
=
useRecoilValue
(
capturedFilterState
)
const
capturedState
=
useRecoilValue
(
capturedFilterState
)
const
limit
=
14
const
[
limit
,
setLimit
]
=
useState
(
15
)
const
[
skip
,
setSkip
]
=
useState
(
0
)
const
[
skip
,
setSkip
]
=
useState
(
0
)
const
{
loading
,
data
}
=
useQuery
(
SEARCH_POKEMONS
,
{
const
{
loading
,
data
}
=
useQuery
(
SEARCH_POKEMONS
,
{
...
@@ -30,21 +31,24 @@ export const PokemonsContainer = () => {
...
@@ -30,21 +31,24 @@ export const PokemonsContainer = () => {
}
}
})
})
const
handlePaginationButton
=
(
newPage
:
string
)
=>
{
const
updateLabelAndSkip
=
(
prevOrNext
:
string
)
=>
{
if
(
newPage
===
'
prev
'
){
setSkip
(
skip
-
14
)
if
(
prevOrNext
===
"
next
"
){
setSkip
(
skip
+
15
)
}
else
{
}
else
{
setSkip
(
skip
+
1
4
)
setSkip
(
skip
-
1
5
)
}
}
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
setSkip
(
0
)
setSkip
(
0
)
setLimit
(
15
)
},
[
searchText
,
typeText
,
capturedState
])
},
[
searchText
,
typeText
,
capturedState
])
if
(
loading
){
if
(
loading
){
return
(
return
(
<
Text
>
LOADING
..
</
Text
>
<
Text
>
Please wait
..
</
Text
>
)
)
}
else
if
(
data
.
searchPokemon
===
0
)
{
}
else
if
(
data
.
searchPokemon
===
0
)
{
<
Text
>
No
matches
for
this
search
<
/Text
>
<
Text
>
No
matches
for
this
search
<
/Text
>
...
@@ -59,19 +63,15 @@ export const PokemonsContainer = () => {
...
@@ -59,19 +63,15 @@ export const PokemonsContainer = () => {
<
View
style
=
{
styles
.
paginationContainers
}
>
<
View
style
=
{
styles
.
paginationContainers
}
>
{
skip
>=
14
&&
data
.
searchPokemon
.
length
>=
4
&&
{
<
TouchableOpacity
style
=
{
styles
.
paginationButtonPrevPage
}
onPress
=
{
()
=>
handlePaginationButton
(
"
prev
"
)
}
>
skip
>=
15
&&
<
Image
<
TouchableOpacity
style
=
{
styles
.
ButtonPrevTouch
}
onPress
=
{
()
=>
updateLabelAndSkip
(
"
prev
"
)
}
>
style
=
{
styles
.
prevButton
}
<
Image
style
=
{
styles
.
prevButton
}
source
=
{
require
(
'
../resources/button.png
'
)
}
/>
source
=
{
require
(
'
../resources/button.png
'
)
}
/>
</
TouchableOpacity
>
}
</
TouchableOpacity
>
}
{
data
.
searchPokemon
.
length
>=
14
&&
{
<
TouchableOpacity
style
=
{
styles
.
paginationButtonNextPage
}
onPress
=
{
()
=>
handlePaginationButton
(
"
next
"
)
}
>
data
.
searchPokemon
.
length
>=
15
&&
<
Image
<
TouchableOpacity
style
=
{
styles
.
ButtonNextTouch
}
onPress
=
{
()
=>
updateLabelAndSkip
(
"
next
"
)
}
>
style
=
{
styles
.
nextButton
}
<
Image
style
=
{
styles
.
nextButton
}
source
=
{
require
(
'
../resources/button.png
'
)
}
/>
source
=
{
require
(
'
../resources/button.png
'
)
}
/>
</
TouchableOpacity
>
}
</
TouchableOpacity
>
}
</
View
>
</
View
>
...
@@ -104,13 +104,13 @@ const styles = StyleSheet.create({
...
@@ -104,13 +104,13 @@ const styles = StyleSheet.create({
height
:
"
100%
"
height
:
"
100%
"
},
},
pagination
ButtonNext
Page
:
{
ButtonNext
Touch
:
{
width
:
50
,
width
:
50
,
height
:
50
,
height
:
50
,
color
:
"
white
"
color
:
"
white
"
},
},
pagination
ButtonPrev
Page
:
{
ButtonPrev
Touch
:
{
width
:
50
,
width
:
50
,
height
:
50
,
height
:
50
,
color
:
"
white
"
,
color
:
"
white
"
,
...
...
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