mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 23:45:21 +00:00
handle glitch on text input after send
This commit is contained in:
parent
4c947fdd9c
commit
0cab8f0c1c
@ -10,7 +10,6 @@ export const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
avoid: {
|
avoid: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '30%',
|
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
},
|
},
|
||||||
closeIcon: {
|
closeIcon: {
|
||||||
|
@ -75,6 +75,7 @@ export function Conversation({close, openDetails, wide}: {close: ()=>void, openD
|
|||||||
busy.current = true;
|
busy.current = true;
|
||||||
setSending(true);
|
setSending(true);
|
||||||
try {
|
try {
|
||||||
|
setAvoid(false);
|
||||||
await actions.send();
|
await actions.send();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -282,12 +283,12 @@ export function Conversation({close, openDetails, wide}: {close: ()=>void, openD
|
|||||||
</Animated.View>
|
</Animated.View>
|
||||||
<TextInput multiline={true} mode="outlined" style={{ ...styles.message, fontSize: state.textSize }}
|
<TextInput multiline={true} mode="outlined" style={{ ...styles.message, fontSize: state.textSize }}
|
||||||
blurOnSubmit={true} onSubmitEditing={sendMessage} returnKeyType="send"
|
blurOnSubmit={true} onSubmitEditing={sendMessage} returnKeyType="send"
|
||||||
onFocus={()=>setAvoid(true)} onBlur={()=>setAvoid(false)}
|
onFocus={()=>setAvoid(true)} onBlur={()=>setAvoid(false)} editable={!sending}
|
||||||
textColor={state.textColorSet ? state.textColor : undefined} outlineColor="transparent" activeOutlineColor="transparent"spellcheck={false}
|
textColor={state.textColorSet ? state.textColor : undefined} outlineColor="transparent" activeOutlineColor="transparent"spellcheck={false}
|
||||||
autoComplete="off" autoCapitalize="none" autoCorrect={false} placeholder={state.strings.newMessage} placeholderTextColor={state.textColorSet ? state.textColor : undefined}
|
autoComplete="off" autoCapitalize="none" autoCorrect={false} placeholder={state.strings.newMessage} placeholderTextColor={state.textColorSet ? state.textColor : undefined}
|
||||||
cursorColor={state.textColorSet ? state.textColor : undefined} value={state.message} onChangeText={value => actions.setMessage(value)} />
|
cursorColor={state.textColorSet ? state.textColor : undefined} value={state.message} onChangeText={value => actions.setMessage(value)} />
|
||||||
|
|
||||||
{ Platform.OS === 'ios' && avoid && (<View style={styles.avoid} />) }
|
{ Platform.OS === 'ios' && avoid && (<View style={{ ...styles.avoid, height: state.avoid - 64}} />) }
|
||||||
|
|
||||||
<View style={styles.controls}>
|
<View style={styles.controls}>
|
||||||
<Pressable style={styles.control} onPress={addImage}><Surface style={styles.surface} elevation={2}><Icon style={styles.button} source="camera" size={24} color={Colors.primary} /></Surface></Pressable>
|
<Pressable style={styles.control} onPress={addImage}><Surface style={styles.surface} elevation={2}><Icon style={styles.button} source="camera" size={24} color={Colors.primary} /></Surface></Pressable>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useState, useContext, useEffect, useRef } from 'react'
|
import { useState, useContext, useEffect, useRef } from 'react'
|
||||||
|
import { Keyboard } from 'react-native'
|
||||||
import { AppContext } from '../context/AppContext'
|
import { AppContext } from '../context/AppContext'
|
||||||
import { DisplayContext } from '../context/DisplayContext'
|
import { DisplayContext } from '../context/DisplayContext'
|
||||||
import { Focus, FocusDetail, Topic, Profile, Card, AssetType, AssetSource, HostingMode, TransformType } from 'databag-client-sdk'
|
import { Focus, FocusDetail, Topic, Profile, Card, AssetType, AssetSource, HostingMode, TransformType } from 'databag-client-sdk'
|
||||||
@ -25,7 +26,6 @@ async function getImageThumb(path: string, type: string, size: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getVideoThumb(path: string, position?: number) {
|
async function getVideoThumb(path: string, position?: number) {
|
||||||
console.log("GET FULL VID THUMB: ", path);
|
|
||||||
const timeStamp = position ? position * 1000 : 0;
|
const timeStamp = position ? position * 1000 : 0;
|
||||||
const shot = await createThumbnail({ url: path, timeStamp })
|
const shot = await createThumbnail({ url: path, timeStamp })
|
||||||
const thumb = await ImageResizer.createResizedImage('file://' + shot.path, 192, 192, "JPEG", 50, 0, null);
|
const thumb = await ImageResizer.createResizedImage('file://' + shot.path, 192, 192, "JPEG", 50, 0, null);
|
||||||
@ -34,6 +34,7 @@ console.log("GET FULL VID THUMB: ", path);
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useConversation() {
|
export function useConversation() {
|
||||||
|
const mute = useRef(false);
|
||||||
const app = useContext(AppContext) as ContextType
|
const app = useContext(AppContext) as ContextType
|
||||||
const display = useContext(DisplayContext) as ContextType
|
const display = useContext(DisplayContext) as ContextType
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
@ -52,15 +53,16 @@ export function useConversation() {
|
|||||||
sealed: false,
|
sealed: false,
|
||||||
access: false,
|
access: false,
|
||||||
subject: '',
|
subject: '',
|
||||||
|
message: null,
|
||||||
subjectNames: [],
|
subjectNames: [],
|
||||||
unknownContacts: 0,
|
unknownContacts: 0,
|
||||||
message: '',
|
|
||||||
assets: [] as {type: string, path: string, mime?: string, position?: number, label?: string, size?: number}[],
|
assets: [] as {type: string, path: string, mime?: string, position?: number, label?: string, size?: number}[],
|
||||||
textColor: '#444444',
|
textColor: '#444444',
|
||||||
textColorSet: false,
|
textColorSet: false,
|
||||||
textSize: 16,
|
textSize: 16,
|
||||||
textSizeSet: false,
|
textSizeSet: false,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
|
avoid: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -130,16 +132,21 @@ export function useConversation() {
|
|||||||
const cardId = focused.cardId;
|
const cardId = focused.cardId;
|
||||||
updateState({ detail, cardId });
|
updateState({ detail, cardId });
|
||||||
}
|
}
|
||||||
updateState({ assets: [], message: '', topics: [], loaded: false });
|
const setKeyboard = (event: KeyboardEvent) => {
|
||||||
|
updateState({ avoid: event.endCoordinates.height });
|
||||||
|
}
|
||||||
|
updateState({ assets: [], message: null, topics: [], loaded: false });
|
||||||
focus.addTopicListener(setTopics);
|
focus.addTopicListener(setTopics);
|
||||||
focus.addDetailListener(setDetail);
|
focus.addDetailListener(setDetail);
|
||||||
contact.addCardListener(setCards);
|
contact.addCardListener(setCards);
|
||||||
identity.addProfileListener(setProfile);
|
identity.addProfileListener(setProfile);
|
||||||
|
const keyboard = Keyboard.addListener('keyboardDidShow', setKeyboard);
|
||||||
return () => {
|
return () => {
|
||||||
focus.removeTopicListener(setTopics);
|
focus.removeTopicListener(setTopics);
|
||||||
focus.removeDetailListener(setDetail);
|
focus.removeDetailListener(setDetail);
|
||||||
contact.removeCardListener(setCards);
|
contact.removeCardListener(setCards);
|
||||||
identity.removeProfileListener(setProfile);
|
identity.removeProfileListener(setProfile);
|
||||||
|
keyboard.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [app.state.focus]);
|
}, [app.state.focus]);
|
||||||
@ -149,7 +156,11 @@ export function useConversation() {
|
|||||||
app.actions.clearFocus();
|
app.actions.clearFocus();
|
||||||
},
|
},
|
||||||
setMessage: (message: string) => {
|
setMessage: (message: string) => {
|
||||||
updateState({ message });
|
if (mute.current) {
|
||||||
|
updateState({ message: '' });
|
||||||
|
} else {
|
||||||
|
updateState({ message });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setTextSize: (textSize: number) => {
|
setTextSize: (textSize: number) => {
|
||||||
const textSizeSet = true;
|
const textSizeSet = true;
|
||||||
@ -281,7 +292,12 @@ export function useConversation() {
|
|||||||
}
|
}
|
||||||
const upload = (progress: number) => { updateState({ progress }) };
|
const upload = (progress: number) => { updateState({ progress }) };
|
||||||
await focus.addTopic(sealed, sealed ? 'sealedtopic' : 'superbasictopic', subject, sources, upload);
|
await focus.addTopic(sealed, sealed ? 'sealedtopic' : 'superbasictopic', subject, sources, upload);
|
||||||
updateState({ message: '', assets: [], progress: 0 });
|
|
||||||
|
mute.current = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
mute.current = false;
|
||||||
|
}, 1000);
|
||||||
|
updateState({ message: null, assets: [], progress: 0 });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addImage: (path: string, mime: string, size: number) => {
|
addImage: (path: string, mime: string, size: number) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user