chahinebrini 5d6c322129 wip: KeyboardAwareSheet migrations + Snake/Tetris UI + iron.png + useMe live-update
Sheets via neuer KeyboardAwareSheet-Composable (in Modal pattern, auto-grow
mit Tastatur, paddingBottom-Lift): EditMail, AddDomain, CreateRoom, ConnectMail.
GameOverScreen behält Spring-Slide-In, nutzt RN Keyboard.addListener für Lift.

- KeyboardAwareSheet.tsx — universal modal with sheet-grow + keyboard-padding
- react-native-keyboard-controller installiert + KeyboardProvider in Root
- Snake: time + ScoreProgressBar + useSnakeSounds (haptic, audio TODO)
- Tetris: title weg, Buttons zentriert, kein Pressable mit style-fn
- DPad-Buttons 60→48, more bg, no scale
- useMe: pub-sub listener pattern für app-weite avatar/nickname-Updates
- dm.tsx: resolveAvatar wrap (iron.png-Warning)
- Mail-error-humanizer + locales

Recovery-Doc-Update in docs/internal/RECOVERY_LOG_2026-05-10.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 23:59:25 +02:00

34 lines
1.2 KiB
TypeScript

import { useEffect, useState } from 'react';
import { Keyboard, Platform } from 'react-native';
/**
* Liefert die aktuelle Keyboard-Höhe in px (0 wenn versteckt).
*
* Pattern aus components/PostCommentsSheet.tsx — iOS nutzt `keyboardWillShow`
* für glatte Animation, Android `keyboardDidShow` weil iOS-Will-Events dort nicht feuern.
*
* Für Standard-Forms reicht `<KeyboardAdjustedView>` (das nutzt diesen Hook intern).
* Direkten Hook-Zugriff nur wenn man die Höhe selbst irgendwo einrechnen muss
* (z.B. SOS-Chat mit FlatList + Input-Bar im selben Layout).
*/
export function useKeyboardHeight(): number {
const [keyboardHeight, setKeyboardHeight] = useState(0);
useEffect(() => {
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
const showSub = Keyboard.addListener(showEvent, (e) => {
setKeyboardHeight(e.endCoordinates.height);
});
const hideSub = Keyboard.addListener(hideEvent, () => {
setKeyboardHeight(0);
});
return () => {
showSub.remove();
hideSub.remove();
};
}, []);
return keyboardHeight;
}