React Native学习

react-native开发实例之城市选择组件update

2016-12-23  本文已影响121人  sleepforests

效果图

ios.gif

介绍

上次的文章 react-native开发实例之城市选择组件 介绍了simple city select版本,没有实现类似下图的功能。

Paste_Image.png

这次的update改进主要针对这块区域和searchbox部分。

代码

http://git.oschina.net/react9527/react-native-select-city

几点分析

let eachheight = SECTIONHEIGHT + ROWHEIGHT * thisRow.length;
            if (sectionID === key_hot || sectionID === key_now || sectionID === key_last_visit) {
                let rowNum = (thisRow.length % 3 === 0)
                    ? (thisRow.length / 3)
                    : parseInt(thisRow.length / 3) + 1;

                console.log('sectionIDs===>' + sectionIDs + ", rowNum=====>" + rowNum);

                eachheight = SECTIONHEIGHT + ROWHEIGHT_BOX * rowNum;
            }

及对字母索引的直接row length乘以高度,而另外3种情况需要考虑每行3个元素

上一篇 下一篇

猜你喜欢

热点阅读