Skip to content

Commit 1c2b46d

Browse files
committed
English Comments to Components
1 parent 69b0576 commit 1c2b46d

File tree

6 files changed

+159
-60
lines changed

6 files changed

+159
-60
lines changed

src/components/common/CustomButtonDock.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@ import React from 'react';
22
import { View, StyleSheet, Platform } from 'react-native';
33
import { colors, paddings } from '../../style';
44

5+
/**
6+
* CustomButtonDock Component
7+
* A container component that displays buttons in a docked position at the bottom of the screen.
8+
* Supports both vertical and horizontal button layouts.
9+
*
10+
* @param {string} direction - Layout direction for buttons: "vertical" or "horizontal"
11+
* @param {React.ReactNode} firstButton - The first button component to display
12+
* @param {React.ReactNode} secondButton - The second button component to display
13+
*/
514
const CustomButtonDock = ({ direction = "vertical", firstButton, secondButton }) => {
615
return (
716
<View style={styles.overlay} pointerEvents="box-none">
817
<View style={styles.bottomContainer} pointerEvents="box-none">
918
<View style={[styles.dock, direction === "horizontal" ? styles.horizontal : styles.vertical]}>
1019
{firstButton && (
11-
<View style={[styles.buttonWrapper, direction === "horizontal" && { flex: 1 }]}>
20+
<View style={[direction === "horizontal" && { flex: 1 }]}>
1221
{firstButton}
1322
</View>
1423
)}
1524
{secondButton && (
16-
<View style={[styles.buttonWrapper, direction === "horizontal" && { flex: 1 }]}>
25+
<View style={[direction === "horizontal" && { flex: 1 }]}>
1726
{secondButton}
1827
</View>
1928
)}
@@ -23,6 +32,7 @@ const CustomButtonDock = ({ direction = "vertical", firstButton, secondButton })
2332
);
2433
};
2534

35+
// Styles for the dock container and button layout
2636
const styles = StyleSheet.create({
2737
overlay: {
2838
position: 'absolute',
@@ -36,7 +46,6 @@ const styles = StyleSheet.create({
3646
flex: 1,
3747
justifyContent: 'flex-end',
3848
pointerEvents: 'box-none',
39-
4049
},
4150
dock: {
4251
backgroundColor: colors.white,
@@ -53,9 +62,6 @@ const styles = StyleSheet.create({
5362
vertical: {
5463
flexDirection: 'column',
5564
},
56-
buttonWrapper: {
57-
58-
},
5965
});
6066

6167
export default CustomButtonDock;

src/components/common/CustomButtonIcon.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { Text, StyleSheet, View, Pressable } from "react-native";
33
import { colors, paddings, rounded, textStyles } from '../../style';
44
import LoadingDots from "../../animations/LoadingDots";
55

6+
/**
7+
* Style configurations for different button types
8+
* Defines background colors, text colors, and border styles for each button type
9+
*/
610
const typeStyles = {
711
primary: { backgroundColor: colors.violet500, textColor: colors.white },
812
secondary: { backgroundColor: colors.grey800, textColor: colors.white },
@@ -14,6 +18,10 @@ const typeStyles = {
1418
},
1519
};
1620

21+
/**
22+
* Style configurations for different button states
23+
* Defines how buttons appear in different states: default, hover, pressed, disabled, loading
24+
*/
1725
const stateStyles = {
1826
default: {
1927
primary: { backgroundColor: colors.violet500 },
@@ -34,7 +42,6 @@ const stateStyles = {
3442
primary: { backgroundColor: colors.grey100, textColor: colors.grey600 },
3543
secondary: { backgroundColor: colors.grey100, textColor: colors.grey600 },
3644
tertiary: { backgroundColor: colors.white, textColor: colors.grey500, borderColor: colors.grey500, borderWidth: 1 },
37-
3845
},
3946
loading: {
4047
primary: { backgroundColor: colors.violet500 },
@@ -43,13 +50,24 @@ const stateStyles = {
4350
},
4451
};
4552

53+
/**
54+
* Style configurations for different button sizes
55+
* Defines height and padding for each size variant
56+
*/
4657
const sizeStyles = {
4758
1: { height: 32, padding: paddings.p_4 },
4859
2: { height: 40, padding: paddings.p_8 },
4960
3: { height: 48, padding: paddings.p_12 },
5061
4: { height: 56, padding: paddings.p_16 },
5162
};
5263

64+
/**
65+
* Combines styles based on button type, state, and size
66+
* @param {string} type - Button type (primary, secondary, tertiary)
67+
* @param {string} state - Button state (default, hover, pressed, disabled, loading)
68+
* @param {number} size - Button size (1-4)
69+
* @returns {Object} Combined style object
70+
*/
5371
const getCombinedStyles = (type, state, size) => {
5472
const typeStyle = typeStyles[type];
5573
const stateStyle = stateStyles[state]?.[type];
@@ -62,6 +80,17 @@ const getCombinedStyles = (type, state, size) => {
6280
};
6381
};
6482

83+
/**
84+
* CustomButtonIcon Component
85+
* A button component that displays an icon with configurable styles and states
86+
*
87+
* @param {Object} containerStyle - Custom styles for the button container
88+
* @param {Function} onPress - Function to call when button is pressed
89+
* @param {string} type - Button type: "primary", "secondary", or "tertiary"
90+
* @param {number} size - Button size: 1 (smallest) to 4 (largest)
91+
* @param {React.ReactNode} icon - Icon component to display
92+
* @param {boolean} disabled - Whether the button is disabled
93+
*/
6594
const CustomButtonIcon = ({
6695
containerStyle,
6796
onPress,
@@ -74,6 +103,7 @@ const CustomButtonIcon = ({
74103
const state = disabled ? 'disabled' : buttonState;
75104
const combinedStyles = getCombinedStyles(type, state, size);
76105

106+
// Handle button press events
77107
const handlePressIn = () => {
78108
if (!disabled) {
79109
setButtonState('pressed');
@@ -111,13 +141,13 @@ const CustomButtonIcon = ({
111141
]}
112142
onPress={handlePress}
113143
onPressIn={handlePressIn}
114-
onPressOut={handlePressOut}
144+
onPressOut={handlePressOut}
115145
disabled={disabled}
116-
>
117-
<View style={styles.contentContainer}>
118-
{icon && <View style={styles.icon}>{icon}</View>}
119-
</View>
120-
</Pressable>
146+
>
147+
<View style={styles.contentContainer}>
148+
{icon && <View style={styles.icon}>{icon}</View>}
149+
</View>
150+
</Pressable>
121151
);
122152
};
123153

src/components/common/CustomCard.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ import * as React from "react";
22
import { Image, Pressable, StyleSheet, Text, View } from "react-native";
33
import { colors, paddings, rounded, textStyles } from "../../style";
44

5+
/**
6+
* CustomCard Component
7+
* A versatile card component that can be used to display content with an icon, title, and description.
8+
*/
59
const CustomCard = ({
6-
iconSource = {},
7-
title,
8-
description,
9-
size = "md", // "md" oder "lg"
10-
state = "default", // State: "active", "default" oder "disabled"
11-
showDescription = true, // Standardmäßig aktiv
12-
onPress
10+
iconSource = {}, // Icon source - can be an image or React component
11+
title, // Card title
12+
description, // Card description
13+
size = "md", // Card size: "md" (medium) or "lg" (large)
14+
state = "default", // Card state: "active", "default", or "disabled"
15+
showDescription = true, // Whether to show the description
16+
onPress // Function to call when card is pressed
1317
}) => {
14-
// Bestimme den Container-Stil:
15-
// Im active-Zustand wird der aktive Style genutzt,
16-
// In default und disabled wird der Container-Style wie bei disabled angewandt.
18+
// Determine container style based on state and size
19+
// For active state, use active style; for default and disabled states, use disabled style
1720
const containerStyle =
1821
state === "active"
1922
? size === "md"
@@ -23,18 +26,15 @@ const CustomCard = ({
2326
? styles.cardMdDisabled
2427
: [styles.cardLgDisabled, !showDescription && { height: 92}];
2528

26-
// Beim Text: Nur im disabled-Zustand wird durchgestrichen.
29+
// Apply text styles - strikethrough for disabled state only
2730
const titleStyle = [styles.title, state === "disabled" && styles.strikeThroughText];
2831
const descriptionStyle = [styles.description, state === "disabled" && styles.strikeThroughText];
29-
30-
// Text-Wrapper (für md bzw. lg)
32+
// Text wrapper styles for medium and large sizes
3133
const textWrapperStyle = size === "md" ? styles.textWrapperMd : styles.textWrapperLg;
32-
33-
// Icon: Falls iconSource ein React-Element ist, setzen wir per cloneElement die Farbe auf Schwarz.
34+
// Handle icon - if iconSource is a React element, clone it and set color to black
3435
const iconElement = React.isValidElement(iconSource)
3536
? React.cloneElement(iconSource, { color: colors.black })
3637
: iconSource;
37-
3838
return (
3939
<Pressable style={containerStyle} onPress={onPress}>
4040
<View style={[styles.iconContainer, size === "lg" && { alignSelf: "flex-start" }]}>
@@ -56,7 +56,7 @@ const CustomCard = ({
5656

5757
const styles = StyleSheet.create({
5858
// -------------------------------
59-
// Active Styles (voll aktiv)
59+
// Active Styles
6060
// -------------------------------
6161
cardMdContainer: {
6262
gap: paddings.p_12,
@@ -84,10 +84,10 @@ const styles = StyleSheet.create({
8484
borderColor: colors.black,
8585
},
8686
// -------------------------------
87-
// Disabled Styles (wie bisher)
87+
// Disabled Styles
8888
// -------------------------------
89-
// (Sowohl für default als auch disabled wird hier der Container-Stil genutzt –
90-
// der Unterschied zeigt sich nur beim Text: bei disabled wird der Text durchgestrichen.)
89+
// Used for both default and disabled states
90+
// The only difference is text strikethrough in disabled state
9191
cardMdDisabled: {
9292
gap: paddings.p_12,
9393
padding: paddings.p_12,
@@ -112,7 +112,6 @@ const styles = StyleSheet.create({
112112
height: 112,
113113
borderWidth: 1,
114114
borderColor: colors.grey200,
115-
116115
},
117116
// -------------------------------
118117
// Icon-Container
@@ -147,7 +146,7 @@ const styles = StyleSheet.create({
147146
overflow: "hidden",
148147
alignSelf: "stretch",
149148
},
150-
// Durchgestrichener Text (nur im disabled-Zustand angewandt)
149+
// Strikethrough text (only applied in the disabled state)
151150
strikeThroughText: {
152151
textDecorationLine: "line-through",
153152
color: colors.grey500,

0 commit comments

Comments
 (0)