当前位置: 首页 > news >正文

项目公共组件代码

弹出框标题

				<Textstyle={{marginTop: 20,marginBottom: 5,fontSize: 20,textAlign: 'center',fontWeight: 'bold',color: 'black',}}>{data.language.CROUPLIST_CLASS_MEMBERS}</Text>

可以复用的公共体

import React, {useContext, useEffect, useState} from 'react';
import {View,Text,SafeAreaView,Dimensions,TouchableOpacity,StyleSheet,Image,
} from 'react-native';
import {Button} from 'react-native-paper';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import {deviceList,
} from '../../../api/index';
import Store from '../../../stores/index';
import theme from '../../../styles/theme.json';
const {width, height} = Dimensions.get('window');const BleExample = ({route, navigation}) => {const insets = useSafeAreaInsets();const [fullScreenHeight, setFullScreenHeight] = useState(height);const {data} = useContext(Store);useEffect(() => {// 计算全屏高度,包括刘海区域setFullScreenHeight(height - insets.top);}, [insets]);return (<SafeAreaViewstyle={{backgroundColor: '#FFFFFF',width: width,height: height,}}><View style={[styles.linearGradient, {height: fullScreenHeight}]}><View style={styles.container}><View style={[styles.titleItem1]}><TouchableOpacityonPress={() => {navigation.goBack();}}><Imagesource={require('../../../static/image/img_arrow-back.png')}style={{height: 40, width: 40}}/></TouchableOpacity></View><View style={[styles.titleItem]}><Textstyle={{textAlign: 'left',fontSize: 20,fontWeight: 'bold',color: '#000000',}}>{data.language.DEVICE_TITLE_MYDEVICE}</Text></View></View><Viewstyle={{flex: 1,flexDirection: 'column',height: height,justifyContent: 'space-between',paddingBottom: 30,}}><Viewstyle={{flexDirection: 'column',alignItems: 'center',height: '80%',}}></View><Viewstyle={[{flexDirection: 'row',justifyContent: 'center',alignItems: 'center',},]}><Buttonmode="contained"textColor={theme.REGIST_BTN_COLOR}buttonColor={theme.LOGIN_BTN_COLOR}style={styles.Account}contentStyle={{height: 50}}labelStyle={{fontSize: 20}}onPress={() => {navigation.navigate('AddManageMent');}}>{data.language.DEVICE_BTN_ADD}</Button></View></View></View></SafeAreaView>);
};export default BleExample;const styles = StyleSheet.create({linearGradient: {paddingTop: 20,height: height,},container: {width: width,height: height / 15,position: 'relative',},titleItem1: {position: 'absolute',width: width,height: height / 15,flexDirection: 'row',alignItems: 'center',zIndex: 1,},titleItem: {position: 'absolute',width: width,height: height / 15,flexDirection: 'row',justifyContent: 'center',alignItems: 'center',},Account: {width: width / 1.1,borderRadius: 10,},
});

toast

import Toast from '../../../components/Toast';const [toastflag, setToastFlag] = useState(false); // 添加成功的toastconst [title, setTitle] = useState(''); // 提示框内容setTitle('添加成功');setToastFlag(true);setTimeout(() => {setToastFlag(false);setTitle('');}, 2000);<Toast toastflag={toastflag} title={title}></Toast>

公共的顶部

import {Dimensions, Image, SafeAreaView, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import Store from '../../../stores/index';
import { useContext } from 'react';
const {width,height} = Dimensions.get('window')
export default function Index({navigation,route}) {const {data} = useContext(Store);return (<SafeAreaView><View style={styles.container}><View style={[styles.titleItem1]}><TouchableOpacityonPress={() => {navigation.goBack();}}><Imagesource={require('../../../static/image/img_arrow-back.png')}style={{height: 40, width: 40}}/></TouchableOpacity></View><View style={[styles.titleItem]}><Textstyle={{textAlign: 'left',fontSize: 20,fontWeight: 'bold',color: '#000000',}}>{data.language.DEVICESSN_TEXT_TITIE}</Text></View><View style={styles.titleItem3}><TouchableOpacityonPress={() => {navigation.navigate('AddManageMent');}}><Imagestyle={{width: 50, height: 50}}source={require('../../../static/image/Device/addDevices.png')}></Image></TouchableOpacity></View></View></SafeAreaView>);
}const styles = StyleSheet.create({container: {width: width,height: height / 15,position: 'relative',marginTop:20},titleItem1: {position: 'absolute',width: width,height: height / 15,flexDirection: 'row',alignItems: 'center',zIndex: 1,left: 5,},titleItem: {position: 'absolute',width: width,height: height / 15,flexDirection: 'row',justifyContent: 'center',alignItems: 'center',},titleItem3: {position: 'absolute',// width: width,right: 0,height: height / 15,flexDirection: 'row',justifyContent: 'flex-end',alignItems: 'center',zIndex: 2,right: 10,},
})

共用底部弹窗

import BottomModel from '../../../components/BottomModel';const [visible, setVisible] = useState(true); // 控制弹窗的显示隐藏const onClose = () => {setVisible(false);};// 确认按钮const endClass = () => {};{visible ? (<BottomModel visible={visible} LineBarFlag={true} onClose={onClose}><View><View style={[styles.bottommodulcontainer]}><Textstyle={{textAlign: 'center',fontWeight: 'bold',fontSize: 20,}}>{data.language.DEVICESUCCESS_MODELTITLE_REMINDER}</Text><Text style={{fontSize: 16, marginTop: 20, lineHeight: 30}}>{data.language.DEVICESUCCESS_MODELTITLESUB_SUB}</Text></View><View style={[styles.BtnBottom]}><Buttonmode="contained"textColor={theme.LOGIN_BTN_COLOR}buttonColor={theme.REGIST_BTN_COLOR}style={[styles.Account2,{borderWidth: 1, borderColor: theme.LOGIN_BTN_COLOR},]}contentStyle={{height: 45}}labelStyle={{fontSize: 15}}onPress={onClose}>{data.language.DEVICESUCCESS_MODEL_LEFTBTN}</Button><Buttonmode="contained"textColor={theme.REGIST_BTN_COLOR}buttonColor={theme.LOGIN_BTN_COLOR}style={[styles.Account2, {borderWidth: 1}]}contentStyle={{height: 45}}labelStyle={{fontSize: 15}}onPress={endClass}>{data.language.DEVICESUCCESS_MODEL_RIGHTBTN}</Button></View></View></BottomModel>) : null}bottommodulcontainer: {padding: 20,},BtnBottom: {flexDirection: 'row',alignItems: 'center',justifyContent: 'space-around',marginTop: 40,},Account2: {width: width / 2.5,borderRadius: 10,},
http://www.lryc.cn/news/344875.html

相关文章:

  • 深入解析MySQL中的事务(上)
  • Springboot项目使用redis实现session共享
  • 【Linux】Centos7安装部署unimrcp,搭建MRCP服务器
  • 什么是Jetpack
  • macOS sonoma 14.4.1编译JDK 12
  • GPU通用计算介绍
  • 如果数据给的是树形 转好的树形结构并且是有两个二级children的话 该如何写?
  • C++ 函数重载
  • 5. 分布式链路追踪TracingFilter改造增强设计
  • C++数据类型与表达式
  • 电脑ip地址设置成什么比较好
  • vue-element-template优化升级dart-sass、pnpm
  • Oracle拼接json字符串
  • 如何向Linux内核提交开源补丁?
  • python数据分析——pandas DataFrame基础知识2
  • TODESK远程开机的原理
  • 【c1】数据类型,运算符/循环,数组/指针,结构体,main参数,static/extern,typedef
  • word图片水印
  • kali安装及替换源
  • JSpdf,前端下载大量表格数据pdf文件,不创建dom
  • PHP关联数组[区别,组成,取值,遍历,函数]
  • JavaWeb--13Mybatis(2)
  • 如何远程控制另一部手机:远程控制使用方法
  • x64dbg中类似于*.exe+地址偏移
  • ICode国际青少年编程竞赛- Python-1级训练场-基础训练1
  • Baidu Comate智能编码助手
  • nginx自动部署-跨操作系统
  • 组合模式(结构型)
  • Pspice for TI学习
  • LoRA的原理简介