Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working on android React-Native 0.7x #519

Open
PhamMinhKha opened this issue Mar 29, 2024 · 1 comment
Open

not working on android React-Native 0.7x #519

PhamMinhKha opened this issue Mar 29, 2024 · 1 comment

Comments

@PhamMinhKha
Copy link

It's not working and not showing any errors on Android, but it works fine on iOS.

Version & Platform

├─┬ @react-native-masked-view/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-picker/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ ├─┬ @react-navigation/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @realm/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ @types/[email protected]
│ └─┬ @react-native/[email protected]
│   └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├── [email protected]
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└─┬ [email protected]
  └── [email protected] deduped

Platform: Android

We will notify an error to fix.

Actual behavior: Nothing appears.

Steps to reproduce the behavior

import {
  View,
  Text,
  TextInput,
  TouchableOpacity,
  Image,
  ScrollView,
} from 'react-native';
import React, { useState, useRef } from 'react';
import { useTheme, useSetting } from '@/hooks';
import { PrintLabel } from '@/utilities/PrinterFunction';
import ViewShot, { ViewShotProperties } from 'react-native-view-shot';
export default function InTem() {
  const viewShot = useRef<any | ViewShotProperties>();
  const { tencuahang, sdt } = useSetting();
  const { Layout, Colors, Gutters, Common, Fonts } = useTheme();
  const Logo = require('../../theme/assets/images/full_logo_ngang.png');
  // const [setting, SetSetting] = useState<Config>({
  //   tencuahang,
  //   diachi,
  //   sdt,
  //   mayin,
  //   loichao,
  //   loitambiet,
  //   tennhanvien,
  // });
  const [info, setInfo] = useState({
    nguoinhan: '',
    sodienthoai: '',
    diachi: '',
  });
  async function inTemRa() {
    console.log('InTem');
    viewShot.current.capture().then((base64: any) => {
      console.log('do something with ', base64);
      PrintLabel(base64);
    });
  }
  return (
    <View style={[Layout.fill, Gutters.tinyPadding]}>
      <Text>Tên người nhận</Text>
      <TextInput
        style={[Common.textInput]}
        onChangeText={e => setInfo({ ...info, nguoinhan: e })}
      />
      <Text>Số điện thoại</Text>
      <TextInput
        style={[Common.textInput]}
        onChangeText={e => setInfo({ ...info, sodienthoai: e })}
      />
      <Text>Địa chỉ</Text>
      <TextInput
        style={[Common.textInput]}
        onChangeText={e => setInfo({ ...info, diachi: e })}
      />
      <TouchableOpacity
        style={[
          Common.button.rounded,
          Gutters.regularBMargin,
          { backgroundColor: Colors.success },
        ]}
        onPress={inTemRa}
      >
        <Text>In tem</Text>
      </TouchableOpacity>
      <ViewShot
        ref={viewShot}
        style={{ flex: 1 }}
        options={{ result: 'base64' }}
      >
        <ScrollView style={{ flex: 1 }}>
          <View
            style={[
              Layout.alignItemsCenter,
              Gutters.tinyPadding,
              Layout.scrollSpaceBetween,
              {
                backgroundColor: Colors.white,
                width: 569,
                height: 378,
                marginTop: 10,
                marginBottom: 10,
                transform: [
                  {
                    rotate: '90deg',
                  },
                ],
                top: 80,
              },
            ]}
          >
            <Image source={Logo} />
            <View style={[Layout.alignItemsCenter]}>
              <Text style={[Fonts.textRegular]}>
                Người Nhận: {info.nguoinhan}
              </Text>
              <Text style={[Fonts.textRegular]}>
                Điện thoại: {info.sodienthoai}
              </Text>
              <Text style={[Fonts.textRegular]}>{info.diachi}</Text>
            </View>
            <Text style={[Fonts.textRegular]}>
              Người gửi: {tencuahang} - ĐT: {sdt}
            </Text>
          </View>
        </ScrollView>
      </ViewShot>
    </View>
  );
}

@PhamMinhKha PhamMinhKha changed the title not working on ios RN0.76.4 not working on ios RN0.72.6 Mar 29, 2024
@PhamMinhKha PhamMinhKha changed the title not working on ios RN0.72.6 not working on ios RN0.7x Mar 29, 2024
@PhamMinhKha PhamMinhKha changed the title not working on ios RN0.7x not working on ios React-Native 0.7x Mar 29, 2024
@PhamMinhKha PhamMinhKha changed the title not working on ios React-Native 0.7x not working on android React-Native 0.7x Mar 29, 2024
@kuldipopenxcell
Copy link

kuldipopenxcell commented May 2, 2024

I got the same issue, it does not work on android and not showing any error logs

const MapPage = () => {
  const captureMap = async () => {
    try {
      // Capture map as image
      const uri = await mapRef.current.capture();
      console.log('uri', uri);
    } catch (error) {
      console.error('Error:', error);
      Alert.alert('Error', 'Failed to save PDF.');
    }
  };
    return (
      <View style={styles.container}>
          <ViewShot ref={mapRef} style={{flex: 1}}>
          <MapView
                    ref={mapRef}
                    style={{flex: 1}}
                    scrollEnabled={false}
                    provider={PROVIDER_GOOGLE}
                    initialRegion={{
                      latitude: 55.8622166,
                      longitude: 12.388021,
                      latitudeDelta: 0.0922,
                      longitudeDelta: 0.0421,
                    }}
                    onTouchStart={handleTouchStart}
                    onPanDrag={handlePanDrag}
                    onTouchEnd={handleTouchEnd}>
                    {lines.map((line, index) => (
                      <Polyline
                        key={index}
                        coordinates={line}
                        strokeColor="#FF0000"
                        strokeWidth={3}
                      />
                    ))}
                  </MapView>
           </ViewShot>
           <Button label="Capture screenshot" onPress={captureMap} />
    </View>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants