import React, { Component } from 'react' import { ScrollView, View, Text, Dimensions, ViewStyle } from 'react-native' import { TopviewGetInstance } from '../../components/Topview' import variables from '../../common/styles/variables' import { range } from '../../common/utils' export interface RulerProps { style?: ViewStyle direction?: 'vertical' | 'horizontal' } export class Ruler extends Component { static defaultProps = { direction: 'vertical' } constructor (p) { super(p) this.state = { topviewId: null } } componentDidMount () { if (this.state.topviewId) { return } TopviewGetInstance() && TopviewGetInstance().add(this.renderFullScreenView()).then((id) => { this.setState({ topviewId: id }) }) } componentWillUnmount () { TopviewGetInstance() && TopviewGetInstance().remove(this.state.topviewId) } renderFullScreenView () { const { direction, style } = this.props return ( { range(100).map((item) => { const index = item + 1 const evenNumber = index % 2 === 0 const base = 10 const value = index * base const showValue = value % 50 === 0 const valueViewHeight = direction === 'vertical' ? base : null const valueViewWidth = direction === 'vertical' ? null : base return ( { showValue ? {value} : null } ) }) } ) } render () { return null } }