React Native【实战范例】银行卡(含素材)

c 复制代码
import React from "react";
import { Image, ImageBackground, StyleSheet, Text, View } from "react-native";
import {
  SafeAreaProvider,
  useSafeAreaInsets,
} from "react-native-safe-area-context";
import bg_card from "../../assets/images/bg_card.png";
import icon_bank from "../../assets/images/icon_bank.png";
export default function HomeScreen() {
  const insets = useSafeAreaInsets();
  return (
    <SafeAreaProvider>
      <View
        style={{
          flex: 1,
          paddingTop: insets.top, // 顶部安全区域
          paddingBottom: insets.bottom, // 底部安全区域
          paddingLeft: 10,
          paddingRight: 10,
        }}
      >
        <View style={styles.root}>
          <ImageBackground
            style={styles.viewStyle}
            imageStyle={styles.imgStyle}
            source={bg_card}
          >
            <Image style={styles.icon_logo} source={icon_bank} />
            <Text style={styles.txtBank}>
              {`招商银行\n`}
              <Text style={styles.cardTypeTxt}>{`储蓄卡\n\n`}</Text>
              <Text style={styles.cardNoTxt}>●●●● ●●●● ●●●● 3068</Text>
            </Text>
          </ImageBackground>
        </View>
      </View>
    </SafeAreaProvider>
  );
}
const styles = StyleSheet.create({
  page: {
    padding: 10,
  },
  root: {
    width: "100%",
    height: "100%",
    flexDirection: "column",
  },
  viewStyle: {
    width: "100%",
    height: 150,
    flexDirection: "row",
    alignItems: "flex-start",
  },
  imgStyle: {
    resizeMode: "cover",
    borderRadius: 12,
  },
  icon_logo: {
    width: 48,
    height: 48,
    borderRadius: 24,
    marginLeft: 20,
    marginTop: 20,
  },
  txtBank: {
    fontSize: 24,
    color: "white",
    marginLeft: 10,
    marginTop: 21,
    fontWeight: "bold",
  },
  cardTypeTxt: {
    fontSize: 20,
    color: "#FFFFFFA0",
    fontWeight: "normal",
  },
  cardNoTxt: {
    fontSize: 26,
    color: "white",
  },
});

assets/images/bg_card.png

assets/images/icon_bank.png

相关推荐
Cxiaomu24 分钟前
React Native App 图表绘制完整实现指南
javascript·react native·react.js
黄毛火烧雪下12 小时前
React Native (RN)项目在web、Android和IOS上运行
android·前端·react native
明远湖之鱼1 天前
浅入理解跨端渲染:从零实现 React DSL 跨端渲染机制
前端·react native·react.js
一头小鹿2 天前
【React Native+Appwrite】获取数据时的分页机制
前端·react native
XiaoSong2 天前
基于 React Native/Expo 项目的持续集成(CI)最佳实践配置指南
前端·react native·react.js
VisuperviReborn2 天前
React Native 与 iOS 原生通信:从理论到实践
前端·react native·前端框架
冰冷的bin4 天前
【React Native】粘性布局StickyScrollView
react native
chenbin___4 天前
react native中 createAsyncThunk 的详细说明,及用法示例(转自通义千问)
javascript·react native·react.js
前端拿破轮6 天前
ReactNative从入门到性能优化(一)
前端·react native·客户端