mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 06:49:40 +02:00
- Add uload project with apps/web structure
- Reorganize from flat to monorepo structure
- Remove PocketBase binary and local data
- Update to pnpm and @uload/web namespace
- Add picture project to monorepo
- Remove embedded git repository
- Unify all package names to @{project}/{app} schema:
- @maerchenzauber/* (was @storyteller/*)
- @manacore/* (was manacore-*, manacore)
- @manadeck/* (was web, backend, manadeck)
- @memoro/* (was memoro-web, landing, memoro)
- @picture/* (already unified)
- @uload/web
- Add convenient dev scripts for all apps:
- pnpm dev:{project}:web
- pnpm dev:{project}:landing
- pnpm dev:{project}:mobile
- pnpm dev:{project}:backend
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
212 lines
5.8 KiB
TypeScript
212 lines
5.8 KiB
TypeScript
import React, { ReactNode, useState } from 'react';
|
|
import { View, ScrollView, ActivityIndicator, TouchableOpacity } from 'react-native';
|
|
import { Ionicons } from '@expo/vector-icons';
|
|
import { Text } from './Text';
|
|
import { Button } from './Button';
|
|
import { useTheme } from '~/contexts/ThemeContext';
|
|
|
|
export type OptionItem = {
|
|
id: string;
|
|
label: string;
|
|
subtitle?: string;
|
|
icon?: string;
|
|
description?: string;
|
|
};
|
|
|
|
type OptionSelectorProps = {
|
|
options: OptionItem[];
|
|
selectedId: string | null;
|
|
onSelect: (option: OptionItem) => void;
|
|
loading?: boolean;
|
|
error?: string | null;
|
|
onRetry?: () => void;
|
|
disabled?: boolean;
|
|
minWidth?: number;
|
|
title?: string;
|
|
};
|
|
|
|
export function OptionSelector({
|
|
options,
|
|
selectedId,
|
|
onSelect,
|
|
loading = false,
|
|
error = null,
|
|
onRetry,
|
|
disabled = false,
|
|
minWidth = 160,
|
|
title,
|
|
}: OptionSelectorProps) {
|
|
const { theme } = useTheme();
|
|
const [showInfo, setShowInfo] = useState(false);
|
|
|
|
// Loading state
|
|
if (loading) {
|
|
return (
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
padding: 20,
|
|
backgroundColor: theme.colors.surface,
|
|
borderRadius: 12,
|
|
}}
|
|
>
|
|
<ActivityIndicator size="small" color={theme.colors.primary.default} />
|
|
<Text variant="body" color="secondary" style={{ marginLeft: 12 }}>
|
|
Lade...
|
|
</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
// Error state
|
|
if (error || options.length === 0) {
|
|
return (
|
|
<View
|
|
style={{
|
|
padding: 20,
|
|
backgroundColor: theme.colors.surface,
|
|
borderRadius: 12,
|
|
alignItems: 'center',
|
|
}}
|
|
>
|
|
<Text variant="body" color="tertiary" align="center">
|
|
{error || 'Keine Optionen verfügbar'}
|
|
</Text>
|
|
{onRetry && (
|
|
<Button
|
|
title="Erneut laden"
|
|
onPress={onRetry}
|
|
size="sm"
|
|
variant="secondary"
|
|
style={{ marginTop: 12 }}
|
|
/>
|
|
)}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
// Find selected option for description
|
|
const selectedOption = options.find(opt => opt.id === selectedId);
|
|
|
|
// Check if any option has subtitle or description
|
|
const hasDetails = options.some(opt => opt.subtitle || opt.description);
|
|
|
|
// Success state - show options
|
|
return (
|
|
<View>
|
|
{/* Header with Title and Info Icon */}
|
|
{(title || hasDetails) && (
|
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
|
|
{title && (
|
|
<Text variant="body" weight="semibold" color="primary">
|
|
{title}
|
|
</Text>
|
|
)}
|
|
{hasDetails && (
|
|
<TouchableOpacity
|
|
onPress={() => setShowInfo(!showInfo)}
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
padding: 4,
|
|
}}
|
|
>
|
|
<Ionicons
|
|
name={showInfo ? 'information-circle' : 'information-circle-outline'}
|
|
size={24}
|
|
color={theme.colors.text.secondary}
|
|
/>
|
|
<Text variant="body" color="secondary" style={{ marginLeft: 4 }}>
|
|
{showInfo ? 'Info ausblenden' : 'Info'}
|
|
</Text>
|
|
</TouchableOpacity>
|
|
)}
|
|
</View>
|
|
)}
|
|
|
|
<ScrollView
|
|
horizontal
|
|
showsHorizontalScrollIndicator={false}
|
|
style={{ marginHorizontal: -4 }}
|
|
>
|
|
{options.map((option) => {
|
|
const isSelected = selectedId === option.id;
|
|
|
|
return (
|
|
<TouchableOpacity
|
|
key={option.id}
|
|
onPress={() => !disabled && onSelect(option)}
|
|
disabled={disabled}
|
|
activeOpacity={0.7}
|
|
style={{
|
|
backgroundColor: isSelected
|
|
? theme.colors.primary.default
|
|
: theme.colors.surface,
|
|
borderWidth: 2,
|
|
borderColor: isSelected
|
|
? theme.colors.primary.default
|
|
: theme.colors.border,
|
|
borderRadius: 12,
|
|
padding: 16,
|
|
marginHorizontal: 4,
|
|
minWidth: minWidth,
|
|
opacity: disabled ? 0.5 : 1,
|
|
alignItems: 'center',
|
|
}}
|
|
>
|
|
{option.icon && (
|
|
<Text style={{ fontSize: 28, marginBottom: 8 }}>
|
|
{option.icon}
|
|
</Text>
|
|
)}
|
|
|
|
<Text
|
|
variant="body"
|
|
weight="semibold"
|
|
style={{
|
|
color: isSelected
|
|
? theme.colors.text.inverse
|
|
: theme.colors.text.primary,
|
|
marginBottom: showInfo && option.subtitle ? 4 : 0,
|
|
}}
|
|
numberOfLines={1}
|
|
>
|
|
{option.label}
|
|
</Text>
|
|
|
|
{showInfo && option.subtitle && (
|
|
<Text
|
|
variant="caption"
|
|
style={{
|
|
color: isSelected
|
|
? theme.colors.primary.light
|
|
: theme.colors.text.tertiary,
|
|
}}
|
|
>
|
|
{option.subtitle}
|
|
</Text>
|
|
)}
|
|
</TouchableOpacity>
|
|
);
|
|
})}
|
|
</ScrollView>
|
|
|
|
{showInfo && selectedOption?.description && (
|
|
<View
|
|
style={{
|
|
marginTop: 16,
|
|
padding: 16,
|
|
backgroundColor: theme.colors.surface,
|
|
borderRadius: 12,
|
|
}}
|
|
>
|
|
<Text variant="caption" color="secondary">
|
|
{selectedOption.description}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
</View>
|
|
);
|
|
}
|