| .. | .. |
|---|
| 8 | 8 | } from "react-native"; |
|---|
| 9 | 9 | import * as Haptics from "expo-haptics"; |
|---|
| 10 | 10 | import { VoiceButton } from "./VoiceButton"; |
|---|
| 11 | +import { useTheme } from "../../contexts/ThemeContext"; |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | interface InputBarProps { |
|---|
| 13 | 14 | onSendText: (text: string) => void; |
|---|
| 15 | + onVoiceRecorded: (uri: string) => void; |
|---|
| 14 | 16 | onReplay: () => void; |
|---|
| 15 | 17 | isTextMode: boolean; |
|---|
| 16 | 18 | onToggleMode: () => void; |
|---|
| 19 | + audioPlaying?: boolean; |
|---|
| 17 | 20 | } |
|---|
| 18 | 21 | |
|---|
| 19 | 22 | export function InputBar({ |
|---|
| 20 | 23 | onSendText, |
|---|
| 24 | + onVoiceRecorded, |
|---|
| 21 | 25 | onReplay, |
|---|
| 22 | 26 | isTextMode, |
|---|
| 23 | 27 | onToggleMode, |
|---|
| 28 | + audioPlaying = false, |
|---|
| 24 | 29 | }: InputBarProps) { |
|---|
| 25 | 30 | const [text, setText] = useState(""); |
|---|
| 26 | 31 | const inputRef = useRef<TextInput>(null); |
|---|
| 32 | + const { colors } = useTheme(); |
|---|
| 33 | + |
|---|
| 34 | + const canSend = !!text.trim(); |
|---|
| 27 | 35 | |
|---|
| 28 | 36 | const handleSend = useCallback(() => { |
|---|
| 29 | 37 | const trimmed = text.trim(); |
|---|
| .. | .. |
|---|
| 43 | 51 | paddingVertical: 10, |
|---|
| 44 | 52 | paddingBottom: 6, |
|---|
| 45 | 53 | borderTopWidth: 1, |
|---|
| 46 | | - borderTopColor: "#2E2E45", |
|---|
| 54 | + borderTopColor: colors.border, |
|---|
| 47 | 55 | alignItems: "center", |
|---|
| 48 | 56 | }} |
|---|
| 49 | 57 | > |
|---|
| 50 | | - {/* Replay last message */} |
|---|
| 58 | + {/* Replay / Stop */} |
|---|
| 51 | 59 | <Pressable |
|---|
| 52 | 60 | onPress={() => { |
|---|
| 53 | 61 | Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); |
|---|
| .. | .. |
|---|
| 61 | 69 | borderRadius: 34, |
|---|
| 62 | 70 | alignItems: "center", |
|---|
| 63 | 71 | justifyContent: "center", |
|---|
| 64 | | - backgroundColor: "#1A2E1A", |
|---|
| 72 | + backgroundColor: colors.bgTertiary, |
|---|
| 65 | 73 | borderWidth: 1.5, |
|---|
| 66 | | - borderColor: "#3A6A3A", |
|---|
| 74 | + borderColor: colors.border, |
|---|
| 67 | 75 | }} |
|---|
| 68 | 76 | > |
|---|
| 69 | | - <Text style={{ fontSize: 24 }}>▶</Text> |
|---|
| 70 | | - <Text style={{ color: "#8ABF8A", fontSize: 10, marginTop: 1, fontWeight: "600" }}>Replay</Text> |
|---|
| 77 | + <Text style={{ fontSize: 24 }}>{audioPlaying ? "\u23F8" : "\u25B6"}</Text> |
|---|
| 78 | + <Text style={{ color: colors.textSecondary, fontSize: 10, marginTop: 1, fontWeight: "600" }}> |
|---|
| 79 | + {audioPlaying ? "Stop" : "Replay"} |
|---|
| 80 | + </Text> |
|---|
| 71 | 81 | </View> |
|---|
| 72 | 82 | </Pressable> |
|---|
| 73 | 83 | |
|---|
| 74 | | - {/* Talk button — center, biggest */} |
|---|
| 84 | + {/* Talk button */} |
|---|
| 75 | 85 | <View style={{ flex: 1, alignItems: "center" }}> |
|---|
| 76 | | - <VoiceButton onTranscript={onSendText} /> |
|---|
| 86 | + <VoiceButton onVoiceRecorded={onVoiceRecorded} /> |
|---|
| 77 | 87 | </View> |
|---|
| 78 | 88 | |
|---|
| 79 | 89 | {/* Text mode toggle */} |
|---|
| .. | .. |
|---|
| 91 | 101 | borderRadius: 34, |
|---|
| 92 | 102 | alignItems: "center", |
|---|
| 93 | 103 | justifyContent: "center", |
|---|
| 94 | | - backgroundColor: "#1A1A3E", |
|---|
| 104 | + backgroundColor: colors.bgTertiary, |
|---|
| 95 | 105 | borderWidth: 1.5, |
|---|
| 96 | | - borderColor: "#3A3A7A", |
|---|
| 106 | + borderColor: colors.border, |
|---|
| 97 | 107 | }} |
|---|
| 98 | 108 | > |
|---|
| 99 | | - <Text style={{ fontSize: 22, color: "#9898D0", fontWeight: "700" }}>Aa</Text> |
|---|
| 109 | + <Text style={{ fontSize: 22, color: colors.textSecondary, fontWeight: "700" }}>Aa</Text> |
|---|
| 100 | 110 | </View> |
|---|
| 101 | 111 | </Pressable> |
|---|
| 102 | 112 | </View> |
|---|
| .. | .. |
|---|
| 112 | 122 | paddingHorizontal: 12, |
|---|
| 113 | 123 | paddingVertical: 8, |
|---|
| 114 | 124 | borderTopWidth: 1, |
|---|
| 115 | | - borderTopColor: "#2E2E45", |
|---|
| 125 | + borderTopColor: colors.border, |
|---|
| 116 | 126 | alignItems: "flex-end", |
|---|
| 117 | 127 | }} |
|---|
| 118 | 128 | > |
|---|
| .. | .. |
|---|
| 129 | 139 | borderRadius: 20, |
|---|
| 130 | 140 | alignItems: "center", |
|---|
| 131 | 141 | justifyContent: "center", |
|---|
| 132 | | - backgroundColor: "#1E1E2E", |
|---|
| 142 | + backgroundColor: colors.bgTertiary, |
|---|
| 133 | 143 | marginBottom: 2, |
|---|
| 134 | 144 | }} |
|---|
| 135 | 145 | > |
|---|
| 136 | | - <Text style={{ fontSize: 20 }}>🎤</Text> |
|---|
| 146 | + <Text style={{ fontSize: 20 }}>{"\uD83C\uDFA4"}</Text> |
|---|
| 137 | 147 | </Pressable> |
|---|
| 138 | 148 | |
|---|
| 139 | 149 | {/* Text input */} |
|---|
| .. | .. |
|---|
| 142 | 152 | value={text} |
|---|
| 143 | 153 | onChangeText={setText} |
|---|
| 144 | 154 | placeholder="Message PAI..." |
|---|
| 145 | | - placeholderTextColor="#5A5A78" |
|---|
| 155 | + placeholderTextColor={colors.textMuted} |
|---|
| 146 | 156 | multiline |
|---|
| 147 | 157 | maxLength={2000} |
|---|
| 148 | 158 | onSubmitEditing={handleSend} |
|---|
| .. | .. |
|---|
| 150 | 160 | blurOnSubmit |
|---|
| 151 | 161 | style={{ |
|---|
| 152 | 162 | flex: 1, |
|---|
| 153 | | - backgroundColor: "#1E1E2E", |
|---|
| 163 | + backgroundColor: colors.bgTertiary, |
|---|
| 154 | 164 | borderRadius: 20, |
|---|
| 155 | 165 | paddingHorizontal: 16, |
|---|
| 156 | 166 | paddingVertical: 10, |
|---|
| 157 | 167 | maxHeight: 120, |
|---|
| 158 | | - color: "#E8E8F0", |
|---|
| 168 | + color: colors.text, |
|---|
| 159 | 169 | fontSize: 16, |
|---|
| 160 | 170 | }} |
|---|
| 161 | 171 | /> |
|---|
| .. | .. |
|---|
| 163 | 173 | {/* Send button */} |
|---|
| 164 | 174 | <Pressable |
|---|
| 165 | 175 | onPress={handleSend} |
|---|
| 166 | | - disabled={!text.trim()} |
|---|
| 176 | + disabled={!canSend} |
|---|
| 167 | 177 | style={{ |
|---|
| 168 | 178 | width: 40, |
|---|
| 169 | 179 | height: 40, |
|---|
| .. | .. |
|---|
| 171 | 181 | alignItems: "center", |
|---|
| 172 | 182 | justifyContent: "center", |
|---|
| 173 | 183 | marginBottom: 2, |
|---|
| 174 | | - backgroundColor: text.trim() ? "#4A9EFF" : "#1E1E2E", |
|---|
| 184 | + backgroundColor: canSend ? colors.accent : colors.bgTertiary, |
|---|
| 175 | 185 | }} |
|---|
| 176 | 186 | > |
|---|
| 177 | 187 | <Text |
|---|
| 178 | 188 | style={{ |
|---|
| 179 | 189 | fontSize: 18, |
|---|
| 180 | 190 | fontWeight: "bold", |
|---|
| 181 | | - color: text.trim() ? "#FFFFFF" : "#5A5A78", |
|---|
| 191 | + color: canSend ? "#FFFFFF" : colors.textMuted, |
|---|
| 182 | 192 | }} |
|---|
| 183 | 193 | > |
|---|
| 184 | | - ↑ |
|---|
| 194 | + {"\u2191"} |
|---|
| 185 | 195 | </Text> |
|---|
| 186 | 196 | </Pressable> |
|---|
| 187 | 197 | </View> |
|---|