Skip to content

Commit b43ea40

Browse files
committed
code format Hint component
1 parent 55320c0 commit b43ea40

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

src/components/hint/index.tsx

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ interface HintTargetFrame {
5050
height?: number;
5151
}
5252

53-
type Position = Pick<ViewStyle, 'top' | 'bottom' | 'left' | 'right'>
53+
type Position = Pick<ViewStyle, 'top' | 'bottom' | 'left' | 'right'>;
5454

55-
type HintPositionStyle = Position & Pick<ViewStyle, 'alignItems'>
56-
57-
type Paddings = Pick<ViewStyle, 'paddingLeft' | 'paddingRight' | 'paddingVertical' | 'paddingHorizontal'>
55+
type HintPositionStyle = Position & Pick<ViewStyle, 'alignItems'>;
5856

57+
type Paddings = Pick<ViewStyle, 'paddingLeft' | 'paddingRight' | 'paddingVertical' | 'paddingHorizontal'>;
5958

6059
export interface HintProps {
6160
/**
@@ -110,7 +109,7 @@ export interface HintProps {
110109
* Callback for Hint press
111110
*/
112111
onPress?: () => void;
113-
/**
112+
/**
114113
* Callback for the background press
115114
*/
116115
onBackgroundPress?: (event: GestureResponderEvent) => void;
@@ -195,7 +194,7 @@ class Hint extends Component<HintProps, HintState> {
195194
const {message} = this.props;
196195
const targetRefTag = findNodeHandle(this.targetRef);
197196
const hintRefTag = findNodeHandle(this.hintRef);
198-
197+
199198
if (targetRefTag && _.isString(message)) {
200199
AccessibilityInfo.setAccessibilityFocus(targetRefTag);
201200
} else if (hintRefTag) {
@@ -217,7 +216,7 @@ class Hint extends Component<HintProps, HintState> {
217216
if (!_.isEqual(this.state.targetLayout, layout)) {
218217
this.setState({targetLayout: layout});
219218
}
220-
219+
221220
if (!this.state.targetLayoutInWindow || this.props.onBackgroundPress) {
222221
setTimeout(() => {
223222
this.targetRef?.measureInWindow((x: number, y: number, width: number, height: number) => {
@@ -286,7 +285,7 @@ class Hint extends Component<HintProps, HintState> {
286285
getTargetPositionOnScreen() {
287286
if (this.targetLayout?.x && this.targetLayout?.width) {
288287
const targetMidPosition = this.targetLayout.x + this.targetLayout.width / 2;
289-
288+
290289
if (targetMidPosition > this.containerWidth * (2 / 3)) {
291290
return TARGET_POSITIONS.RIGHT;
292291
} else if (targetMidPosition < this.containerWidth * (1 / 3)) {
@@ -329,7 +328,7 @@ class Hint extends Component<HintProps, HintState> {
329328

330329
getHintPadding() {
331330
const paddings: Paddings = {paddingVertical: this.hintOffset, paddingHorizontal: this.edgeMargins};
332-
331+
333332
if (this.useSideTip && this.targetLayout?.x) {
334333
const targetPositionOnScreen = this.getTargetPositionOnScreen();
335334
if (targetPositionOnScreen === TARGET_POSITIONS.LEFT) {
@@ -345,7 +344,7 @@ class Hint extends Component<HintProps, HintState> {
345344
getHintAnimatedStyle = () => {
346345
const {position} = this.props;
347346
const translateY = position === HintPositions.TOP ? -10 : 10;
348-
347+
349348
return {
350349
opacity: this.visibleAnimated,
351350
transform: [
@@ -431,25 +430,19 @@ class Hint extends Component<HintProps, HintState> {
431430
transform: [{scaleY: flipVertically ? -1 : 1}, {scaleX: flipHorizontally ? -1 : 1}]
432431
};
433432

434-
return (
435-
<Image
436-
tintColor={color}
437-
source={source}
438-
style={[styles.hintTip, this.getTipPosition(), flipStyle]}
439-
/>
440-
);
433+
return <Image tintColor={color} source={source} style={[styles.hintTip, this.getTipPosition(), flipStyle]}/>;
441434
}
442435

443436
renderContent() {
444437
const {
445-
message,
446-
messageStyle,
447-
icon,
448-
iconStyle,
449-
borderRadius,
450-
color = DEFAULT_COLOR,
451-
customContent,
452-
removePaddings,
438+
message,
439+
messageStyle,
440+
icon,
441+
iconStyle,
442+
borderRadius,
443+
color = DEFAULT_COLOR,
444+
customContent,
445+
removePaddings,
453446
enableShadow,
454447
visible,
455448
testID
@@ -463,7 +456,7 @@ class Hint extends Component<HintProps, HintState> {
463456
style={[
464457
styles.hint,
465458
!removePaddings && styles.hintPaddings,
466-
visible && enableShadow && styles.containerShadow,
459+
visible && enableShadow && styles.containerShadow,
467460
{backgroundColor: color},
468461
!_.isUndefined(borderRadius) && {borderRadius}
469462
]}
@@ -508,7 +501,7 @@ class Hint extends Component<HintProps, HintState> {
508501
return (
509502
<View
510503
{...others}
511-
// this view must be collapsable, don't pass testID or backgroundColor etc'.
504+
// this view must be collapsable, don't pass testID or backgroundColor etc'.
512505
collapsable
513506
testID={undefined}
514507
style={[styles.container, style, this.getContainerPosition()]}
@@ -533,7 +526,7 @@ class Hint extends Component<HintProps, HintState> {
533526

534527
render() {
535528
const {onBackgroundPress, testID} = this.props;
536-
529+
537530
if (!this.props.visible && this.state.hintUnmounted) {
538531
return this.props.children || null;
539532
}

0 commit comments

Comments
 (0)