ReactNative Hooks写法抽离子view

  const itemTop = (itemName: any, itemIcon: any) => {
    return <View style={[$row, $flex1, { padding: 8, backgroundColor: '#f3f6ff', borderRadius: 10, }]}>
      <IconFont size={65} name={itemIcon} />
      <View style={[$justifyAround, $flex1, { marginLeft: 20, }]}>
        <Text style={[{ textAlign: 'right', color: theme.primary.color }, $fontSize16, $fontWeight]} >99</Text>
        <Text style={[{ textAlign: 'right', color: '#7a869a' }, $fontSize12]}>{itemName}</Text>
      </View>
    </View>
  }

  const IItemTop = (info: any) => {
    return <View style={[$row, $flex1, { padding: 8, backgroundColor: '#f3f6ff', borderRadius: 10, }]}>
      <IconFont size={65} name={info.itemIcon} />
      <View style={[$justifyAround, $flex1, { marginLeft: 20, }]}>
        <Text style={[{ textAlign: 'right', color: theme.primary.color }, $fontSize16, $fontWeight]} >99</Text>
        <Text style={[{ textAlign: 'right', color: '#7a869a' }, $fontSize12]}>{info.itemName}</Text>
      </View>
    </View>
  }


  const HeadTop = () => {
    return <View>
      <View style={[$row, $flex1, { marginTop: 36, marginLeft: 20, marginRight: 20 }]}>
        {/* {itemTop('In', 'menuIn')} */}
        <IItemTop itemName={'In'} itemIcon={'menuIn'} />
        <View style={ { width: 10 }} />
        {itemTop('Received', 'menuReceived')}
      </View>

      <View style={[$row, $flex1, { marginTop: 16, marginLeft: 20, marginRight: 20 }]}>
        {itemTop('Sorted', 'menuSorted')}
        <View style={ { width: 10 }} />
        {itemTop('Check In', 'menuDelivered')}

      </View>

      <Text>Operation</Text>
    </View>

  }

两种写法

相关推荐

  1. 逆序对————权值线段树+离散写法

    2024-01-05 13:36:03       17 阅读
  2. 原型模式(上机考试题)

    2024-01-05 13:36:03       18 阅读
  3. 常用的路径稀算法

    2024-01-05 13:36:03       10 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-05 13:36:03       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-05 13:36:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-05 13:36:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-05 13:36:03       20 阅读

热门阅读

  1. 人机之间的联系

    2024-01-05 13:36:03       44 阅读
  2. delphi中自定义自己的定时器

    2024-01-05 13:36:03       45 阅读
  3. Golang如何解决重复提交并发问题

    2024-01-05 13:36:03       44 阅读
  4. HarmonyOS创建自定义组件

    2024-01-05 13:36:03       55 阅读
  5. HarmonyOS@Builder装饰器

    2024-01-05 13:36:03       48 阅读
  6. 面试算法91:粉刷房子

    2024-01-05 13:36:03       39 阅读