caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

133 lines
2.6 KiB
TypeScript

import React, { useEffect, useRef } from 'react';
import {
View,
Text,
StyleSheet,
Animated,
TouchableOpacity,
} from 'react-native';
import { Colors } from '../../constants/Colors';
interface ToastProps {
message: string;
type?: 'success' | 'error' | 'info';
duration?: number;
onClose?: () => void;
}
export default function Toast({
message,
type = 'info',
duration = 3000,
onClose,
}: ToastProps) {
const fadeAnim = useRef(new Animated.Value(0)).current;
const slideAnim = useRef(new Animated.Value(-100)).current;
useEffect(() => {
// Fade in and slide down
Animated.parallel([
Animated.timing(fadeAnim, {
toValue: 1,
duration: 300,
useNativeDriver: true,
}),
Animated.spring(slideAnim, {
toValue: 0,
useNativeDriver: true,
tension: 50,
friction: 7,
}),
]).start();
// Auto dismiss
const timer = setTimeout(() => {
dismiss();
}, duration);
return () => clearTimeout(timer);
}, []);
const dismiss = () => {
Animated.parallel([
Animated.timing(fadeAnim, {
toValue: 0,
duration: 200,
useNativeDriver: true,
}),
Animated.timing(slideAnim, {
toValue: -100,
duration: 200,
useNativeDriver: true,
}),
]).start(() => {
onClose?.();
});
};
const backgroundColor =
type === 'success'
? Colors.success
: type === 'error'
? Colors.error
: Colors.info;
return (
<Animated.View
style={[
styles.container,
{
opacity: fadeAnim,
transform: [{ translateY: slideAnim }],
},
]}
>
<View style={[styles.toast, { backgroundColor }]}>
<Text style={styles.message}>{message}</Text>
<TouchableOpacity onPress={dismiss} style={styles.closeButton}>
<Text style={styles.closeText}>✕</Text>
</TouchableOpacity>
</View>
</Animated.View>
);
}
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 50,
left: 0,
right: 0,
zIndex: 1000,
paddingHorizontal: 16,
},
toast: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
padding: 16,
borderRadius: 8,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
},
message: {
flex: 1,
color: Colors.text,
fontSize: 14,
fontWeight: '500',
},
closeButton: {
marginLeft: 12,
padding: 4,
},
closeText: {
color: Colors.text,
fontSize: 18,
fontWeight: 'bold',
},
});