Coder Social home page Coder Social logo

可否自定义弹出视图? about teaset HOT 7 CLOSED

erhutime avatar erhutime commented on August 15, 2024
可否自定义弹出视图?

from teaset.

Comments (7)

erhutime avatar erhutime commented on August 15, 2024

另,仔细查看代码,发现,此乃神人也。代码逻辑如此严谨,清晰。

from teaset.

rilyu avatar rilyu commented on August 15, 2024

1、 设计时所有组件都是可以单独使用的,比如只使用Label:

import Label from 'teaset/components/Label/Label';

不过我没有测试过,你可以试试看,应该是可以的。

2、可以弹出任何内容,具体可参考OverlayExample.js,查看Overlay.js可以看出来Overlay.show的参数没有任何限制,可以是任何View,不过我建议弹出的View继承自Overlay.View并加上自己的逻辑,Overlay.PullView, Overlay.PopView, Overlay.PopoverView就是这么做的;
Overlay.View, Overlay.PullView, Overlay.PopView, Overlay.PopoverView是Overlay的静态变量,意味着你可以替换成你自己的class以改变弹出层的默认样式和行为,例如:

Overlay.View = MyOverlayView;

from teaset.

erhutime avatar erhutime commented on August 15, 2024

大神,目前有一个需求,想用你的来实现。就是点击Listview的item某一个控件,然后点击的item的控件旁边展示一个弹出层,弹出层高亮,屏幕其他弹出层遮罩,变灰。想用你这个来实现,不知道如何下手,大神可有思路,求指导。

from teaset.

rilyu avatar rilyu commented on August 15, 2024

不知道这是不是你想要的效果:

<ListRow title='测试左边弹出' detail={
  <Button title='点我弹出' ref='popoverButton' onPress={() => this.onPopoverButtonPress()} />
} />

onPopoverButtonPress() {
  this.refs['popoverButton'].measureInWindow((x, y, width, height) => {
    let fromBounds = {x, y, width, height};
    let overlayView = (
      <Overlay.PopoverView
        fromBounds={fromBounds}
        direction='left'
        align='start'
        directionInsets={4}
        showArrow={false}
        overlayOpacity={0.4}
      >
        <View style={{height: 60, padding: 10}}>
          <Label size='lg' text='这是内容' />
        </View>
      </Overlay.PopoverView>
    );
    Overlay.show(overlayView);
  });
}

如果是,把

        <View style={{height: 60, padding: 10}}>
          <Label size='lg' text='这是内容' />
        </View>

替换成你要显示的内容就行了

from teaset.

erhutime avatar erhutime commented on August 15, 2024

您好,我遇到一些问题:
1-:_renderRow(rowData) {
return (
<GoodInCell
msg='GoodInCell'
rowData={rowData}
onSelected={()=>{
this.onPopoverButtonPress();
}}
onSelectedByType={(type)=>{
this._onSelectedByType(type)
}}
/>
);
}
2-:GoodinCell:
let refMsg=this.props.msg;

<TouchableOpacity
ref={refMsg}
onPress={()=>{
this.onSelected();
}}>
<Image source={require('../../images/icon_time.png')} style={styles.iconBtn} />

2-:点击弹出方式还是按照你给的代码进行了简单修改,
点击时:
undefined is not an object (evaluating 'this.refs['GoodInCell'].measureInWindow')
排查不到问题,大神,有遇到类似的吗?

from teaset.

erhutime avatar erhutime commented on August 15, 2024

问题已经解决,谢谢大神,之前提供的方式可行。

from teaset.

Gqq475 avatar Gqq475 commented on August 15, 2024

很好 如有需要 会选择的

from teaset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.