feat: 로그인 화면 및 공통 속성 생성
This commit is contained in:
73
src/components/ui/Button.tsx
Normal file
73
src/components/ui/Button.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import React from "react";
|
||||
import { Pressable, type PressableProps, StyleSheet, View } from "react-native";
|
||||
import { Theme } from "../../theme/theme";
|
||||
import AppText from "./AppText";
|
||||
|
||||
type Props = PressableProps & {
|
||||
title: string;
|
||||
variant?: "primary" | "secondary";
|
||||
};
|
||||
|
||||
export default function Button({
|
||||
title,
|
||||
variant = "primary",
|
||||
style,
|
||||
...props
|
||||
}: Props) {
|
||||
const isPrimary = variant === "primary";
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
{...props}
|
||||
style={({ pressed }) => [
|
||||
styles.base,
|
||||
isPrimary ? styles.primary : styles.secondary,
|
||||
pressed &&
|
||||
(isPrimary ? styles.primaryPressed : styles.secondaryPressed),
|
||||
typeof style === "function" ? style({ pressed }) : style,
|
||||
]}
|
||||
>
|
||||
<View>
|
||||
<AppText
|
||||
style={{
|
||||
textAlign: "center",
|
||||
fontWeight: Theme.FontWeight.bold,
|
||||
color: isPrimary ? Theme.Colors.text : Theme.Colors.text,
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</AppText>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
base: {
|
||||
height: 48,
|
||||
paddingVertical: 0,
|
||||
paddingHorizontal: Theme.Spacing.lg,
|
||||
borderRadius: Theme.Radius.md,
|
||||
alignItems: "center", // 가로 가운데
|
||||
justifyContent: "center", // 세로 가운데
|
||||
},
|
||||
text: {
|
||||
textAlign: "center",
|
||||
fontWeight: Theme.FontWeight.bold,
|
||||
lineHeight: 20,
|
||||
},
|
||||
primary: {
|
||||
backgroundColor: Theme.Colors.primary,
|
||||
},
|
||||
primaryPressed: {
|
||||
backgroundColor: Theme.Colors.primaryPressed,
|
||||
},
|
||||
secondary: {
|
||||
backgroundColor: Theme.Colors.surface,
|
||||
borderWidth: 1,
|
||||
borderColor: Theme.Colors.border,
|
||||
},
|
||||
secondaryPressed: {
|
||||
opacity: 0.9,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user