GithubHelp home page GithubHelp logo

rilyu / teaset Goto Github PK

View Code? Open in Web Editor NEW
2.9K 70.0 484.0 6.53 MB

A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.

License: MIT License

JavaScript 97.24% Java 0.63% Objective-C 1.00% Ruby 0.67% Starlark 0.46%
react-native framework library overlay menu toast carousel projector checkbox select

teaset's Introduction

Teaset

🇨🇳中文完整文档版

A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.

Installation

npm install --save teaset

Example

Clone teaset project from github (or download zip file):

git clone https://github.com/rilyu/teaset.git
cd teaset/example
npm install

To run example on iOS:

cd ios && pod install && cd ..
react-native run-ios

To run example on Android:

react-native run-android

Tips: In the Android system, the animations is not smooth, switch to the release mode can be resolved.

iPhoneX

iPhoneX and iPhoneXS are fully supported after 0.6.0, and this option is true by default.

If SafeAreaView is used, please use Theme.set({fitIPhoneX: false}) to manually turn off it.

Redux

If you use Redux, you need to use the <TopView> package container (thanks @Alexorz ).

import { TopView } from 'teaset';

container => () => <Provider store={store}><TopView>{container}</TopView></Provider>

Documentation

The document is being written, please refer to the example source code.

Translation project

Screenshots

Components

Theme

Label

Button

Checkbox

Input

Select

Stepper

SearchInput

Badge

Popover

NavigationBar

ListRow

Carousel

Projector

SegmentedBar

SegmentedView

TabView

TransformView

AlbumView

Wheel

Overlay

Toast

ActionSheet

ActionPopover

PullPicker

PopoverPicker

Menu

Drawer

ModalIndicator

License

MIT

teaset's People

Contributors

auven avatar coderabbityu avatar covenanter avatar fahrinh avatar jedshiming avatar kala888 avatar leejialing avatar ljunb avatar rilyu avatar shoutleafy avatar shuirong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teaset's Issues

Theme.set primaryColor 没有生效

'use strict';

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';

import { TeaNavigator } from 'teaset';
import TeasetExampleHome from './views/Home';
import TabPage from './components/TabPage';

import { Theme } from 'teaset';
Theme.set(Theme.themes.default);
Theme.set({
primaryColor: '#1AAD19',
backButtonTitle: '返回',
});

export default class TeasetExample extends Component {
render() {
return <TeaNavigator rootView={} />;
}
}

AppRegistry.registerComponent('example', () => TeasetExample);

“返回”生效的,但是 primaryColor 没有生效

关于导航器

0.44以后facebook推出了新的导航 来解决卡顿的问题 作者什么时候把新导航加进来啊 老的那个慢慢就废弃掉了

react-redux support for Overlay

As Overlay introduces TopView as the new top element, the react-redux connect call won't find Provider element for any customised Overlay views added to TopView.

One easy (but not ideal) solution is to manually assign store to each of the Overlay views.

Is there a better solution for this?

Input 组件设置多行无效

<Input multiline={true} numberOfLines={4} onChangeText={(text) => this.setState({ text })} value={this.state.text} />

NavigationPage中的renderPage会渲染两次

NavigationPage中的renderPage会渲染两次,请问是有什么原因吗?

'use strict';
import React, {Component} from 'react';
import {View, ScrollView,Text} from 'react-native';
import {Theme, NavigationPage, NavigationBar, ListRow,TeaNavigator} from 'teaset';

export default class Index extends NavigationPage {
  static defaultProps = {...NavigationPage.defaultProps,title: 'index'};
  renderPage() {
    console.log('somelog');   //----------此处会打印出两次----------//
     return (
      <ScrollView style={{flex: 1}}>
        <ListRow title='Theme' detail='主题' onPress={() => this.navigator.push({view: <View />})} topSeparator='full' />
      </ScrollView>
    );
  }
}

Select to accept a function for rendering the items.

First of all, I love your work. It is really great. But I have one feature request.

It would be nice if Select component could have a prop for rendering the items and selected item. e.g.

renderItem(item, index) { return (<Text>{item}</Text>); }

This is to replace the getItemText prop.
This open up possibility to make a picker for Images and others.
I saw PopoverPickerItem already supports this.

<ModalIndicator>覆盖问题?

我用的是react-navigation,
<ModalIndicator.IndicatorView/>不能覆盖导航栏,
ModalIndicator.show()则可以覆盖,但是在render()中使用会有以下警告:
Cannot update during an existing state transition (such as within render or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount.

ScrollView in PopView not scrolling

The issue can be reproduced using the example below:

<Overlay.PopView 
   modal={true}
   style={{flex:1}}
   containerStyle={{flex:1}}
>
 <ScrollView style={{flex:1}} contentContainerStyle={{flex:1}}>
	<Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
        <Text>12323213</Text>
  </ScrollView>
</Overlay.PopView> 

When justifyItem set to scrollable, SegmentedBar will take too much space

Here are the example code and screenshot highlighted the issue:

<SegmentedView 
    type='projector' 
    justifyItem='scrollable'
    autoScroll={true} 
    animated={true}
    style={{flex:1}} 
    >
            <SegmentedView.Sheet key={1} title={"view 1"}>
							<View>
                <ListRow title='List Item 1' detail={'ssss'} topSeparator='full' />
                <ListRow title='List Item 2' detail={'ssss'} topSeparator='none'/>
                <ListRow title='List Item 3' detail={'ssss'} topSeparator='none'/>
                <ListRow title='List Item 4' detail={'ssss'} topSeparator='none' bottomSeparator='full' />
							</View>
						</SegmentedView.Sheet>
            <SegmentedView.Sheet key={2} title={"view 2"}>
							<View>
							  <ListRow title='List Item 1' detail={'2'} topSeparator='full' />
							  <ListRow title='List Item 2' detail={'ssss'} topSeparator='none'/>
							  <ListRow title='List Item 3' detail={'ssss'} topSeparator='none'/>
							  <ListRow title='List Item 4' detail={'ssss'} topSeparator='none' bottomSeparator='full' />
							</View>
						</SegmentedView.Sheet>
            <SegmentedView.Sheet key={3} title={"view 3"}>
							<View>
                <ListRow title='List Item 1' detail={'3'} topSeparator='full' />
                <ListRow title='List Item 2' detail={'ssss'} topSeparator='none'/>
                <ListRow title='List Item 3' detail={'ssss'} topSeparator='none'/>
                <ListRow title='List Item 4' detail={'ssss'} topSeparator='none' bottomSeparator='full' />
							</View>
						</SegmentedView.Sheet>
    </SegmentedView>

image

SegmentedView 使用这个组件创建3个页面,是一次性加载完成的吗?

1.要实现类似react-native-scrollable-tab-view这个库的样式, 使用SegmentedView之后,发现里面的子页面是一次性加载完成的. 能不能实现react-native-scrollable-tab-view那样, 按需加载呢?
如果是一次性加载完的, 如果页面都一样,输入请求就是一次性请求完了..
2.还有SegmentedView 里面只提供了onChange这样的属性,如果我想在滚动的时候,让底部的滚动条颜色改变, 展示上会有问题.

Something wrong with SearchInput's value

Hi, cool library.
But I found something wrong when I used SearchInput in Overlay.
Problem is the input area will be cleared after editing.
So I change the source of SearchInput line if (value === undefined) value = this.state.value; to value = this.state.value; in method render().
Dont know if this is right. Hope for your fix.

toast duration error

code:

static show(options) {
    let {duration, ...others} = options && typeof options === 'object' ? options : {};

    let key = super.show(<this.ToastView {...others} />);
    if (typeof duration !== 'number') {
      console.log("Toast--duration");
      switch (duration) {
        case 'long': duration = 3500; break;
        default: duration = 7000; break;
      }
    }
    console.log("Toast--duration-time ", duration);
    console.log("Toast--duration-time-dataStart", new Date());
    setTimeout(() => {
      console.log("Toast--duration-time-dataEnd", new Date());
      this.hide(key)
    }, 7000);

    return key;
  }

error:

Toast--duration
E:\lottery\RNLotteryProject\node_modules\teaset\components\Toast\Toast.js:40 Toast--duration-time 7000
E:\lottery\RNLotteryProject\node_modules\teaset\components\Toast\Toast.js:41 Toast--duration-time-dataStart Sat Jul 08 2017 10:02:37 GMT+0800 (**标准时间)
E:\lottery\RNLotteryProject\APP\Buy\BuyMainPage.js:53 paresData
E:\lottery\RNLotteryProject\APP\Buy\BuyMainPage.js:336 redner
E:\lottery\RNLotteryProject\APP\Buy\BuyMainPage.js:141 createNowLotteryNumberView 00 04 02 33 11 55 11
E:\lottery\RNLotteryProject\APP\Buy\BuyMainPage.js:336 redner
E:\lottery\RNLotteryProject\APP\Buy\BuyMainPage.js:336 redner
E:\lottery\RNLotteryProject\node_modules\teaset\components\Toast\Toast.js:43 Toast--duration-time-dataEnd Sat Jul 08 2017 10:02:37 GMT+0800 (**标准时间)
E:\lottery\RNLotteryProject\node_modules\teaset\components\Toast\Toast.js:43 Toast--duration-time-dataEnd Sat Jul 08 2017 10:02:37 GMT+0800 (**标准时间)

ModalIndicator自定义图标

可以自定义那个loading的图标吗?我做一个录音的场景录音时想用这个实现累次微信录语音的效果

Slow on Android?

In Example project, each "click" takes about 5 seconds to be processed (navigation from home to some option), and Overlay animations are very slow.

Tested on a low-end device (Moto G XT 1033) and in a mid-end device (Asus ZenFone 2 Selfie).

可否自定义弹出视图?

1-:感觉功能比较强大,但是项目中只会用一两个,想拆出来,发觉包还是很大的。
2-:可否自定义弹出内容?view视图是否提供自定义?

REPORT:A NEW BUG WITH SegmentedView.Sheet

I like the Lib,and now I have some question?

  1. Why don't you use navagation to replace the navagator?

  2. why don't you use Flux and Redux

  3. now I find a bug ,when i used SegmentedView.Sheet's title property ,I find if the page status has changed,This component will be rendered

for example ,if i used TextInput or your InputRow,SegmentedView.Sheet's title property it will grab the spotlight,i have no idea to control the TextInput content change caused Title state change

  1. and SegmentedView.Sheet need to resolve pull-down refresh the event of conflict

Finally, I hope you can add me QQ56927299 communicate RN together

ListRow 的图标与文字之间没有分开

我看了下你的源码:ListRow.js是这么处理图标的

//icon
if ((icon || icon === 0) && !React.isValidElement(icon)) {
  icon = (
    <View style={{paddingRight: Theme.rowIconPaddingRight}}>
      <Image style={{width: Theme.rowIconWidth, height: Theme.rowIconHeight}} source={icon} />
    </View>
  );
}

这样图标只能是图片的时候图标和标题文字之间的间隔 paddingRight 才器作用,
我用到矢量图标的时候出现问题
//导入图标字体,这里使用FontAwesome库
import Icon from 'react-native-vector-icons/FontAwesome';
但是我在图标的样式上增加style={{paddingRight:12}}可以解决,我想应该是你的代码的兼容性出了问题,希望能够纠正过来,要不每次每次都要修复这个小问题也挺麻烦的。

注:我用的是import {StackNavigator} from 'react-navigation';进行导航的,比较流畅一点。

具体代码如下

      <ListRow title='时光相册'
                     icon={<Icon name="info-circle" size={20} style={{paddingRight:12}}/>}
                     detail='时光相册'
                     onPress={() => this.navigator.push({view: <AboutScreen />})}/>

事实上没用你的库之前我是这么写的

<TouchableOpacity onPress={() => navigate('NewsDetail')} style={styles.itemContainer}> <Icon name="file-image-o" size={20}/> <Text style={styles.itemText}> 时光相册 </Text> <Icon name="chevron-right"/> </TouchableOpacity>

关于导航功能

我在index.android.js使用了 TabView
`export default class TabViewExample extends BasePage {

static defaultProps = {
...BasePage.defaultProps,
scene: TeaNavigator.SceneConfigs.PushFromRight,
};

constructor(props) {
super(props);
Object.assign(this.state, {
type: 'projector',
});
}

renderPage() {
return (
<TabView style={{ flex: 1 }} type={this.state.type} >
<TabView.Sheet
title='主页'
icon={require('./icons/my/home.png')}
activeIcon={require('./icons/my/home_fill.png')}
>

</TabView.Sheet>`
当我进入一个tab后,点击一个按钮,然后整个tabview导航到别的页面,请问这种效果怎么做?

拿微信举个例子,点击“发现”->"朋友圈"

TabView

我使用TabView 从当前页跳转到 另外一页 底部的TabView 一直都在 有什么方法让他隐藏吗

TabView切换能Sheet能否重新渲染页面

目前的需求是一个TabView中包含了3个NavigationPage。
希望切换TabSheet的时候能够重新渲染页面。
componentWillMount只在第一次加载时触发,能否手动触发。
TabSheet类似于:
<TabView style={{flex: 1}} type={this.state.type}> <TabView.Sheet title='audit' icon={require('../assets/icons/png/audit.png')} activeIcon={require('../assets/icons/png/audit.png')} > <HomePage type={this.state.type} onChangeType={type => this.setState({type})} /> </TabView.Sheet> <TabView.Sheet title='list' icon={require('../assets/icons/png/list.png')} activeIcon={require('../assets/icons/png/list.png')} > <HomePage type={this.state.type} onChangeType={type => this.setState({type})} /> </TabView.Sheet> <TabView.Sheet title='cloud' icon={require('../assets/icons/png/cloud.png')} activeIcon={require('../assets/icons/png/cloud_active.png')} > <MePage type={this.state.type} onChangeType={type => this.setState({type})}/> </TabView.Sheet> </TabView>

homePage中:
componentWillMount() { console.log('componentWillMount'); this.fetchData(); }

给您添麻烦了,先谢过!

Android:TransformView点击事件 与 Path onPressOut 事件冲突

Mr.rilyu 首先非常感谢作者的开源精神,顺滑的ES6语法糖,优雅流畅的teaset编码,受益匪浅,最近又遇到一个适配问题啦

1.Android TransformView 放大SVG ,SVG点击事件 Android SVG onPressLayout 与父组件 TransformView onChildrenPress 事件冲突,ios妥妥的没问题,具体代码如下:

    <TransformView
                      style={{backgroundColor: Theme.pageColor, flex: 1, alignItems: 'center', justifyContent: 'center'}} minScale={0.5}
                      maxScale={2}
                      magnetic={true}
                      onisEidt = {(isEidt) => {
	                      this.isEidt = isEidt;
                      }}>
                        <SvgMap
                            svgJson={svgJsonsCity[leftAreaCode]['svg']}
                            onChildrenPress={children => {this._onChildrenPress(children)}}
                        />
                    </TransformView>
'use strict';

import React, {Component, PropTypes} from 'react';
import {StyleSheet, View, Dimensions} from 'react-native';

import {Svg, Path, Text} from 'react-native-svg';


export default class SvgMap extends Component {

  static propTypes = {
    ...Svg.propTypes,
    svgJson: PropTypes.object.isRequired,
    onChildrenPress: PropTypes.func, //(children)
  };

  constructor(props) {
    super(props);
    this.pageWidth = Dimensions.get('window').width;
    this.pageHeight = Dimensions.get('window').height - 400;
    this.padding = 12 * 320/this.pageWidth;


  }

  getParams() {
    let {svgJson} = this.props;

    let clientWidth = this.pageWidth - this.padding * 2;
    let clientHeight = this.pageHeight - this.padding * 2;

    let {x, y, width, height} = svgJson.bounds;
    let scaleX = clientWidth / width;
    let scaleY = clientHeight / height;
    let scale = Math.min(scaleX, scaleY);

    let paddingX = this.padding + Math.round((clientWidth - width * scale) / 2) ;
    let paddingY = this.padding + Math.round((clientHeight - height * scale) / 2);


    return {
      x: paddingX,
      y: paddingY,
      scale: scale,
    };
  }

  renderMainMap(x, y, scale, strokeColor, strokeWidth, fill) {
    let {svgJson} = this.props;
    let elements = svgJson.paths.map((item, index) => (
      <Path
        key={svgJson.name + index}
        x={x}
        y={y}
        scale={scale}
        d={item}
        fill={fill}
        stroke={strokeColor}
        strokeWidth={strokeWidth / scale}
        strokeLinecap='round'
        strokeLinejoin='round'
      />
    ));
    return elements;
  }

  onTouchForChildren(children){
      let { onChildrenPress} = this.props;
      onChildrenPress(children);
  }


  renderSubMap(x, y, scale, strokeColor, strokeWidth) {
      let {svgJson, onChildrenPress} = this.props;
      let elements = [];

      let {childrens} = svgJson;
      let fillColors = ["#f9c62a", "#a6c2de", "#fc9ecc", "#7df84d", "#ffff00", "#f9c62a", "#a6c2de", "#fc9ecc", "#7df84d", "#ffff00"];
      for (let i = 0; i < childrens.length; i++) {
          if (svgJson.level === 'city') childrens[i].fillColor = fillColors[i % fillColors.length];
          childrens[i].paths.map((item, index) => {
              elements.push(
                  <Path
                      key={childrens[i].name + 'name' + index}
                      x={x}
                      y={y}
                      scale={scale}
                      d={item}
                      fill={childrens[i].fillColor}
                      stroke={strokeColor}
                      strokeWidth={strokeWidth / scale}
                      strokeLinecap='round'
                      strokeLinejoin='round'
                      onPressOut={() => this.onTouchForChildren(childrens[i])}
                  />
              );
          });
      }

      for (let children of childrens) {
              elements.push(
                  <Text
                      key={children.name + 'text'}
                      fontSize={5}
                      x={x + children.center.x * scale}
                      y={y + children.center.y * scale}
                      textAnchor="middle"
                      onPress={() => this.onTouchForChildren(childrens)}
                  >
                      {children.name}
                  </Text>
              );
      }

      return elements;
  }

  render() {
    let {x, y, scale} = this.getParams();
    return (
      <Svg width={this.pageWidth} height={this.pageHeight}>
        {this.renderMainMap(x, y, scale, '#c9cacb', 10, 'none')}
        {this.renderSubMap(x, y, scale, '#3ea5dc', 1)}
      </Svg>
    );
  }

}

弹窗里面再弹窗

A弹窗的Input给了 this.state.xxx
点击A的某个按钮弹出B弹出(A弹窗不关闭)
B弹出某个按钮点击后 改变 this.state.xxx 的值,后关闭B弹窗
A弹窗里面的 this.state.xxx 没改变。
求如何改变值

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.