1 | import PropTypes from 'prop-types';
|
2 | import React from 'react';
|
3 | import { ActivityIndicator, Platform, StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
|
4 | import Color from './Color';
|
5 | import { StylePropType } from './utils';
|
6 | const styles = StyleSheet.create({
|
7 | container: {
|
8 | alignItems: 'center',
|
9 | marginTop: 5,
|
10 | marginBottom: 10,
|
11 | },
|
12 | wrapper: {
|
13 | alignItems: 'center',
|
14 | justifyContent: 'center',
|
15 | backgroundColor: Color.defaultColor,
|
16 | borderRadius: 15,
|
17 | height: 30,
|
18 | paddingLeft: 10,
|
19 | paddingRight: 10,
|
20 | },
|
21 | text: {
|
22 | backgroundColor: Color.backgroundTransparent,
|
23 | color: Color.white,
|
24 | fontSize: 12,
|
25 | },
|
26 | activityIndicator: {
|
27 | marginTop: Platform.select({
|
28 | ios: -14,
|
29 | android: -16,
|
30 | default: -15,
|
31 | }),
|
32 | },
|
33 | });
|
34 | export function LoadEarlier({ isLoadingEarlier = false, onLoadEarlier = () => { }, label = 'Load earlier messages', containerStyle, wrapperStyle, textStyle, activityIndicatorColor = 'white', activityIndicatorSize = 'small', activityIndicatorStyle, }) {
|
35 | return (<TouchableOpacity style={[styles.container, containerStyle]} onPress={onLoadEarlier} disabled={isLoadingEarlier} accessibilityRole='button'>
|
36 | <View style={[styles.wrapper, wrapperStyle]}>
|
37 | {isLoadingEarlier ? (<View>
|
38 | <Text style={[styles.text, textStyle, { opacity: 0 }]}>
|
39 | {label}
|
40 | </Text>
|
41 | <ActivityIndicator color={activityIndicatorColor} size={activityIndicatorSize} style={[styles.activityIndicator, activityIndicatorStyle]}/>
|
42 | </View>) : (<Text style={[styles.text, textStyle]}>{label}</Text>)}
|
43 | </View>
|
44 | </TouchableOpacity>);
|
45 | }
|
46 | LoadEarlier.propTypes = {
|
47 | onLoadEarlier: PropTypes.func,
|
48 | isLoadingEarlier: PropTypes.bool,
|
49 | label: PropTypes.string,
|
50 | containerStyle: StylePropType,
|
51 | wrapperStyle: StylePropType,
|
52 | textStyle: StylePropType,
|
53 | activityIndicatorStyle: StylePropType,
|
54 | activityIndicatorColor: PropTypes.string,
|
55 | activityIndicatorSize: PropTypes.string,
|
56 | };
|
57 | //# sourceMappingURL=LoadEarlier.js.map |
\ | No newline at end of file |