Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810 H21
Team 05
prosjekt4
Commits
13221fcd
Commit
13221fcd
authored
Nov 18, 2021
by
Simen Kristoffersen
Browse files
Endret fargetema for ToggleButton
parent
5396b37a
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/ToggleButton.tsx
View file @
13221fcd
import
React
from
"
react
"
;
import
{
useState
}
from
"
react
"
;
import
{
StyleSheet
,
ViewStyle
}
from
"
react-native
"
;
import
{
TouchableOpacity
}
from
"
react-native
"
;
import
{
useThemeColor
}
from
"
./common/Themed
"
;
import
glyphmap
from
"
@expo/vector-icons/build/MaterialIcons
"
;
import
MaterialIcons
from
"
@expo/vector-icons/build/MaterialIcons
"
;
import
React
from
'
react
'
;
import
{
useState
}
from
'
react
'
;
import
{
StyleSheet
,
ViewStyle
}
from
'
react-native
'
;
import
{
TouchableOpacity
}
from
'
react-native
'
;
import
{
useThemeColor
}
from
'
./common/Themed
'
;
import
glyphmap
from
'
@expo/vector-icons/build/MaterialIcons
'
;
import
MaterialIcons
from
'
@expo/vector-icons/build/MaterialIcons
'
;
type
IconMap
=
typeof
glyphmap
.
glyphMap
;
...
...
@@ -29,16 +29,22 @@ const ToggleButton: React.FC<IProps> = (props: IProps) => {
styles
.
button
,
props
.
style
,
{
backgroundColor
:
useThemeColor
({},
"
comp
lem
ent
"
),
borderColor
:
useThemeColor
({},
"
border
"
),
backgroundColor
:
useThemeColor
({},
'
comp
on
ent
'
),
borderColor
:
useThemeColor
({},
'
border
'
),
},
]
}
onPress
=
{
()
=>
handleClick
()
}
>
{
toggled
?
(
<
MaterialIcons
name
=
{
props
.
activeIcon
}
style
=
{
styles
.
icon
}
/>
<
MaterialIcons
name
=
{
props
.
activeIcon
}
style
=
{
[
styles
.
icon
,
{
color
:
useThemeColor
({},
'
inputText
'
)
}]
}
/>
)
:
(
<
MaterialIcons
name
=
{
props
.
inactiveIcon
}
style
=
{
styles
.
icon
}
/>
<
MaterialIcons
name
=
{
props
.
inactiveIcon
}
style
=
{
[
styles
.
icon
,
{
color
:
useThemeColor
({},
'
inputText
'
)
}]
}
/>
)
}
</
TouchableOpacity
>
);
...
...
@@ -51,11 +57,11 @@ const styles = StyleSheet.create({
borderWidth
:
1
,
borderRadius
:
15
,
paddingBottom
:
1
,
alignItems
:
"
center
"
,
justifyContent
:
"
center
"
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
},
icon
:
{
color
:
"
#fefefe
"
,
color
:
'
#fefefe
'
,
paddingVertical
:
0
,
marginVertical
:
0
,
fontSize
:
20
,
...
...
constants/Colors.ts
View file @
13221fcd
const
tintColorLight
=
"
#2f95dc
"
;
const
tintColorDark
=
"
#fff
"
;
const
tintColorLight
=
'
#2f95dc
'
;
const
tintColorDark
=
'
#fff
'
;
export
default
{
light
:
{
text
:
"
#000
"
,
inputText
:
"
#333
"
,
background
:
"
#fff
"
,
component
:
"
rgb(240, 240, 240)
"
,
border
:
"
rgb(221, 221, 221)
"
,
complement
:
"
#177ddc
"
,
text
:
'
#000
'
,
inputText
:
'
#333
'
,
background
:
'
#fff
'
,
component
:
'
rgb(240, 240, 240)
'
,
border
:
'
rgb(221, 221, 221)
'
,
complement
:
'
#177ddc
'
,
tint
:
tintColorLight
,
tabIconDefault
:
"
#ccc
"
,
tabIconDefault
:
'
#ccc
'
,
tabIconSelected
:
tintColorLight
,
},
dark
:
{
text
:
"
#fff
"
,
inputText
:
"
rgb(220, 220, 220)
"
,
background
:
"
#000
"
,
component
:
"
rgb(18, 18, 18)
"
,
border
:
"
rgb(39, 39, 41)
"
,
complement
:
"
#177ddc
"
,
text
:
'
#fff
'
,
inputText
:
'
rgb(220, 220, 220)
'
,
background
:
'
#000
'
,
component
:
'
rgb(18, 18, 18)
'
,
border
:
'
rgb(39, 39, 41)
'
,
complement
:
'
#177ddc
'
,
tint
:
tintColorDark
,
tabIconDefault
:
"
#ccc
"
,
tabIconDefault
:
'
#ccc
'
,
tabIconSelected
:
tintColorDark
,
},
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment