forked from Ivasoft/mattermost-mobile
* Initial commit post input * Fix message posting, add create direct channel and minor fixes * Fix "is typing" and "react to last post" behaviour * Some reordering, better handling of upload error, properly clear draft on send message, and fix minor progress bar misbehavior * Add keyboard listener for shift-enter, add selection between video or photo while attaching, add alert when trying to attach more than you are allowed, add paste functionality, minor fixes and reordering * Add library patch * Fix lint * Address feedback * Address feedback * Add missing negation * Check for group name and fix typo on draft comparisons * Address feedback * Address feedback * Address feedback * Address feedback * Fix several bugs * Remove @app imports * Address feedback * fix post list & post draft layout on iOS * Fix post draft cursor position * Fix file upload route * Allow to pick multiple images using the image picker * accurately get the channel member count * remove android cursor workaround * Remove local const INPUT_LINE_HEIGHT * move getPlaceHolder out of the component * use substring instead of legacy substr for hardward keyboard * Move onAppStateChange above the effects * Fix camera action bottom sheet * no need to memo SendButton * properly use memberCount in sender handler * Refactor how to get memberCount * Fix queryRecentPostsInThread * Remove unused isDirectChannelVisible && isGroupChannelVisible util functions * rename errorBadUser to errorUnkownUser * extract localized strings * use ClientErrorProps instead of ClientError * Minor improvements Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useCallback, useEffect, useState} from 'react';
|
|
import {LayoutChangeEvent, StyleSheet, StyleProp, View, ViewStyle} from 'react-native';
|
|
import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
|
|
|
|
type ProgressBarProps = {
|
|
color: string;
|
|
progress: number;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
height: 4,
|
|
borderRadius: 2,
|
|
backgroundColor: 'rgba(255, 255, 255, 0.16)',
|
|
overflow: 'hidden',
|
|
width: '100%',
|
|
},
|
|
progressBar: {
|
|
flex: 1,
|
|
},
|
|
});
|
|
|
|
const ProgressBar = ({color, progress, style}: ProgressBarProps) => {
|
|
const [width, setWidth] = useState(0);
|
|
|
|
const progressValue = useSharedValue(progress);
|
|
|
|
const progressAnimatedStyle = useAnimatedStyle(() => {
|
|
return {
|
|
transform: [
|
|
{translateX: withTiming(((progressValue.value * 0.5) - 0.5) * width, {duration: 200})},
|
|
{scaleX: withTiming(progressValue.value ? progressValue.value : 0.0001, {duration: 200})},
|
|
],
|
|
};
|
|
}, [width]);
|
|
|
|
useEffect(() => {
|
|
progressValue.value = progress;
|
|
}, [progress]);
|
|
|
|
const onLayout = useCallback((e: LayoutChangeEvent) => {
|
|
setWidth(e.nativeEvent.layout.width);
|
|
}, []);
|
|
|
|
return (
|
|
<View
|
|
onLayout={onLayout}
|
|
style={[styles.container, style]}
|
|
>
|
|
<Animated.View
|
|
style={[
|
|
styles.progressBar,
|
|
{
|
|
backgroundColor: color,
|
|
width,
|
|
},
|
|
progressAnimatedStyle,
|
|
]}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|
|
|
|
export default ProgressBar;
|