native-base#Icon JavaScript Examples

The following examples show how to use native-base#Icon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ButtonH2t.js    From expo-ticket-app with MIT License 6 votes vote down vote up
ButtonH2t = ({ text, style, onPress, loading, disabled = false, icon = null }) => (
    <TouchableOpacity style={{
        flex: 1,
        height: 50,
        borderRadius: 10,
        backgroundColor: disabled ? colors.brandLight : colors.brandStyle,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'center',
        shadowColor: '#000',
        shadowOffset: {
            width: 0,
            height: 1,
        },
        shadowOpacity: 0.22,
        shadowRadius: 2.22,
        elevation: 3,
        opacity: disabled ? 0.6 : 1,
        ...style,
    }} onPress={onPress} disabled={loading || disabled}>
        {icon && !loading &&
        <Icon type="FontAwesome" name="ticket" style={{ color: '#fff', fontSize: 20, paddingRight: 5 }}/>}
        {!loading && <TextI18n style={{
            flex: icon ? 0 : 1,
            color: '#fff',
            fontFamily: 'Montserrat',
            fontWeight: 'normal',
            fontSize: 17,
            textAlign: icon ? 'left' : 'center',
        }}>{text}</TextI18n>}
        {loading && <Loading/>}
    </TouchableOpacity>
)
Example #2
Source File: CallsViewItem.js    From WhatsApp-Clone with MIT License 5 votes vote down vote up
CallsViewItem = ({item, hideBorder = true}) => {
  return (
    <View transparent style={{elevation: 0, marginRight: -5}}>
      <CardItem>
        <View style={{marginLeft: -5}}>
          <Thumbnail source={item.profile} />
          {/* <StoryImage hideBorder={hideBorder} source={item.profile} /> */}
        </View>
        <Body
          style={{
            flexDirection: 'column',
            width: 800,
            marginLeft: 15,
          }}>
          <Text
            numberOfLines={1}
            style={[DEFAULT_STYLES.poppinsSemiBold, styles.userName]}>
            {item.name}
          </Text>
          <View style={{flexDirection: 'row'}}>
            <Icon
              style={{
                fontSize: 20,
                marginTop: 3,
                color: item.isMissed ? RED : LIGHT_GREEN,
                marginRight: 5,
              }}
              type="MaterialCommunityIcons"
              name={item.msgIcon}
            />
            <Text
              numberOfLines={2}
              style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}>
              {item.time}
            </Text>
          </View>
        </Body>
        <View>
          {/* <Text style={(DEFAULT_STYLES.poppinsSemiBold, styles.userTime)}>
            {item.time}
          </Text> */}
          <Icon
            style={styles.msgIcon}
            name={item.callTypeIcon}
            type="MaterialIcons"
          />
        </View>
      </CardItem>
    </View>
  );
}
Example #3
Source File: ChatListItem.js    From WhatsApp-Clone with MIT License 5 votes vote down vote up
ChatListItem = ({item, navigation, userId}) => {
  const [userType, setUserType] = useState('');

  let data = item.chat[0];

  useEffect(() => {
    setUserName();
  }, []);

  async function setUserName() {
    let userType = await getUserType(item);
    setUserType(userType);
  }

  return (
    <TouchableOpacity
      onPress={() => {
        navigation &&
          navigation.navigate(NAV_TYPES.CHAT_MESSAGE_SCREEN, {
            item: item,
            isNewChat: false,
          });
      }}>
      <Card transparent style={{elevation: 0, marginRight: -5}}>
        <CardItem>
          <View style={{marginLeft: -5}}>
            <Thumbnail
              source={
                data.chatImage === ''
                  ? PROFILE
                  : {isStatic: true, uri: data.chatImage}
              }
            />
          </View>
          <Body
            style={{
              flexDirection: 'column',
              marginLeft: 15,
            }}>
            <Text
              numberOfLines={1}
              style={[DEFAULT_STYLES.poppinsSemiBold, styles.userName]}>
              {userType == constants.FRIEND ? data.userName : data.chatName}
            </Text>

            <Text
              numberOfLines={2}
              style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}>
              {data.chatMessage}
            </Text>
          </Body>
          <View>
            <Text style={[DEFAULT_STYLES.poppinsSemiBold, styles.userTime]}>
              {getTimeInFormat(data.chatTime)}
            </Text>
            {item.chatUnreadCount != 0 && (
              <View style={styles.textMsgCountView}>
                <Text
                  style={styles.textMsgCount}>
                  {item.chatUnreadCount}
                </Text>
              </View>
            )}
            {item.chatUnreadCount === 0 && (
              <Icon
                style={styles.msgIcon}
                name={data.chatUnreadCount}
                type={data.chatUnreadCount}
              />
            )}
          </View>
        </CardItem>
      </Card>
    </TouchableOpacity>
  );
}
Example #4
Source File: Welcome.js    From expo-ticket-app with MIT License 5 votes vote down vote up
render() {
        const { loading } = this.props;

        return (<Container style={{ backgroundColor: commonColor.backgroundColor }}>
            <StatusBar style="light"/>
            <Content padder style={{ flex: 1 }}>
                <Spacer size={60}/>
                <Text style={{
                    flex: 1,
                    fontSize: 55,
                    fontWeight: '400',
                    fontFamily: 'Montserrat_Bold',
                    color: 'white',
                    textAlign: 'center',
                }}>
                    {'Expo\nTicket App'}
                </Text>
                <LottieView
                    loop={true}
                    autoPlay
                    speed={1.5}
                    style={{ width: '100%' }}
                    source={require('../../../images/home')}
                />
                {!loading && <View>
                    <Card style={{ backgroundColor: commonColor.brandStyle }}>
                        <ListItem onPress={Actions.login} icon first>
                            <Left>
                                <Icon name="log-in" style={{ color: 'white' }}/>
                            </Left>
                            <Body style={{ borderBottomWidth: 0 }}>
                                <TextI18n style={{
                                    color: 'white',
                                    fontSize: 20
                                }}>
                                    login.connect
                                </TextI18n>
                            </Body>
                        </ListItem>
                        <ListItem onPress={Actions.signUp} icon>
                            <Left>
                                <Icon name="add-circle" style={{ color: 'white' }}/>
                            </Left>
                            <Body style={{ borderBottomWidth: 0 }}>
                                <TextI18n style={{
                                    color: 'white',
                                    fontSize: 20
                                }}>
                                    login.signUp
                                </TextI18n>
                            </Body>
                        </ListItem>
                    </Card>
                    <TextI18n
                        onPress={Actions.tabbar}
                        style={{
                            flex: 1,
                            fontSize: 13,
                            fontWeight: '400',
                            fontFamily: 'Montserrat',
                            paddingTop: 10,
                            color: 'white',
                            textAlign: 'center',
                            textDecorationLine: 'underline',
                        }}>
                        login.withoutAccount
                    </TextI18n>
                </View>}
                {loading && <Loading/>}
            </Content>
        </Container>);
    }
Example #5
Source File: ContactsHeaderView.js    From WhatsApp-Clone with MIT License 5 votes vote down vote up
ContactsHeaderView = ({item, navigation}) => { 

  return (
    <View style={{elevation: 0}}>
      <CardItem style={styles.parentView}>
        <View style={{flexDirection: 'row'}}>
          <Icon
            name="arrow-left"
            type="MaterialCommunityIcons"
            style={styles.backIcon}
            onPress={() => navigation.goBack()}
          />
          <Body
            style={{
              flexDirection: 'column', 
              marginLeft: 7,
            }}>
            <Text
              numberOfLines={1}
              style={[DEFAULT_STYLES.poppinsSemiBold, styles.userName]}>
              Select contact
            </Text>
            <Text
              numberOfLines={2}
              style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}>
              {item} contacts
            </Text>
          </Body>
          <View style={{flexDirection: 'row', justifyContent: 'space-evenly'}}>
            <Icon
              name="dots-vertical"
              type="MaterialCommunityIcons"
              style={styles.menuIcons}
            />
          </View>
        </View>
      </CardItem>
    </View>
  );
}
Example #6
Source File: HomeHeader.js    From WhatsApp-Clone with MIT License 5 votes vote down vote up
HomeHeader = ({navigation}) => {
  const menuRef = useRef('');
  const [user, setUser] = useState('');

  useEffect(() => {
    setUserName();
  }, []);

  async function setUserName() {
    const user = await getLocalData(constants.USER_NAME);
    setUser(user);
  }

  const hideMenu = () => {
    menuRef.current.hide();
  };

  const showMenu = () => {
    menuRef.current.show();
  };

  function navigateQrScannerScreen() {
    hideMenu();
    navigateStack({navigation: navigation, screen: NAV_TYPES.QR_CODE_SCREEN});
  }

  return (
    <View style={styles.mainView}>
      {/* <View style={styles.parentView}> */}
      {/* <Image source={prodileImage} style={styles.imageRounded} /> */}
      <_Text title style={styles.userName}>
        WhatsApp Clone
      </_Text>
      {/* </View> */}
      <View style={styles.parentView}>
        <Icon name="search" type="Octicons" style={styles.iconStyle1} />
        {/* <Icon
          name="dots-vertical"
          type="MaterialCommunityIcons"
          style={styles.iconStyle2}
        /> */}
        <Menu
          ref={menuRef}
          button={
            <Icon
              name="dots-vertical"
              type="MaterialCommunityIcons"
              style={styles.iconStyle2}
              onPress={showMenu}
            />
          }>
          <MenuItem textStyle={styles.menuTextStyle} onPress={hideMenu}>
            {user && user}
          </MenuItem>
          <MenuItem
            textStyle={styles.menuTextStyle}
            onPress={navigateQrScannerScreen}>
            {'Whatsapp Web'}
          </MenuItem>
          <MenuDivider />
          <MenuItem
            textStyle={styles.menuTextStyle}
            onPress={() => {
              hideMenu();
              logoutUser(navigation);
            }}>
            Logout
          </MenuItem>
        </Menu>
      </View>
    </View>
  );
}
Example #7
Source File: CardH2t.js    From expo-ticket-app with MIT License 5 votes vote down vote up
CardH2t = ({ source, text1, text2, onPress, loading }) => (
    <TouchableOpacity style={{
        flex: 1,
        height: 220,
        padding: 10,
    }} onPress={onPress} disabled={loading}>
        <View style={{
            shadowColor: '#000',
            shadowOffset: {
                width: 0,
                height: 8,
            },
            shadowOpacity: 0.46,
            shadowRadius: 11.14,
            elevation: 17,
            borderRadius: 10,
        }}>
            <ImageBackground
                source={source}
                imageStyle={{ resizeMode: 'cover', borderRadius: 15 }}
                style={{
                    width: '100%',
                    height: '100%',

                }}>
                <View style={{
                    flex: 1, padding: 15,
                    alignItems: 'center',
                    justifyContent: 'space-around',
                }}>
                    <TextI18n style={{ fontSize: 23, textAlign: 'center', fontFamily: 'Montserrat_Bold' }}>
                        {text1}
                    </TextI18n>
                    <TextI18n style={{ fontSize: 17, textAlign: 'center' }}>{text2}</TextI18n>

                    <View style={{ flexDirection: 'row', alignItems: 'center', alignSelf: 'flex-start' }}>
                        <TextI18n style={{ fontSize: 20, textAlign: 'center', fontFamily: 'Montserrat_Bold' }}>
                            global.go
                        </TextI18n>
                        <Icon type="Entypo" name="chevron-right" style={{ color: 'white', fontSize: 26 }}/>
                    </View>
                </View>
            </ImageBackground>
        </View>
    </TouchableOpacity>
)
Example #8
Source File: index.js    From aws-appsync-refarch-offline with MIT No Attribution 5 votes vote down vote up
OrderList = ({ orders, onSelectOrder }) => {

    function onPress(orderId) {
        if (onSelectOrder) {
            onSelectOrder(orderId);
        }
    }

    const ordersByDay = _.groupBy(orders, order => moment(order.createdAt).format('YYYY-MM-DD'));
    const days = _.keys(ordersByDay);
    const ordersByDayList = days.map(day => {
        const sorted = ordersByDay[day].sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
        const orderList = sorted.map(order => (
            <ListItem thumbnail button key={order.id} onPress={() => onPress(order.id)}>
                <Body>
                    <Text style={styles.orderTitle}>
                        {moment(order.createdAt).format('hh:mm A')}
                    </Text>
                    <Text note>{order.id}</Text>
                </Body>
                <Right>
                    <Text note>
                        ${order.total.toFixed(2)}
                    </Text>
                    <Icon name="arrow-forward" />
                </Right>
            </ListItem>
        ));

        const sectionTitle = (
            <ListItem itemDivider key={day}>
                <Text>{moment(day).format('MMM Do, YYYY')}</Text>
            </ListItem>
        );
        
        return [sectionTitle, ...orderList];
    });

    return (
        <List>
            {ordersByDayList}
        </List>
    );
}
Example #9
Source File: index.js    From react-native-expo-starter-kit with MIT License 5 votes vote down vote up
Index = (
  <Stack hideNavBar>
    <Scene hideNavBar>
      <Tabs
        key="tabbar"
        swipeEnabled
        type="replace"
        showLabel={false}
        {...DefaultProps.tabProps}
      >
        <Stack
          key="home"
          title={AppConfig.appName}
          icon={() => <Icon name="planet" {...DefaultProps.icons} />}
          {...DefaultProps.navbarProps}
        >
          <Scene key="home" component={AboutComponent} />
        </Stack>

        <Stack
          key="articlesList"
          title="Articles List"
          icon={() => <Icon name="list" {...DefaultProps.icons} />}
          {...DefaultProps.navbarProps}
        >
          <Scene key="articlesList" component={ArticlesList} />
          <Scene key="articlesSingle" component={ArticlesSingle} />
        </Stack>

        <Stack
          key="form"
          title="Articles Form"
          icon={() => <Icon name="add" {...DefaultProps.icons} />}
          {...DefaultProps.navbarProps}
        >
          <Scene key="form" component={ArticlesForm} />
        </Stack>
      </Tabs>
    </Scene>
  </Stack>
)
Example #10
Source File: Wallet.js    From web3-react-native with MIT License 5 votes vote down vote up
Wallet = ({ wallet, onRequestAddFunds, onRequestMakeTransaction, ...extraProps }) => {
  return (
    <Card
    >
      <CardItem
        header
        bordered
      >
        <Text
          children="Some Wallet Name"
        />
      </CardItem>

      <CardItem
        bordered
      >
        <Icon active name="wallet" />
        <Text
          style={styles.details}
          children={wallet.address}
        />
      </CardItem>
      <CardItem
      >
        <Body
          style={styles.buttons}
        >
          <View
            style={styles.buttonContainer}
          >
            <Button
              onPress={onRequestAddFunds}
              success
            >
              <Icon name="water" />
              <Text
                children="Faucet"
              />
            </Button>
          </View>
          <View
            style={styles.buttonContainer}
          >
            <Button
              onPress={onRequestMakeTransaction}
              primary
            >
              <Icon name="cash" />
              <Text
                children="Send"
              />
            </Button>
          </View>
        </Body>
      </CardItem>
    </Card>
  );
}
Example #11
Source File: Transaction.js    From web3-react-native with MIT License 5 votes vote down vote up
Transaction = ({ transaction, onRequestViewTransaction, ...extraProps }) => {
  return (
    <Card
    >
      <CardItem
        header
        bordered
      >
        <Text
          children="Some Transaction Name"
        />
      </CardItem>

      <CardItem
        bordered
      >
        <Icon active name="pricetag" />
        <Text
          style={styles.details}
          children={transaction.transactionHash}
        />
      </CardItem>
      <CardItem
      >
        <Body
          style={styles.buttons}
        >
          <View
            style={styles.buttonContainer}
          >
            <Button
              onPress={onRequestViewTransaction}
              success
            >
              <Icon name="eye" />
              <Text
                children="View Transaction"
              />
            </Button>
          </View>
        </Body>
      </CardItem>
    </Card>
  );
}
Example #12
Source File: OTPValidation.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
OTPValidation = ({navigation}) => {
  const [countryCode, setCountryCode] = useState('');
  const [country, setCountry] = useState('');

  const onSelect = country => {
    console.log(country);
    setCountryCode(country.cca2);
    setCountry(country);
  };

  return (
    // <SafeAreaView>
    <View style={[container, {flexDirection: 'column'}]}>
      <View
        style={{
          backgroundColor: GREEN,
          height: '30%',
          justifyContent: 'center',
          alignItems: 'center',
        }}>
        <Icon
          type="FontAwesome"
          name="whatsapp"
          style={{
            fontSize: 50,
            color: WHITE,
            justifyContent: 'center',
            alignSelf: 'center',
          }}
        />
        <_Text style={{marginTop: '2%', color: WHITE, fontSize: 26}}>
          Whatsapp
        </_Text>
      </View>
      <ScrollView
        keyboardShouldPersistTaps="always"
        style={{flexGrow: 1, height: '100%'}}
        // contentContainerStyle={{
        //   // flex: 1,
        //   justifyContent: 'center',
        //   flexGrow:1
        // }}
      >
        <View
          style={{
            margin: '6%',
            flex: 1,
            flexDirection: 'column',
            height: '100%',
            justifyContent: 'flex-start',
          }}>
          <_Text
            title
            style={[
              poppinsMedium,
              {marginTop: '10%', fontSize: 16, alignSelf: 'center'},
            ]}>
            Waiting to automatically detect the sms sent to +91 8850987832
          </_Text>

          <View
            style={{
              flexDirection: 'row',
              justifyContent: 'center',
              marginTop: '10%',
              marginBottom: '5%',
            }}>
            <_TextInput
              editable={true}
              maxLength={1}
              textAlign={'center'}
              containerStyle={styles.otpView1}
              inputStyle={styles.otpLabelView}
            />
            <_TextInput
              editable={true}
              maxLength={1}
              textAlign={'center'}
              containerStyle={styles.otpView}
              inputStyle={styles.otpLabelView}
            />
            <_TextInput
              editable={true}
              maxLength={1}
              textAlign={'center'}
              containerStyle={styles.otpView}
              inputStyle={styles.otpLabelView}
            />
            <_TextInput
              editable={true}
              maxLength={1}
              textAlign={'center'}
              containerStyle={styles.otpView}
              inputStyle={styles.otpLabelView}
            />
          </View>

          <View style={{flexDirection: 'row'}}>
            <_Text description style={(poppinsRegular, styles.resendOtpStyle)}>
              Didn't receive the code ?
            </_Text>
            <_Text
              description
              style={[
                poppinsRegular,
                styles.resendOtpStyle,
                {marginLeft: 10, color: GREEN, fontWeight: 'bold'},
              ]}>
              RESEND CODE
            </_Text>
          </View>
        </View>
      </ScrollView>

      <View
        style={{
          alignSelf: 'flex-end',
          right: '3%',
          bottom: '3%',
        }}>
        <Button
          style={{
            width: 60,
            height: 60,
            backgroundColor: GREEN,
          }}
          onPress={() => navigation.navigate(NAV_TYPES.HOME_SCREEN)}
          rounded>
          <Icon type="MaterialCommunityIcons" name="arrow-right" />
        </Button>
      </View>
    </View>
    // </SafeAreaView>
  );
}
Example #13
Source File: LoginScreen.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
LoginScreen = ({navigation}) => {
  const [userName, setUserName] = useState('');
  const [mobile, setMobile] = useState('');
  const [isLoading, setLoading] = useState(false);

  useEffect(() => {
    getLocalData(constants.USER_ID)
      .then(userID => {
        console.log('Login userID => ', userID);
        if (userID && userID != null && userID != '') {
          navigation.dispatch(StackActions.replace(NAV_TYPES.HOME_SCREEN));
        }
      })
      .catch(err => {
        console.log('Login Error => ', err);
      });
  }, []);

  const onLoginClick = () => {
    if (userName === '') {
      showToast({text: 'Enter your Name', type: 'danger'});
    } else if (mobile === '') {
      showToast({text: 'Enter your Mobile Number', type: 'danger'});
    } else {
      setLoading(!isLoading);
      loginUser(getLoginModel(userName, mobile))
        .then(res => {
          console.log('LOGIN RESPONSE => ' + JSON.stringify(res));
          if (res.data.success) {
            setLoading(isLoading);
            console.log('TOKEN : ', res.headers.token);
            setUserName('');
            setMobile('');
            console.log('LOGIN RESPONSE => ' + JSON.stringify(res));

            storeLocalData(constants.ACCESS_TOKEN, res.headers.token);
            storeLocalData(constants.USER_ID, res.data.id);
            storeLocalData(constants.USER_NAME, userName);

            navigation.navigate(NAV_TYPES.HOME_SCREEN, {});
          }
        })
        .catch(error => {
          console.log('LOGIN ERROR ', error);
        });
    }
  };

  const onSignUpClick = () => {
    navigation.navigate(NAV_TYPES.REGISTER, {});
  };

  return (
    <SafeAreaView style={container}>
      {isLoading && <LoadingComponent />}
      {/* {!isLoading && ( */}
      <Root style={[container, {flexDirection: 'column'}]}>
        <KeyboardAvoidingView
          behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
          style={styles.keyboardView}>
          <View style={styles.headerView}>
            <Icon type="FontAwesome" name="whatsapp" style={styles.logoStyle} />
            <_Text style={styles.logoTextStyle}>{constants.APP_NAME}</_Text>
          </View>
          <ScrollView
            keyboardShouldPersistTaps="handled"
            contentContainerStyle={{
              flex: 1,
              justifyContent: 'center',
            }}>
            <View style={styles.contentView}>
              <View style={{flexDirection: 'column'}}>
                <_Text description style={[poppinsRegular, styles.labelStyle]}>
                  Enter Name
                </_Text>

                <_TextInput
                  value={userName}
                  inputStyle={[poppinsMedium, styles.inputStyle]}
                  floatingLabel={false}
                  keyboardType={'default'}
                  containerStyle={{width: '100%', marginLeft: 0}}
                  onChangeText={data => {
                    setUserName(data.value);
                  }}
                />

                <_Text description style={[poppinsRegular, styles.labelStyle]}>
                  Mobile Number
                </_Text>

                <_TextInput
                  value={mobile}
                  inputStyle={[poppinsMedium, styles.inputStyle]}
                  floatingLabel={false}
                  keyboardType={'numeric'}
                  containerStyle={{width: '100%', marginLeft: 0}}
                  onChangeText={data => {
                    setMobile(data.value);
                  }}
                />
              </View>

              <View style={styles.buttonLoginView}>
                <Button onPress={() => onLoginClick()} style={styles.login}>
                  <Text style={{fontSize: 18, fontWeight: 'bold'}}>Login</Text>
                </Button>
                <BorderlessButton
                  onPress={() => onSignUpClick()}
                  style={styles.buttonSignupView}>
                  <Text style={styles.signup}>Sign Up</Text>
                </BorderlessButton>
              </View>
            </View>
          </ScrollView>
        </KeyboardAvoidingView>
      </Root>
      {/* )} */}
    </SafeAreaView>
  );
}
Example #14
Source File: RegisterScreen.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
RegisterScreen = ({navigation}) => {
  const [countryCode, setCountryCode] = useState('');
  const [country, setCountry] = useState('');
  const [userName, setUserName] = useState('');
  const [mobile, setMobile] = useState('');
  const [isLoading, setLoading] = useState(false);

  useEffect(() => {
    getLocalData(constants.USER_ID)
      .then(userID => {
        console.log('Login userID => ', userID);
        if (userID && userID != null && userID != '') {
          navigation.dispatch(StackActions.replace(NAV_TYPES.HOME_SCREEN));
        }
      })
      .catch(err => {
        console.log('Login Error => ', err);
      });
  }, []);

  const onSelect = country => {
    console.log(country);
    setCountryCode(country.cca2);
    setCountry(country);
  };

  const onSignUpClick = () => {
    if (country === '') {
      showToast({text: 'Select your Country', type: 'danger'});
    } else if (userName === '') {
      showToast({text: 'Enter your Name', type: 'danger'});
    } else if (mobile === '') {
      showToast({text: 'Enter your Mobile Number', type: 'danger'});
    } else {
      setLoading(!isLoading);
      loginUser(getLoginModel(userName, mobile))
        .then(res => {
          setLoading(isLoading);
          console.log('TOKEN : ', res.headers.token);
          setUserName('');
          setMobile('');
          console.log('LOGIN RESPONSE => ' + JSON.stringify(res));

          if (res.data.success) {
            storeLocalData(constants.ACCESS_TOKEN, res.headers.token);
            storeLocalData(constants.USER_ID, res.data.id);
            storeLocalData(constants.USER_NAME, userName);

            navigation.navigate(NAV_TYPES.HOME_SCREEN, {});
          }
        })
        .catch(error => {
          console.log('LOGIN ERROR ', error);
        });
    }
  };

  const onLoginClick = () => {
    navigation && navigation.goBack();
  };

  return (
    <SafeAreaView style={container}>
      {isLoading && <LoadingComponent />}
      {/* {!isLoading && ( */}
      <Root style={[container, {flexDirection: 'column'}]}>
        <KeyboardAvoidingView
          behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
          style={styles.keyboardView}>
          <View style={styles.headerView}>
            <Icon type="FontAwesome" name="whatsapp" style={styles.logoStyle} />
            <_Text style={styles.logoTextStyle}>{constants.APP_NAME}</_Text>
          </View>
          <ScrollView
            keyboardShouldPersistTaps="handled"
            contentContainerStyle={{
              flex: 1,
              justifyContent: 'center',
            }}>
            <View style={styles.contentView}>
              <_Text description style={[poppinsRegular, styles.inputStyle]}>
                Country
              </_Text>
              <View style={{flexDirection: 'column'}}>
                {/* <_TextInput editable={true} style={{width:'20%'}} /> */}
                <CountryPicker
                  containerButtonStyle={{
                    height: 40,
                    marginTop: 5,
                    justifyContent: 'center',
                  }}
                  countryCode={countryCode}
                  withCountryNameButton={true}
                  visible={false}
                  withFlag={true}
                  withCloseButton={true}
                  withAlphaFilter={true}
                  withCallingCode={true}
                  //   withCurrency={true}
                  withEmoji={true}
                  withCountryNameButton={true}
                  //   withCurrencyButton={true}
                  //   withCallingCodeButton={true}
                  withFilter={true}
                  withModal={true}
                  onSelect={onSelect}
                />
                <View style={{height: '3%', backgroundColor: GREEN}} />
              </View>

              <View style={{flexDirection: 'column', marginTop: '-4%'}}>
                <_Text description style={[poppinsRegular, styles.labelStyle]}>
                  Enter Name
                </_Text>

                <_TextInput
                  value={userName}
                  inputStyle={[poppinsMedium, styles.inputStyle]}
                  floatingLabel={false}
                  keyboardType={'default'}
                  containerStyle={{width: '100%', marginLeft: 0}}
                  onChangeText={data => {
                    setUserName(data.value);
                  }}
                />

                <_Text description style={[poppinsRegular, styles.labelStyle]}>
                  Mobile Number
                </_Text>

                <_TextInput
                  value={mobile}
                  inputStyle={[poppinsMedium, styles.inputStyle]}
                  floatingLabel={false}
                  keyboardType={'numeric'}
                  containerStyle={{width: '100%', marginLeft: 0}}
                  onChangeText={data => {
                    setMobile(data.value);
                  }}
                />
              </View>

              <View style={styles.buttonLoginView}>
                <Button onPress={() => onSignUpClick()} style={styles.login}>
                  <Text style={{fontSize: 18, fontWeight: 'bold'}}>
                    Sign Up
                  </Text>
                </Button>
                <BorderlessButton
                  onPress={() => onLoginClick()}
                  style={styles.buttonSignupView}>
                  <Text style={styles.signup}>Login</Text>
                </BorderlessButton>
              </View>
            </View>
          </ScrollView> 
        </KeyboardAvoidingView>
      </Root>
    </SafeAreaView>
  );
}
Example #15
Source File: MyStatusView.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
MyStatusView = ({navigation, statusData, isUser, isBorder}) => {
  const statusImage =
    statusData && statusData.status && statusData.status.length > 0
      ? statusData.status[statusData.status.length - 1].image + ''
      : '';
  // console.log('Status Item : ', statusData);

  return (
    <TouchableOpacity
      onPress={() => {
        statusImage && statusImage != ''
          ? navigation.navigate(NAV_TYPES.STATUS_VIEW, {
              statusData: JSON.stringify(statusData),
              isUser: isUser,
            })
          : navigation.navigate(NAV_TYPES.CAMERA_VIEW, {});
      }}>
      <Card transparent style={{elevation: 0, marginRight: -5}}>
        <CardItem>
          <View style={{marginLeft: -5}}>
            <View
              style={
                isBorder
                  ? styles.circleView
                  : isUser
                  ? styles.circleNoView
                  : styles.circleSeenView
              }>
              <Thumbnail
                style={
                  isBorder
                    ? {width: 50, height: 50}
                    : isUser
                    ? {width: 60, height: 60, borderRadius: 100}
                    : {width: 50, height: 50}
                }
                source={statusImage ? {uri: statusImage} : PROFILE2}
              />
            </View>
            {isUser && (!statusImage || statusImage === '') && (
              <Icon
                type="MaterialCommunityIcons"
                name="plus-circle"
                color={GREEN}
                style={{
                  color: LIGHT_GREEN,
                  position: 'absolute',
                  bottom: -5,
                  right: -18,
                }}
              />
            )}
          </View>
          <Body
            style={{
              flexDirection: 'column',
              width: 800,
              marginLeft: 15,
            }}>
            <Text
              numberOfLines={1}
              style={[DEFAULT_STYLES.poppinsSemiBold, styles.userName]}>
              {isUser ? 'My Status' : statusData.userName}
            </Text>
            <TimeElapsed
              style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}
              time={
                statusData.lastStatusTime
                  ? statusData.lastStatusTime
                  : 'Tap to add status update'
              }
              // interval={1000}
              isValid={statusData != ''}
            />
            {/* <Text
              numberOfLines={2}
              style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}>
              {statusData.lastStatusTime
                ? getDateTimeStatusFormat(statusData.lastStatusTime)
                : 'Tap to add status update'}
            </Text> */}
          </Body>
          <View>
            {isUser && (
              <Icon
                style={styles.msgIcon}
                name="dots-horizontal"
                type="MaterialCommunityIcons"
              />
            )}
          </View>
        </CardItem>
      </Card>
    </TouchableOpacity>
  );
}
Example #16
Source File: ChatTextInput.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
ChatTextInput = ({params, onSendMessage, isStatus, onResetClick}) => {
  const [message, setMessage] = useState('');
  const [keyboardPadding, setKeyboardPadding] = useState(5);

  useEffect(() => {
    let listener1 = Keyboard.addListener('keyboardWillShow', onShowKeyboard);
    let listener2 = Keyboard.addListener('keyboardWillHide', onHideKeyboard);

    return () => {
      listener1.remove();
      listener2.remove();
    };
  }, []);

  function onShowKeyboard(e) {
    // alert('Keyboard Shown');
    console.log(e);
    setKeyboardPadding(
      (e.endCoordinates.height - e.startCoordinates.height) / 2,
    );
  }

  function onHideKeyboard(e) {
    // alert('Keyboard Hidden');
    setKeyboardPadding(0);
  }

  const getChatRoomInput = () => {
    return (
      <View style={{flexDirection: 'row'}}>
        <Item rounded style={{backgroundColor: WHITE, flex: 1}}>
          <Icon
            name="smiley"
            type="Octicons"
            style={[styles.menuIcons, {marginLeft: 5}]}
          />
          <Input
            multiline
            style={styles.userMessage}
            placeholder="Type a message ..."
            placeholderTextColor={LIGHT_GRAY}
            value={message}
            onChangeText={text => {
              setMessage(text);
            }}
          />
          <Icon name="attachment" type="Entypo" style={styles.menuIcons} />
          <Icon
            name="camera"
            type="MaterialCommunityIcons"
            style={[styles.menuIcons, {marginRight: 5}]}
          />
        </Item>
        <Button
          icon
          rounded
          large
          style={styles.sendIconView}
          onPress={() => {
            onSendMessage(message);
            setMessage('');
          }}>
          <Icon
            name={message === '' ? 'microphone' : 'send'}
            type="MaterialCommunityIcons"
            style={styles.sendIcon}
          />
        </Button>
      </View>
    );
  };

  const getStatusInput = () => {
    return (
      <View
        style={{
          flexDirection: 'row',
          paddingBottom: '2%',
          justifyContent: 'center', 
        }}>
        <Button 
          rounded 
          style={styles.sendStatusIconView}
          onPress={() => {
            onResetClick();
            setMessage('');
          }}>
          <Icon
            name="camera"
            type="MaterialCommunityIcons"
            style={[styles.sendIcon]}
          />
        </Button>
        <Input
          multiline
          style={styles.userStatusMessage}
          placeholder="Type a message ..."
          placeholderTextColor={LIGHT_GRAY}
          value={message}
          onChangeText={text => {
            setMessage(text);
          }}
        />
        <Button
          icon
          rounded
          large
          style={styles.sendStatusIconView}
          onPress={() => {
            onSendMessage(message);
            setMessage('');
          }}>
          <Icon
            name={'send'}
            type="MaterialCommunityIcons"
            style={styles.sendIcon}
          />
        </Button>
      </View>
    );
  };

  return (
    <KeyboardAvoidingView style={{paddingBottom: keyboardPadding}}>
      <View style={styles.parentView}>
        {isStatus ? getStatusInput() : getChatRoomInput()}
      </View>
    </KeyboardAvoidingView>
  );
}
Example #17
Source File: ChatRoomHeaderView.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
ChatRoomHeaderView = ({item, navigation, isNewChat}) => {
  // console.log('isNewChat =>', isNewChat);
  const [userType, setUserType] = useState('');
  const [displayLastSeen, setDisplayLastSeen] = useState('');
  const [apiLastSeen, setApiLastSeen] = useState('');

  let data = item.chat[0];

  useEffect(() => {
    populateUserType();
    getUserLastSeen();
    listenUserLastSeen();
  }, []);

  useEffect(() => {
    if (apiLastSeen != '') {
      calcLastSeen(apiLastSeen);
    }
  }, [apiLastSeen]);

  const populateUserType = async () => {
    let userType = await getUserType(item);
    setUserType(userType);
  };

  async function getUserLastSeen() {
    let userId = await getLocalData(constants.USER_ID);
    // This to get id of the other user
    let id = data.userId === userId ? data.chatId : data.userId;
    let request = {id: id};
    let res = getLastSeenUser(request);
    res
      .then(lastSeen => {
        if (lastSeen) {
          // console.log('User Last Seen ==> ', JSON.stringify(lastSeen));
          setApiLastSeen(lastSeen.data.lastSeen[0]);
        }
      })
      .catch(err => {
        console.log('User Last Seen ==> ', err);
      });
  }

  function listenUserLastSeen() {
    socket.on(constants.LAST_SEEN, async status => {
      // console.log('App Status == ', status);
      let newStatus = {
        userId: status.userId,
        userName: status.userName,
        status: status.status,
        lastSeen: status.lastSeen,
      };
      let id = await getLocalData(webConstants.USER_ID);
      if (status.userId != id) {
        calcLastSeen(newStatus);
      } else {
        // setDisplayLastSeen("");
      }
    });
    sendPageLoadStatus();
  }

  async function calcLastSeen(lastSeen) {
    if (lastSeen) {
      if (lastSeen.userId === data.userId || lastSeen.userId === data.chatId) { 
          let time =
            lastSeen.status === 'Offline'
              ? `Last seen at ${getDateTimeInFormat(lastSeen.lastSeen)}`
              : lastSeen.status;
          setDisplayLastSeen(time); 
      } else if (apiLastSeen != '') {
        let time = `Last seen at ${getDateTimeInFormat(apiLastSeen.lastSeen)}`;
        setDisplayLastSeen(time);
      }
    } else {
      // User last seen not available yet
      setApiLastSeen('');
      setDisplayLastSeen('');
    }
  }

  // function calcLastSeen(lastSeen) {
  //   if (lastSeen) {
  //     if (lastSeen.userId === data.userId || lastSeen.userId === data.chatId) {
  //       getLocalData(constants.USER_ID)
  //         .then(id => {
  //           if (lastSeen.userId != id) {
  //             let time =
  //               lastSeen.status === 'Offline'
  //                 ? `Last seen at ${getDateTimeInFormat(lastSeen.lastSeen)}`
  //                 : lastSeen.status;
  //             setDisplayLastSeen(time);
  //           } else if (apiLastSeen != '' && lastSeen != '') {
  //             let time = `Last seen at ${getDateTimeInFormat(
  //               lastSeen.lastSeen,
  //             )}`;
  //             setDisplayLastSeen(time);
  //           } else if (apiLastSeen != '') {
  //             let time = `Last seen at ${getDateTimeInFormat(
  //               apiLastSeen.lastSeen,
  //             )}`;
  //             setDisplayLastSeen(time);
  //           } else {
  //             setDisplayLastSeen('');
  //           }
  //         })
  //         .catch(() => {
  //           if (apiLastSeen != '' && lastSeen != '') {
  //             let time = `Last seen at ${getDateTimeInFormat(
  //               lastSeen.lastSeen,
  //             )}`;
  //             setDisplayLastSeen(time);
  //           } else if (apiLastSeen != '') {
  //             let time = `Last seen at ${getDateTimeInFormat(
  //               apiLastSeen.lastSeen,
  //             )}`;
  //             setDisplayLastSeen(time);
  //           } else {
  //             setDisplayLastSeen('');
  //           }
  //         });
  //     } else if (apiLastSeen != '') {
  //       let time = `Last seen at ${getDateTimeInFormat(apiLastSeen.lastSeen)}`;
  //       setDisplayLastSeen(time);
  //     }
  //   } else {
  //     // User last seen not available yet
  //     setApiLastSeen('');
  //     setDisplayLastSeen('');
  //   }
  // }

  return (
    <View style={{elevation: 0}}>
      <CardItem style={styles.parentView}>
        <View style={{flexDirection: 'row'}}>
          <Icon
            name="arrow-left"
            type="MaterialCommunityIcons"
            style={styles.backIcon}
            onPress={() => navigation.goBack()}
          />
          <Thumbnail
            source={
              !data.chatImage && data.chatImage != ''
                ? {isStatic: true, uri: data.chatImage}
                : USER
            }
            style={styles.profileIcon}
          />
          <Body
            style={{
              flexDirection: 'column',
              marginLeft: 10,
            }}>
            <Text
              numberOfLines={1}
              style={
                displayLastSeen != '' ? styles.userName : styles.centerUserName
              }>
              {userType == constants.FRIEND ? data.userName : data.chatName}
            </Text>
            {displayLastSeen != '' && (
              <Text
                numberOfLines={1}
                ellipsizeMode="tail"
                style={[DEFAULT_STYLES.poppinsLight, styles.userMessage]}>
                {/* Last seen at {getDateTimeInFormat(data.chatTime)} */}
                {displayLastSeen}
              </Text>
            )}
          </Body>
          <View style={{flexDirection: 'row', justifyContent: 'space-evenly'}}>
            <Icon
              name="video"
              type="MaterialCommunityIcons"
              style={styles.menuIcons}
            />
            <Icon
              name="phone"
              type="MaterialCommunityIcons"
              style={styles.menuIcons}
            />
            <Icon
              name="dots-vertical"
              type="MaterialCommunityIcons"
              style={styles.menuIcons}
            />
          </View>
        </View>
      </CardItem>
    </View>
  );
}
Example #18
Source File: StatusView.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
StatusView = ({navigation}) => {
  var [state, dispatch] = useReducer(statusReducer, statusState);

  var {statusData, recentStatusList, viewedStatusList, refresh} = state;

  useFocusEffect(
    React.useCallback(() => {
      getUserStatusFromAPI(dispatch);
    }, []),
  );

  useEffect(() => {
    listenSocket();

    // return () => {
    //   alert('STATUS DISCONNECTED');
    //   socket.removeListener(constants.USER_STATUS);
    // };
  }, []);

  function listenSocket() {
    // socket.removeListener(constants.CHAT_LIST);
    socket.on(constants.USER_STATUS, async statusModel => {
      const id = await getLocalData(constants.USER_ID);
      if (statusModel.userId != id) {
        console.log('STATUS RECEIVED');
        getUserStatusFromAPI(dispatch);
      }
    });
  }

  return (
    <Container>
      <ScrollView nestedScrollEnabled style={{flex: 1, paddingBottom: 200}}>
        <View>
          <MyStatusView
            navigation={navigation}
            statusData={statusData}
            isUser 
            isBorder={false}
          />
          {recentStatusList.length > 0 && (
            <View>
              <_Divider style={{borderBottomWidth: 5}} />
              <Text style={[DEFAULT_STYLES.poppinsSemiBold, styles.userTime]}>
                RECENT UPDATES
              </Text>
              <RecentStatusView
                navigation={navigation}
                statusData={recentStatusList}
              />
            </View>
          )}
          {viewedStatusList.length > 0 && (
            <View>
              <_Divider style={{borderBottomWidth: 5}} />
              <Text style={[DEFAULT_STYLES.poppinsSemiBold, styles.userTime]}>
                VIEWED UPDATES
              </Text>
              <ViewedStatusView
                navigation={navigation}
                statusData={viewedStatusList}
              />
            </View>
          )}
        </View>
      </ScrollView>

      <View
        style={{
          flexDirection: 'column',
          position: 'absolute',
          bottom: 20,
          right: 20,
        }}>
        <Button
          rounded
          style={{
            backgroundColor: APP_BG_COLOR,
            width: 50,
            alignSelf: 'center',
            height: 50,
          }}>
          <Icon
            style={{color: TEXT_SUBTITLE, fontSize: 22}}
            name="pencil"
            type="MaterialCommunityIcons"
          />
        </Button>
        <Button
          rounded
          color={GREEN}
          style={styles.btnView}
          onPress={() => {
            navigation.navigate(NAV_TYPES.CAMERA_VIEW, {});
          }}>
          <Thumbnail circular source={ADD_STATUS} style={styles.thumbView} />
        </Button>
      </View>

      {/* <Fab
        active={true}
        direction="up"
        style={{backgroundColor: '#5067FF', position: 'absolute'}}
        position="bottomRight">
        <Thumbnail source={ADD_STATUS} />
        <Button style={{backgroundColor: '#EEF5F6'}}>
          <Icon
            style={{color: TEXT_SUBTITLE, fontSize: 24}}
            name="pencil"
            type="MaterialCommunityIcons"
          />
        </Button>
      </Fab> */}
    </Container>
  );
}
Example #19
Source File: _TextInput.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
render() {
    const {isFocused} = this.state;
    const {defaultItem, defaultLabel, defaultInput} = inputDefaultStyle;
    const {
      ref,
      isMandatory,
      placeholder,
      value,
      editable = true,
      leftIcon,
      rightIcon,
      labelStyle,
      containerStyle,
      inputStyle,
      leftIconType,
      rightIconType,
      rightIconColor,
      secureTextEntry,
      keyboardType,
      returnKeyType,
      getRef,
      refKey,
      maxLength,
      inlineImageLeft,
      inlineImagePadding,
      numberOfLines,
      returnKeyLabel,
      multiline,
      selectionColor,
      defaultValue,
      floatingLabel,
      textAlign,
    } = this.props;
    return (
      <Item
        floatingLabel={floatingLabel}
        style={[
          defaultItem,
          containerStyle,
          {
            borderBottomWidth: isFocused ? 2 : 2,
            borderBottomColor: isFocused ? GREEN : GREEN,
          },
        ]}>
        {/* <Icon style={{color: INPUT_ICON}} name={leftIcon} type={leftIconType} /> */}
        {/* <Label style={[defaultLabel, labelStyle]}> {placeholder}</Label> */}
        <Input
          ref={ref}
          selectionColor={selectionColor}
          maxLength={maxLength}
          editable={editable}
          value={value}
          secureTextEntry={secureTextEntry}
          style={[
            defaultInput,
            inputStyle,
            {color: !editable ? DISABLED_GRAY : INPUT_TEXT},
          ]}
          autoCapitalize="words"
          keyboardType={keyboardType}
          returnKeyType={returnKeyType}
          onChangeText={this.onChangeText}
          onSubmitEditing={this.onSubmitEditing}
          getRef={ref => getRef && getRef({refKey, ref})} //need to use getRef in case of floatingLabel
          inlineImageLeft={inlineImageLeft}
          inlineImagePadding={inlineImagePadding}
          numberOfLines={numberOfLines}
          returnKeyLabel={returnKeyLabel}
          onFocus={this.handleInputFocus}
          onBlur={this.handleInputBlur}
          multiline={multiline}
          onEndEditing={this.onEndEditing}
          autoFocus={this.props.autoFocus}
          defaultValue={defaultValue}
          textAlign={textAlign}
        />
        {rightIcon && (
          <Icon
            onPress={this.onRightIconPressed}
            style={{color: rightIconColor, fontSize: 16}}
            name={rightIcon}
            type={rightIconType}
          />
        )}

        <Icon
          // onPress={this.onRightIconPressed}
          style={{color: isMandatory ? RED : rightIconColor, fontSize: 8}}
          name={isMandatory ? 'asterisk' : ''}
          type={isMandatory ? 'Foundation' : ''}
        />
      </Item>
    );
  }
Example #20
Source File: CameraView.js    From WhatsApp-Clone with MIT License 4 votes vote down vote up
CameraView = ({navigation, onScanQrCode, isScanCode}) => {
  var [state, dispatch] = useReducer(statusReducer, statusState);
  var {loading, isFlashEnabled, isFrontCam} = state;

  const [imageClicked, setImageClicked] = useState('');
  var cameraRef = useRef('');

  const LoadingView = () => <LoadingComponent />;

  function performAction(camera) {
    if (isScanCode) {
      onScanQrCode();
    } else {
      takePicture(camera);
    }
  }

  const takePicture = async function(camera) {
    const options = {
      //   quality: 0.5,
      base64: true,
      quality: 0.6,
      orientation: RNCamera.Constants.Orientation.auto,
      pauseAfterCapture: true,
      fixOrientation: true,
    };
    const data = await cameraRef.current.takePictureAsync(options);
    // cameraRef.current.pausePreview();
    // console.log(data.uri);
    setImageClicked(data.uri);
  };

  function toggleViews(type) {
    switch (type) {
      case TOGGLE_CAMERA:
        dispatch({type: TOGGLE_CAMERA, payload: !isFrontCam});
        break;

      case TOGGLE_FLASH:
        dispatch({type: TOGGLE_FLASH, payload: !isFlashEnabled});
        break;
    }
  }

  return (
    <Root>
      <SafeAreaView style={styles.container}>
        <View style={styles.container}>
          <RNCamera
            autoFocus='on'
            // autoFocusPointOfInterest
            ref={cameraRef}
            useCamera2Api
            onTouchStart={Keyboard.dismiss}
            style={styles.preview}
            type={
              isFrontCam
                ? RNCamera.Constants.Type.front
                : RNCamera.Constants.Type.back
            }
            flashMode={
              isFlashEnabled
                ? RNCamera.Constants.FlashMode.on
                : RNCamera.Constants.FlashMode.off
            }
            barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
            onBarCodeRead={result => {
              if (isScanCode) {
                // console.log(result.data);
                onScanQrCode(result.data)
              }
            }}
            androidCameraPermissionOptions={{
              title: 'Permission to use camera',
              message: 'We need your permission to use your camera',
              buttonPositive: 'Ok',
              buttonNegative: 'Cancel',
            }}
            androidRecordAudioPermissionOptions={{
              title: 'Permission to use audio recording',
              message: 'We need your permission to use your audio',
              buttonPositive: 'Ok',
              buttonNegative: 'Cancel',
            }}>
            {({camera, status, recordAudioPermissionStatus}) => {
              if (status !== 'READY') return <LoadingView />;
              if (Platform.OS === 'ios') {
                return (
                  <KeyboardAvoidingView
                    behavior={'padding'}
                    onTouchStart={Keyboard.dismiss}
                    style={{width: '100%', height: '100%'}}>
                    {getMainView(camera)}
                  </KeyboardAvoidingView>
                );
              } else {
                return getMainView(camera);
              }
            }}
          </RNCamera>
        </View>
      </SafeAreaView>
    </Root>
  );

  function getMainView(camera) {
    return (
      <View style={{width: '100%', height: '100%'}}>
        <View style={styles.headerView}>
          <BorderlessButton
            style={styles.buttonStyle}
            onPress={() => navigation.goBack()}>
            <Icon
              name={Platform.OS === 'ios' ? 'ios-arrow-back' : 'md-arrow-back'}
              type="Ionicons"
              style={styles.leftIcon}
            />
          </BorderlessButton>

          <View
            style={{
              flexDirection: 'row',
              justifyContent: 'flex-end',
            }}>
            <BorderlessButton
              style={styles.buttonStyle}
              onPress={() => toggleViews(TOGGLE_CAMERA)}>
              <Icon
                name={
                  Platform.OS === 'ios'
                    ? isFrontCam
                      ? 'md-reverse-camera'
                      : 'md-reverse-camera'
                    : isFrontCam
                    ? 'md-reverse-camera'
                    : 'md-reverse-camera'
                }
                type="Ionicons"
                style={styles.leftIcon}
              />
            </BorderlessButton>

            <BorderlessButton
              style={styles.buttonStyle}
              onPress={() => toggleViews(TOGGLE_FLASH)}>
              <Icon
                name={
                  Platform.OS === 'ios'
                    ? isFlashEnabled
                      ? 'ios-flash'
                      : 'ios-flash-off'
                    : isFlashEnabled
                    ? 'md-flash'
                    : 'md-flash-off'
                }
                type="Ionicons"
                style={styles.leftIcon}
              />
            </BorderlessButton>
          </View>
        </View>
        {imageClicked === '' && !isScanCode && (
          <Button
            rounded
            onPress={() => performAction(camera)}
            style={styles.capture}>
            <Icon
              name="camera"
              type="MaterialCommunityIcons"
              style={styles.sendIcon}
            />
            {/* <Text style={{fontSize: 14}}> SNAP </Text> */}
          </Button>
        )}

        {imageClicked != '' && (
          <View style={styles.bottomView}>
            <ChatTextInput
              isStatus
              onSendMessage={status => {
                dispatch({type: LOADING, payload: true});
                uploadStatus(imageClicked, status, navigation, dispatch);
              }}
              onResetClick={() => {
                // cameraRef.current.resumePreview();
                setImageClicked('');
              }}
            />
          </View>
        )}

        {loading && <LoadingView />}
      </View>
    );
  }
}
Example #21
Source File: index.js    From expo-ticket-app with MIT License 4 votes vote down vote up
Index = (
  <Stack
    key="root"
  >
    <Scene
      initial
      hideNavBar
      type="replace"
      key="welcome"
      {...DefaultProps.navbarProps}
      component={LoginContainer}
      Layout={WelcomeComponent}
    />
    <Scene
      back
      key="login"
      {...DefaultProps.navbarProps}
      component={LoginContainer}
      Layout={LoginComponent}
    />
    <Scene
      back
      key="signUp"
      {...DefaultProps.navbarProps}
      component={SignUpContainer}
      Layout={SignUpComponent}
    />
    <Scene
      back
      key="forgotPassword"
      {...DefaultProps.navbarProps}
      component={ForgotPasswordContainer}
      Layout={ForgotPasswordComponent}
    />
    <Tabs
      hideNavBar
      showLabel={false}
      key="tabbar"
      tabBarPosition="bottom"
      type="reset"
      {...DefaultProps.tabProps}
    >
      <Stack
        hideNavBar
        key="home"
        icon={({focused}) => (
          <Icon
            type="FontAwesome"
            name="home"
            style={{color: focused ? '#FC1055' : '#CACDD4', fontSize: 25}}
          />
        )}
        {...DefaultProps.navbarProps}
      >
        <Scene key="home" component={HomeContainer} Layout={HomeComponent}/>
      </Stack>

      <Stack
        hideNavBar
        key="events"
        icon={({focused}) => (
          <Icon
            type="Ionicons"
            name="md-search"
            style={{color: focused ? '#FC1055' : '#CACDD4', fontSize: 25}}
          />
        )}
        {...DefaultProps.navbarProps}
      >
        <Scene
          key="eventsListing"
          component={EventsContainer}
          Layout={EventListingComponent}
        />

        <Scene
          back
          hideNavBar
          key="eventView"
          component={EventsContainer}
          Layout={EventViewComponent}
        />
      </Stack>

      <Stack
        hideNavBar
        key="tickets"
        icon={({focused}) => (
          <Icon
            type="FontAwesome"
            name="ticket"
            style={{color: focused ? '#FC1055' : '#CACDD4', fontSize: 22}}
          />
        )}
        {...DefaultProps.navbarProps}
      >
        <Scene
          key="ticketsListing"
          component={MemberContainer}
          Layout={TicketsListingComponent}
        />
        <Scene
          back
          key="ticketView"
          component={MemberContainer}
          Layout={TicketViewComponent}
        />
      </Stack>

      <Stack
        key="profile"
        icon={({focused}) => (
          <Icon
            name="person-circle"
            style={{color: focused ? '#FC1055' : '#CACDD4', fontSize: 25}}
          />
        )}
        {...DefaultProps.navbarProps}
      >
        <Scene
          hideNavBar
          key="profileHome"
          component={MemberContainer}
          Layout={ProfileComponent}
        />

        <Scene
          back
          key="updateProfile"
          {...DefaultProps.navbarProps}
          component={UpdateProfileContainer}
          Layout={UpdateProfileComponent}
        />

        <Scene
          back
          key="scan"
          {...DefaultProps.navbarProps}
          component={MemberContainer}
          Layout={ScanComponent}
        />
      </Stack>
    </Tabs>
  </Stack>
)
Example #22
Source File: Profile.js    From expo-ticket-app with MIT License 4 votes vote down vote up
Profile = ({ member, logout, switchLanguage }) => (
    <Container style={{ backgroundColor: commonColor.backgroundColor }}>
        <StatusBar style="light"/>
        <Content>
            <Spacer size={50}/>
            <List>
                {(member && member.email) ? (
                    <View>
                        <Content padder>
                            <Header
                                title={`${member.firstName}`}
                                content={`${i18n.t('profile.connectWith')} : ${member.email}`}
                            />
                        </Content>
                        <ListItem onPress={switchLanguage} icon>
                            <Left>
                                <Icon style={{ color: '#fff' }} name="language"
                                      type="MaterialIcons"/>
                            </Left>
                            <Body style={{
                                flexDirection: 'row',
                                justifyContent: 'flex-start',
                                alignItems: 'center',
                            }}>
                                <TextI18n>
                                    global.currentLanguage
                                </TextI18n>
                                <TextH2t style={{ fontSize: 20, marginRight: 20 }}>
                                    {member.locale === 'fr' && 'Fr ??'}
                                    {member.locale === 'en' && 'En ??'}
                                </TextH2t>
                            </Body>
                        </ListItem>
                        <ListItem onPress={Actions.updateProfile} icon>
                            <Left>
                                <Icon style={{ color: '#fff' }} name="person-add"/>
                            </Left>
                            <Body>
                                <TextI18n>profile.myAccount</TextI18n>
                            </Body>
                        </ListItem>
                        <ListItem onPress={logout} icon>
                            <Left>
                                <Icon style={{ color: '#fff' }} name="power"/>
                            </Left>
                            <Body>
                                <TextI18n>profile.logout</TextI18n>
                            </Body>
                        </ListItem>
                        <Spacer size={20}/>
                        {member.role && member.role.toLowerCase().includes('admin') &&
                        <ListItem onPress={Actions.scan} icon>
                            <Left>
                                <Icon style={{ fontSize: 23, color: '#fff' }} type="AntDesign" name="scan1"/>
                            </Left>
                            <Body>
                                <TextI18n>profile.scan</TextI18n>
                            </Body>
                        </ListItem>}
                    </View>
                ) : (
                    <View>
                        <Spacer size={40}/>
                        <ListItem onPress={switchLanguage} icon>
                            <Left>
                                <Icon style={{ color: '#fff' }} name="language"
                                      type="MaterialIcons"/>
                            </Left>
                            <Body style={{
                                flexDirection: 'row',
                                justifyContent: 'flex-start',
                                alignItems: 'center',
                                borderBottomWidth: 0,
                            }}>
                                <TextI18n>
                                    global.currentLanguage
                                </TextI18n>
                                <TextH2t style={{ fontSize: 20, marginRight: 20 }}>
                                    {member.locale === 'fr' ? 'Fr ??' : 'En ??'}
                                </TextH2t>
                            </Body>
                        </ListItem>
                        <CardH2t
                            source={require('../../../images/Events/account.jpg')}
                            onPress={Actions.login}
                            text1="login.connect"
                            text2="login.connectText"
                        />
                        <CardH2t
                            source={require('../../../images/Events/signIn.jpg')}
                            onPress={Actions.signUp}
                            text1="login.signUp"
                            text2="login.signUpText"
                        />
                        <Spacer size={80}/>
                    </View>
                )}
            </List>
        </Content>
    </Container>
)
Example #23
Source File: Login.js    From expo-ticket-app with MIT License 4 votes vote down vote up
render () {
        const { loading, error, success } = this.props;
        const { email } = this.state;

        return (
            <KeyboardAvoidingView
                style={{ backgroundColor: commonColor.backgroundColor, flex: 1 }}
                behavior={(Platform.OS === 'ios') ? 'padding' : null}
                enabled
                keyboardVerticalOffset={Platform.select({ ios: 80, android: 500 })}>
                <StatusBar style="light"/>
                <ScrollView>
                    <Container style={{ backgroundColor: commonColor.backgroundColor }}>
                        <Content padder>
                            <Spacer size={60}/>
                            <Text style={{
                                flex: 1,
                                fontSize: 75,
                                fontWeight: '400',
                                fontFamily: 'Montserrat_Bold',
                                color: 'white',
                                textAlign: 'center',
                            }}>
                                {'H2T.'}
                            </Text>
                            <Spacer size={60}/>
                            <Card style={{ backgroundColor: commonColor.backgroundColor }}>
                                {error && <View style={{ margin: 10 }}><Messages message={error}/></View>}
                                {success &&
                                <View style={{ margin: 10 }}><Messages type="success" message={success}/></View>}
                                <Form>
                                    <Item floatingLabel style={{ margin: 15 }}>
                                        <Label style={{
                                            color: '#fff',
                                            fontFamily: 'Montserrat',
                                        }}>{i18n.t('login.fields.email')}</Label>
                                        <Input
                                            style={{ color: '#fff', fontFamily: 'Montserrat' }}
                                            autoCapitalize="none"
                                            value={email}
                                            keyboardType="email-address"
                                            disabled={loading}
                                            returnKeyType={'next'}
                                            onChangeText={v => this.handleChange('email', v)}
                                            onSubmitEditing={() => { this.focusTheField('field2'); }}
                                            blurOnSubmit={false}
                                        />
                                    </Item>
                                    <Item floatingLabel style={{ margin: 15 }}>
                                        <Label style={{
                                            color: '#fff',
                                            fontFamily: 'Montserrat',
                                        }}>{i18n.t('login.fields.password')}</Label>
                                        <Input
                                            getRef={input => { this.inputs['field2'] = input; }}
                                            style={{ color: '#fff', fontFamily: 'Montserrat' }}
                                            secureTextEntry
                                            disabled={loading}
                                            returnKeyType={'go'}
                                            onChangeText={v => this.handleChange('password', v)}
                                            onSubmitEditing={this.handleSubmit}
                                        />
                                    </Item>

                                    <Spacer size={20}/>

                                    <ButtonH2t text={'login.connect'} loading={loading} onPress={this.handleSubmit}/>
                                </Form>
                                <ListItem onPress={Actions.forgotPassword} icon>
                                    <Left>
                                        <Icon style={{ color: 'white' }} name="help-buoy"/>
                                    </Left>
                                    <Body style={{ borderBottomWidth: 0 }}>
                                        <TextI18n style={{ color: 'white' }}>
                                            login.forgotPassword
                                        </TextI18n>
                                    </Body>
                                </ListItem>
                            </Card>
                        </Content>
                    </Container>
                </ScrollView>
            </KeyboardAvoidingView>
        );
    }
Example #24
Source File: TicketsListing.js    From expo-ticket-app with MIT License 4 votes vote down vote up
TicketsListing = ({ member, loading, reFetch }) => (
    <Container>
        <ImageBackground
            source={require('../../../images/Tickets/no-tickets.png')}
            imageStyle={{
                resizeMode: 'stretch',
                height: 650,
            }}
            style={{
                width: '100%',
                flex: 1,
                backgroundColor: commonColor.backgroundColor,
            }}>
            <StatusBar style="light"/>
            <TextI18n style={{ fontSize: 30, margin: 50, marginBottom: 10, marginLeft: 10 }}>
                tickets.title
            </TextI18n>
            <Content padder refreshControl={(
                <RefreshControl
                    refreshing={loading}
                    onRefresh={reFetch}
                    title="Pull to refresh"
                    tintColor="#fff"
                    titleColor="#fff"
                    colors={["#000", "#fff", "#000"]}
                />
            )}>
                {(member && member.tickets && member.tickets.length)
                    ? (<View>
                        <Spacer size={30}/>
                        <FlatList
                            data={member.tickets}
                            renderItem={({ item, index }) =>
                                (<TouchableOpacity disabled={item.scanned === true}
                                                   onPress={() => Actions.ticketView({ ticket: item })}
                                                   style={{ flex: 1, paddingBottom: 12 }}>
                                    <View style={{
                                        flex: 1,
                                        flexDirection: 'row',
                                        alignItems: 'center',
                                        justifyContent: 'center',
                                        backgroundColor: commonColor.backgroundColor,
                                        borderRadius: 10,
                                        shadowColor: '#000',
                                        shadowOffset: {
                                            width: 0,
                                            height: 3,
                                        },
                                        shadowOpacity: 0.29,
                                        shadowRadius: 4.65,
                                        elevation: 7,
                                        marginLeft: 10,
                                        marginRight: 10,
                                        opacity: item.scanned === true ? 0.6 : 1,
                                        zIndex: 1,
                                    }}>
                                        {item.scanned === true && <View style={{
                                            flex: 1,
                                            flexDirection: 'row',
                                            alignItems: 'center',
                                            justifyContent: 'center',
                                            position: 'absolute',
                                            zIndex: 10,
                                        }}>
                                            <TextI18n style={{
                                                color: '#fff',
                                                fontSize: 25,
                                                fontFamily: 'Montserrat_Bold',
                                            }}>
                                                tickets.scanned
                                            </TextI18n>
                                        </View>}
                                        <View style={{
                                            borderColor: '#FFE5EC',
                                            borderRadius: 100,
                                            borderWidth: 7,
                                            backgroundColor: '#FFE5EC',
                                            margin: 10,
                                            marginRight: 10,
                                        }}>
                                            <Icon
                                                name="ticket"
                                                type="MaterialCommunityIcons"
                                                style={{ color: commonColor.brandStyle, fontSize: 30 }}
                                            />
                                        </View>
                                        <View style={{ flex: 1, padding: 5, marginRight: 5 }}>
                                            <View style={{
                                                flex: 1,
                                                flexDirection: 'row',
                                                alignItems: 'center',
                                                justifyContent: 'space-between',
                                            }}>
                                                <TextH2t style={{ fontSize: 15 }}>
                                                    {item.title ? (item.title.length > 22) ? ((item.title.substring(0, 22 - 3)) + '...') : item.title : ''}
                                                </TextH2t>
                                                <TextH2t style={{ fontSize: 13 }}>
                                                    {item.date ? item.date : ''}
                                                </TextH2t>
                                            </View>
                                            <View style={{
                                                flex: 1,
                                                flexDirection: 'row',
                                                alignItems: 'center',
                                                justifyContent: 'space-between',
                                            }}>
                                                <View style={{ flexDirection: 'row' }}>
                                                    <Icon type="FontAwesome5" name="music"
                                                          style={{ fontSize: 16, color: '#b3b5bb', paddingRight: 5 }}/>
                                                    <TextH2t style={{ color: '#b3b5bb', fontSize: 13 }}>Techno</TextH2t>
                                                </View>
                                                <TextH2t style={{ color: '#b3b5bb', fontSize: 13 }}>
                                                    {item.hour ? item.hour : ''}
                                                </TextH2t>
                                            </View>
                                        </View>
                                    </View>
                                </TouchableOpacity>)}
                            keyExtractor={(index) => {return index.uuid;}}
                        />

                    </View>) : (
                        <View>
                            <Spacer size={100}/>
                            <TextI18n style={{ fontSize: 30, textAlign: 'center', fontFamily: 'Montserrat_Bold' }}>
                               tickets.noTickets
                            </TextI18n>
                            <TextI18n style={{ fontSize: 15, textAlign: 'center' }}>
                                tickets.noTicketsInfo
                            </TextI18n>
                        </View>
                    )}
                <Spacer size={20}/>
            </Content>
        </ImageBackground>
    </Container>
)
Example #25
Source File: EventsListing.js    From expo-ticket-app with MIT License 4 votes vote down vote up
EventsListing = ({ loading, events, reFetch }) => {

    const onPress = index => Actions.eventView({ match: { params: { id: String(index) } } });

    return (
        <Container style={{ backgroundColor: commonColor.backgroundColor }}>
            <StatusBar style="light"/>
            <TextI18n style={{ color: '#ffffff', fontSize: 30, margin: 50, marginBottom: 10, marginLeft: 10 }}>
                events.title
            </TextI18n>
            <Content padder refreshControl={(
                <RefreshControl
                    refreshing={loading}
                    onRefresh={reFetch}
                    title="Pull to refresh"
                    tintColor="#fff"
                    titleColor="#fff"
                    colors={['#000', '#fff', '#000']}
                />
            )}>
                <FlatList
                    data={events}
                    renderItem={({ item, index }) => (
                        <TouchableOpacity onPress={() => onPress(index)} style={{ flex: 1 }}>
                            <View style={{
                                flex: 1,
                                flexDirection: 'column',
                                justifyContent: 'center',
                            }}>
                                <View style={{
                                    shadowColor: '#000',
                                    shadowOffset: {
                                        width: 0,
                                        height: 6,
                                    },
                                    shadowOpacity: 0.39,
                                    shadowRadius: 8.30,
                                    elevation: 13,
                                    borderRadius: 5,
                                    position: 'absolute',
                                    backgroundColor: commonColor.brandStyle,
                                    width: 100,
                                    height: 34,
                                    top: 150 + ((deviceWidth > 400) ? 40 : 20),
                                    right: 40,
                                    zIndex: 1000,
                                    alignItems: 'center',
                                    justifyContent: 'center',
                                }}>
                                    <TextH2t style={{ color: '#ffffff', fontSize: 18 }}>
                                        {item.price ? item.price + ' $' : 'Free'}
                                    </TextH2t>
                                </View>
                                <View style={{
                                    shadowColor: '#000',
                                    shadowOffset: {
                                        width: 0,
                                        height: 3,
                                    },
                                    shadowOpacity: 0.29,
                                    shadowRadius: 4.65,
                                    elevation: 8,
                                    borderRadius: 5,
                                    flex: 1,
                                }}>
                                    <Image
                                        source={{ uri: item.image ? item.image : '' }}
                                        style={{
                                            width: '100%',
                                            aspectRatio: 1.85,
                                            resizeMode: 'stretch',
                                            borderRadius: (Platform.OS === 'ios') ? 5 : 10,
                                        }}
                                    />
                                </View>
                                <View style={{ flex: 1, padding: 10 }}>
                                    <TextH2t style={{ color: '#ffffff', fontSize: 16 }}>
                                        {item.date}
                                    </TextH2t>
                                    <TextH2t style={{ color: '#ffffff', fontSize: 23, fontFamily: 'Montserrat_Bold' }}>
                                        {item.title}
                                    </TextH2t>
                                    <TextH2t style={{ color: '#b3b5bb', fontSize: 13 }}>
                                        {item.hour}
                                    </TextH2t>
                                    <View style={{
                                        flexDirection: 'row',
                                        alignItems: 'center',
                                        justifyContent: 'space-between',
                                    }}>
                                        <View style={{ flexDirection: 'row' }}>
                                            <TextH2t style={{ color: '#b3b5bb', fontSize: 13 }}># Techno</TextH2t>
                                        </View>
                                        <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
                                            <Icon type="FontAwesome" name="ticket"
                                                  style={{ fontSize: 17, color: '#b3b5bb', paddingRight: 5 }}/>
                                            <TextH2t style={{
                                                color: '#b3b5bb',
                                                fontSize: 13,
                                            }}>{item.tickets > 0 ? `${item.tickets} ${i18n.t('events.available')}` : i18n.t('events.full')}</TextH2t>
                                        </View>
                                    </View>
                                </View>
                            </View>
                        </TouchableOpacity>
                    )}
                    keyExtractor={(item, index) => (`list-item-${index}`)}
                />
                <Spacer size={20}/>
            </Content>
        </Container>
    );
}
Example #26
Source File: EventView.js    From expo-ticket-app with MIT License 4 votes vote down vote up
EventView = ({ events, eventId, loading, buyTicket, onCardChange, buyDisabled, member }) => {
    let event = null;
    if (eventId && events) {
        event = events[eventId];
    }

    if (!event) return <Error content={'errors.events404'}/>;

    const [isModalVisibleCard, setModalVisibleCard] = useState(false);

    return (
        <KeyboardAvoidingView
            style={{ backgroundColor: commonColor.backgroundColor, flex: 1 }}
            behavior={(Platform.OS === 'ios') ? 'padding' : null}
            enabled
            keyboardVerticalOffset={Platform.select({ ios: 80, android: 500 })}>
            <Container style={{ backgroundColor: commonColor.backgroundColor }}>
                <StatusBar style="light"/>
                <Content padder>
                    <Spacer size={15}/>
                    <Card style={{ borderRadius: 10, backgroundColor: commonColor.backgroundColorLighter }}>
                        <Image
                            source={{ uri: event.image ? event.image : '' }}
                            style={{
                                height: 200,
                                width: '100%',
                                resizeMode: 'stretch',
                                borderTopLeftRadius: 10,
                                borderTopRightRadius: 10,
                            }}/>
                        <CardItem style={{
                            borderBottomRightRadius: 10,
                            borderBottomLeftRadius: 10,
                            backgroundColor: commonColor.backgroundColorLighter,
                        }}>
                            <Body>
                                <TextH2t style={{
                                    fontSize: 30,
                                    fontFamily: 'Montserrat_Bold',
                                    alignSelf: 'center',
                                }}>{event.title}</TextH2t>
                                <TextH2t style={{
                                    fontSize: 20,
                                    fontFamily: 'Montserrat',
                                    alignSelf: 'center',
                                }}>{event.date}</TextH2t>
                                <TextH2t style={{
                                    fontSize: 20,
                                    fontFamily: 'Montserrat',
                                    alignSelf: 'center',
                                }}>{event.hour}</TextH2t>
                            </Body>
                        </CardItem>
                    </Card>
                    <Spacer size={15}/>
                    {event.tickets !== undefined && event.tickets > 0 && member.email &&
                        <ButtonH2t
                            onPress={() => setModalVisibleCard(true)}
                            icon
                            loading={loading}
                            text="events.buyTicket"
                        />
                    }
                    <Spacer size={15}/>
                    <Card style={{ backgroundColor: commonColor.backgroundColorLighter, borderRadius: 10 }}>
                        <CardItem style={{
                            backgroundColor: commonColor.backgroundColorLighter,
                            borderRadius: 10,
                            flexDirection: 'row',
                        }}>
                            <Icon type="FontAwesome" name="ticket"
                                  style={{ fontSize: 17, color: '#b3b5bb', paddingRight: 5 }}/>
                            <TextH2t style={{ color: '#b3b5bb' }}>
                                {event.tickets > 0 ? `${event.tickets} ${i18n.t('events.available')}` : i18n.t('events.full')}
                            </TextH2t>
                        </CardItem>
                        <CardItem style={{ backgroundColor: commonColor.backgroundColorLighter, borderRadius: 10 }}>
                            <TextH2t>{event.description}</TextH2t>
                        </CardItem>
                    </Card>
                    <Spacer size={15}/>

                    <Card>
                        {event.locations && <CardItem style={{ backgroundColor: commonColor.backgroundColorLighter }}>
                            <Icon type="MaterialCommunityIcons" name="google-maps"
                                  style={{ color: 'white', fontSize: 26 }}/>
                            <TextH2t style={{ textDecorationLine: 'underline' }}
                                     onPress={() => Linking.openURL('https://www.google.com/maps/place/' + event.locations)}>Link</TextH2t>
                        </CardItem>}
                    </Card>

                    <Spacer size={20}/>
                </Content>

                <Modal
                    isVisible={isModalVisibleCard}
                    backdropOpacity={0.7}
                    onBackdropPress={() => setModalVisibleCard(false)}
                    onSwipeComplete={() => setModalVisibleCard(false)}
                    swipeDirection={['down']}
                    style={{ margin: 0 }}
                    propagateSwipe
                >
                    <Spacer size={10}/>
                    <View style={{
                        width: 50,
                        height: 5,
                        backgroundColor: '#fff',
                        borderRadius: 20,
                        alignSelf: 'center',
                        margin: 10,
                    }}/>
                    <ScrollView contentContainerStyle={{
                        backgroundColor: commonColor.backgroundColorLighter,
                        borderTopLeftRadius: 10,
                        borderTopRightRadius: 10,
                        borderWidth: 10,
                        borderColor: commonColor.backgroundColorLighter,
                        flexGrow: 2,
                    }}>
                        <Card style={{ backgroundColor: commonColor.backgroundColorLighter }}>
                            <CardItem style={{
                                backgroundColor: commonColor.backgroundColorLighter,
                                flexDirection: 'row',
                                justifyContent: 'space-between',
                                marginBottom: 20,
                            }}>
                                <TextH2t style={{ fontSize: 18 }}>{event.title} X 1</TextH2t>
                                <TextH2t style={{ fontSize: 18 }}>{event.price} $</TextH2t>
                            </CardItem>
                            <LiteCreditCardInput
                                inputStyle={{ fontFamily: 'Montserrat', color: 'white', fontSize: 20 }}
                                labelStyle={{ fontFamily: 'Montserrat_Bold', color: 'white', fontSize: 15 }}
                                validColor={'#fff'}
                                onChange={(form) => onCardChange(form)}
                                requiresCVC={true}
                            />
                            <CardItem style={{
                                backgroundColor: commonColor.backgroundColorLighter,
                                flexDirection: 'row',
                                justifyContent: 'space-between',
                                marginTop: 30,
                            }}>
                                <TextH2t style={{ fontSize: 11 }}>
                                    By confirming your order you accept H2T Terms of Use.
                                </TextH2t>
                            </CardItem>
                            {event.tickets !== undefined && event.tickets > 0 && member.email &&
                                <ButtonH2t
                                    onPress={async () => {
                                        await buyTicket(event.id);
                                        setModalVisibleCard(false);
                                    }}
                                    disabled={buyDisabled}
                                    loading={loading} text="events.pay"
                                    style={{ flex: 0 }}
                                />
                            }
                            <Spacer size={20}/>
                        </Card>
                    </ScrollView>
                </Modal>
            </Container>
        </KeyboardAvoidingView>
    );
}
Example #27
Source File: FindPeopleScreen.js    From SocialApp-React-Native with MIT License 4 votes vote down vote up
FindPeopleScreen = (props) => {

    const findPeopleUsers = useSelector(state => state.users.findPeople);

    const [isLoading, setIsLoading] = useState(false);
    const [isRefreshing, setIsRefreshing] = useState(false);
    const [error, setError] = useState();
    const [searchText, setSearchText] = useState('');
    const [data, setData] = useState([]);

    const dispatch = useDispatch();


    const loadFindPeople = useCallback(async () => {
        setError(null);
        setIsRefreshing(true);
        try {
            const result = await dispatch(usersActions.fetchFindPeopleUsers());
            let verifiedUsers =  result.filter(e => VerifiedUser.verifiedUsersId.includes(e._id));
            let otherUsers = result.filter(e => !VerifiedUser.verifiedUsersId.includes(e._id));
            let updatedResult = [...verifiedUsers, ...otherUsers];
            setData(updatedResult);
        } catch (err) {
            setError(err.message);
        }
        setIsRefreshing(false);
    }, [dispatch, setIsLoading, setError])

    
    useEffect(() => {
        setIsLoading(true);
        loadFindPeople()
        .then(() => {
            setIsLoading(false);
        });
    }, [dispatch, loadFindPeople])


    // useEffect(() => {
    //     const unsubscribe = props.navigation.addListener('focus', e => {
    //         setSearchText('');
    //         setData(findPeopleUsers);
    //     });
    //     return () => {
    //         unsubscribe();
    //     };
    // }, [])


    const handleSearchTextChange = (text) => {
        setSearchText(text);
        if(text !== ''){
            let filteredData = []
            let currData = findPeopleUsers;

            filteredData = currData.filter(item => {
                const lc = item.name.toLowerCase();
                const lcEmail = item.email.toLowerCase();
                text = text.toLowerCase();
                return lc.includes(text) || lcEmail.includes(text);
            });
            setData(filteredData);
        } else {
            setData(findPeopleUsers);
        }
    }


    const followHandlerForData = (id) => {
        //follow handler to remove item from search data i.e. data state
        let searchData = data;
        searchData = searchData.filter(i => i._id !== id);
        setData(searchData);
    }



    if(error){
        return (
            <View style={styles.centered} >
                <Text>An error occured.</Text>
                <Button onPress={loadFindPeople} color={Colors.primary} >
                    <Text>Try again</Text>
                </Button>
            </View>
        );
    }


    if(isLoading){
        return (
            <View style={styles.centered} >
                <ActivityIndicator size='large' color={Colors.primary} />
            </View>
        );
    }

    return (
        <Container style={{ backgroundColor: '#fff' }} >
            <Header style={{ backgroundColor: Colors.brightBlue }} searchBar rounded>
                <Item>
                    <Icon name="ios-search" />
                    <Input
                        value={searchText}
                        onChangeText={(text) => handleSearchTextChange(text)}
                        placeholder={`Search by name or email...`}
                    />
                    <Text>{data.length}</Text>
                    <Icon name="ios-people"  />
                </Item>
            </Header>
            { data.length === 0 && (
                <View style={styles.centered}>
                    <Text style={{ fontSize: 18, margin: 10 }} >No users found.</Text>
                    <Text>Either you are already following the user</Text>
                    <Text>or no user exists with that name.</Text>
                </View>
            ) }
            <FlatList
                style={styles.list}
                refreshing={isRefreshing}
                onRefresh={loadFindPeople}
                contentContainerStyle={styles.listContainer}
                data={data}
                horizontal={false}
                numColumns={2}
                keyExtractor={(item) => {
                    return item._id;
                }}
                renderItem={({ item }) => (
                    <UserList item={item} followHandler={followHandlerForData} />
                )} 
            />
        </Container>
    );
}
Example #28
Source File: ChatListScreen.js    From SocialApp-React-Native with MIT License 4 votes vote down vote up
ChatListScreen = (props) => {

    const loggedUser = useSelector(state => state.auth.user);
    const chatList = useSelector(state => state.chat.chatList);
    const allChats = useSelector(state => state.chat.allChats);
    let allUsers = useSelector(state => state.users.allUsers);

    // remove logged user from the list
    allUsers = allUsers.filter(item => item._id !== loggedUser._id);


    const [isLoading, setIsLoading] = useState(false);
    const [isRefreshing, setIsRefreshing] = useState(false);
    const [searchText, setSearchText] = useState('');
    const [data, setData] = useState(chatList);


    const dispatch = useDispatch();

    const loadChatList = useCallback(async () => {
        setIsRefreshing(true);
        try {
            const result = await dispatch(chatActions.fetchChatList());
            await dispatch(chatActions.fetchChats());
            setData(result);
        } catch (err) {
            console.log(err)
        }
        setIsRefreshing(false);
    }, [dispatch, setIsLoading])

    const loadChats = useCallback(async () => {
        try {
            await dispatch(chatActions.fetchChats());
        } catch (err) {
            console.log(err)
        }
    }, [dispatch, setIsLoading])


    // useEffect(() => {
    //     const unsubscribe = props.navigation.addListener('focus', e => {
    //         setSearchText('');
    //         loadChatList();
    //     });
    //     return () => {
    //         unsubscribe();
    //     };
    // }, [])

    useEffect(() => {
        setIsLoading(true);
        loadChats()
        .then(() => {
            setIsLoading(false);
        });
        setIsLoading(false)
    }, [dispatch, loadChats])

    const handleSearchTextChange = (text) => {
        setSearchText(text);
        if(text !== ''){
            let filteredData = []
            let currData = allUsers;

            filteredData = currData.filter(item => {
                const lc = item.name.toLowerCase();
                text = text.toLowerCase();
                return lc.includes(text);
            });
            setData(filteredData);
        } else {
            setData(chatList);
        }
    }   


    if (isLoading) {
        return (
            <View style={styles.centered} >
                <ActivityIndicator size='large' color={Colors.primary} />
            </View>
        );
    }

    return (
        <Container>
            <Header style={{ backgroundColor: Colors.brightBlue }} searchBar rounded>
                <Item>
                    <Icon name="ios-search" />
                    <Input
                        value={searchText}
                        onChangeText={(text) => handleSearchTextChange(text)}
                        placeholder="Search" 
                    />
                    <Icon name="ios-people" />
                </Item>
            </Header>
            { data.length === 0 && (
                <View style={styles.centered}>
                    <Text>No chats !</Text>
                    <Text>Either your search does not match any user's name</Text>
                    <Text>or you have no chats.</Text>
                    <Text>Please refresh if you have new chats.</Text>
                </View>
            ) }
            <FlatList
                data={data}
                refreshing={isRefreshing}
                onRefresh={loadChatList}
                keyExtractor={(item) => item._id}
                renderItem={(user) => (
                    <ChatListItem user={user.item} />
                )}
            />
        </Container>
    );
}