d class="lines-num lines-num-old"> 532
			return POSITION_BOTTOM_CENTER;
533
		}else if (isUp) {
534
			if(isRight){
535
				return POSITION_TOP_RIGHT;
536
			}else if (isLeft) {
537
				return POSITION_TOP_LEFT;
538
			}
539
			return POSITION_TOP_CENTER;
540
		}else if (isRight) {
541
			return POSITION_RIGHT_CENTER;
542
		}else if (isLeft) {
543
			return POSITION_LEFT_CENTER;
544
		}
545
//		if(!isLeft && !isRight && !isUp && !isBottom){
546
			return POSITION_CENTER;
547
//		}
548
	}
549
	/**
550
	 * 偏移量计算
551
	 */
552
	private int[] computOffset(int position,int i){
553
		int toX = 0,toY =0 ;
554
		radius = buttonRadius * 2;
555
		if(position != 0 && position % 2 == 0){//当position为扇形,打开时初始半径变大1.5倍;
556
			radius *= 1.5;
557
		}
558
		switch (position) {
559
		case POSITION_CENTER:
560
			setCircle(1);
561
			toX =(int)(radius*Math.sin(i*angle));
562
			toY =(int)(radius*Math.cos(i*angle));
563
			break;
564
		case POSITION_TOP_CENTER:
565
			setCircle(0.5f);
566
			toX = (int)(radius*Math.sin(i*angle + Math.PI/2));
567
			toY = (int)(radius*Math.cos(i*angle + Math.PI/2));
568
			break;
569
		case POSITION_TOP_RIGHT:
570
			setCircle(0.25f);
571
			toX = (int)(radius*Math.sin(i*angle + Math.PI));
572
			toY = (int)(radius*Math.cos(i*angle + Math.PI));
573
			break;
574
		case POSITION_RIGHT_CENTER:
575
			setCircle(0.5f);
576
			toX = (int)(radius*Math.sin(i*angle + Math.PI));
577
			toY = (int)(radius*Math.cos(i*angle + Math.PI));
578
			break;
579
		case POSITION_BOTTOM_RIGHT:
580
			setCircle(0.25f);
581
			toX = (int)(radius*Math.sin(i*angle - Math.PI/2));
582
			toY = (int)(radius*Math.cos(i*angle - Math.PI/2));
583
			break;
584
		case POSITION_BOTTOM_CENTER:
585
			setCircle(0.5f);
586
			toX = (int)(radius*Math.sin(i*angle - Math.PI/2));
587
			toY = (int)(radius*Math.cos(i*angle - Math.PI/2));
588
			break;
589
		case POSITION_BOTTOM_LEFT:
590
			setCircle(0.25f);
591
			toX = (int)(radius*Math.sin(i*angle));
592
			toY = (int)(radius*Math.cos(i*angle));
593
			break;
594
		case POSITION_LEFT_CENTER:
595
			setCircle(0.5f);
596
			toX = (int)(radius*Math.sin(i*angle));
597
			toY = (int)(radius*Math.cos(i*angle));
598
			break;
599
		case POSITION_TOP_LEFT:
600
			setCircle(0.25f);
601
			toX = (int)(radius*Math.sin(i*angle + Math.PI/2));
602
			toY = (int)(radius*Math.cos(i*angle + Math.PI/2));
603
			break;
604
		default:
605
			break;
606
		}
607
		int [] xy = {toX,toY};
608
		return xy;
609
	}
610
	
611
	public PathMenu setPosition(int position){
612
		this.position = position;
613
		return this;
614
	}
615
	
616
}

TemporaryRep - Nuosi Git Service

临时仓库

Header.js 2.5KB

    /** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow * @lint-ignore-every XPLATJSCOPYRIGHT1 */ import React, {Component, Children} from 'react'; import {Modal, StyleSheet, Text, View,Image,TouchableOpacity,TouchableHighlight} from 'react-native'; import ModalContent from './ModalContent' export default class Header extends Component { state = { modalVisible: false }; setModalVisible(visible) { this.setState({ modalVisible: visible }); } renderTitle(){ let {children,title} = this.props if(title){ title = <Text style={styles.headerLeftText} numberOfLines={1}>{title}</Text> } return title?title:children } render() { return ( <View style={{height:50}}> <View style={styles.headerContainer}> <View style={styles.headerLeft}> {this.renderTitle()} {/* <Text style={styles.headerLeftText} onPress={()=>{this.props.leftEvent()}}>{this.props.title}</Text> */} </View> <View style={styles.headerRight}> <TouchableOpacity style={styles.clickButton,styles.leftButton} onPress={() => { this.refs.dialog._setModalVisible(true); }}> <Image style={styles.img} source={require('../static/img/point.png')}/> </TouchableOpacity> <TouchableOpacity style={styles.clickButton,styles.rightButton}> <Image style={styles.img} source={require('../static/img/circle.png')}/> </TouchableOpacity> </View> </View> <ModalContent ref="dialog" /> </View> ); } } const styles = StyleSheet.create({ headerContainer:{ flex: 1, flexDirection:'row', justifyContent: 'space-between', backgroundColor:'#ddd', padding:7.5 }, headerLeft:{ }, headerLeftText:{ lineHeight:35, fontSize:15, color:'#000' }, headerRight:{ flex:1,flexDirection:'row',justifyContent: 'flex-end' }, leftButton:{ borderTopLeftRadius:35,borderBottomLeftRadius:35,borderColor:'#fff', backgroundColor:'#fff',borderLeftWidth:15,borderRightWidth:10,height:35, }, rightButton:{ borderTopRightRadius:35,borderBottomRightRadius:35,borderColor:'#fff', backgroundColor:'#fff',borderLeftWidth:10,borderRightWidth:15,height:35, }, img:{ height: 25, width: 25, alignItems: 'center', marginTop:5 } });