themed-button, themed-mapview, selectChantier maj
This commit is contained in:
37
components/themed-button.tsx
Normal file
37
components/themed-button.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Pressable, type PressableProps } from 'react-native';
|
||||
|
||||
import { useThemeColor } from '@/hooks/use-theme-color';
|
||||
|
||||
export type ThemedPressableProps = PressableProps & {
|
||||
lightColor?: string;
|
||||
darkColor?: string;
|
||||
lvl?:number;
|
||||
border?:number;
|
||||
};
|
||||
|
||||
export function ThemedButton({ style, lightColor, darkColor,lvl=1,border=-1, ...otherProps }: ThemedPressableProps) {
|
||||
var lvlStr:string = "background";
|
||||
var borderColor ="";
|
||||
if(lvl>=0 && lvl<6){
|
||||
lvlStr+=lvl;
|
||||
}
|
||||
else lvlStr+='5';
|
||||
|
||||
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor },lvlStr as 'background0'|'background1'|'background2'|'background3'|'background4'|'background5');
|
||||
|
||||
|
||||
if(border!=-1){
|
||||
var borderStr = "";
|
||||
if(border>=0 && border<6){
|
||||
borderStr="background"+border;
|
||||
borderColor = useThemeColor({ light: lightColor, dark: darkColor },borderStr as 'background0'|'background1'|'background2'|'background3'|'background4'|'background5');
|
||||
}
|
||||
else{
|
||||
borderColor = backgroundColor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return <Pressable style={(state) =>[{ backgroundColor, borderColor }, typeof style === 'function' ? style(state) : style,]} {...otherProps}/>;
|
||||
}
|
||||
Reference in New Issue
Block a user