Skip to content

Commit 217df1e

Browse files
committed
fix tag logic
1 parent 1b1ce8b commit 217df1e

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

examples/demo/src/components/ListWidgets.tsx

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ import { Colors, AppTheme } from '../theme';
77
interface PairItemProps {
88
itemKey: string;
99
itemValue: string;
10+
layout?: 'inline' | 'stacked';
1011
onDelete?: () => void;
1112
testID?: string;
1213
}
1314

14-
export function PairItem({ itemKey, itemValue, onDelete, testID }: PairItemProps) {
15+
export function PairItem({
16+
itemKey,
17+
itemValue,
18+
layout = 'inline',
19+
onDelete,
20+
testID,
21+
}: PairItemProps) {
1522
return (
1623
<View style={styles.pairRow} testID={testID}>
17-
<Text style={styles.pairKey} numberOfLines={1}>{itemKey}</Text>
18-
<Text style={styles.pairSeparator}>|</Text>
19-
<Text style={styles.pairValue} numberOfLines={1}>{itemValue}</Text>
24+
{layout === 'stacked' ? (
25+
<View style={styles.pairStackedContent}>
26+
<Text style={styles.pairStackedKey} numberOfLines={1}>{itemKey}</Text>
27+
<Text style={styles.pairStackedValue} numberOfLines={1}>{itemValue}</Text>
28+
</View>
29+
) : (
30+
<>
31+
<Text style={styles.pairKey} numberOfLines={1}>{itemKey}</Text>
32+
<Text style={styles.pairSeparator}>|</Text>
33+
<Text style={styles.pairValue} numberOfLines={1}>{itemValue}</Text>
34+
</>
35+
)}
2036
{onDelete && (
2137
<TouchableOpacity onPress={onDelete} hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}>
2238
<Icon name="close" size={18} color={Colors.textSecondary} />
@@ -63,11 +79,12 @@ export function EmptyState({ message, testID }: EmptyStateProps) {
6379
// PairList (simple, no collapse)
6480
interface PairListProps {
6581
items: [string, string][];
82+
layout?: 'inline' | 'stacked';
6683
onDelete?: (key: string) => void;
6784
filterKeys?: string[];
6885
}
6986

70-
export function PairList({ items, onDelete, filterKeys }: PairListProps) {
87+
export function PairList({ items, layout = 'inline', onDelete, filterKeys }: PairListProps) {
7188
const filtered = filterKeys
7289
? items.filter(([k]) => !filterKeys.includes(k))
7390
: items;
@@ -84,6 +101,7 @@ export function PairList({ items, onDelete, filterKeys }: PairListProps) {
84101
<PairItem
85102
itemKey={k}
86103
itemValue={v}
104+
layout={layout}
87105
onDelete={onDelete ? () => onDelete(k) : undefined}
88106
testID={`pair_item_${idx}`}
89107
/>
@@ -143,6 +161,20 @@ const styles = StyleSheet.create({
143161
alignItems: 'center',
144162
paddingVertical: 8,
145163
},
164+
pairStackedContent: {
165+
flex: 1,
166+
marginRight: 8,
167+
},
168+
pairStackedKey: {
169+
fontSize: 15,
170+
color: Colors.textPrimary,
171+
fontWeight: '500',
172+
marginBottom: 2,
173+
},
174+
pairStackedValue: {
175+
fontSize: 14,
176+
color: Colors.textSecondary,
177+
},
146178
pairKey: {
147179
flex: 1,
148180
fontSize: 14,

examples/demo/src/components/sections/TagsSection.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export default function TagsSection({
3535
</View>
3636
) : (
3737
<View style={styles.listCard}>
38-
<PairList items={tags} />
38+
<PairList
39+
items={tags}
40+
layout="stacked"
41+
onDelete={(key) => onRemoveSelected([key])}
42+
/>
3943
</View>
4044
)}
4145
<ActionButton label="ADD" onPress={() => setAddVisible(true)} testID="add_tag_button" />

0 commit comments

Comments
 (0)