-
Notifications
You must be signed in to change notification settings - Fork 959
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
140 changed files
with
3,243 additions
and
2,355 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/framework/ui/bottomNavigation/bottomNavigationTab.component.web.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { Interaction } from '@kitten/theme'; | ||
import { | ||
BottomNavigationTab as RNBottomNavigationTab, | ||
BottomNavigationTabElement as RNBottomNavigationTabElement, | ||
BottomNavigationTabProps as RNBottomNavigationTabProps, | ||
// @ts-ignore | ||
} from './bottomNavigationTab.component.tsx'; | ||
import { | ||
WebEventResponder, | ||
WebEventResponderCallbacks, | ||
WebEventResponderInstance, | ||
} from '../support/services'; | ||
|
||
export type BottomNavigationTabProps = RNBottomNavigationTabProps & WebEventResponderCallbacks; | ||
export type BottomNavigationTabElement = React.ReactElement<BottomNavigationTabProps>; | ||
|
||
export class BottomNavigationTab extends React.Component<BottomNavigationTabProps> | ||
implements WebEventResponderCallbacks { | ||
|
||
private bottomNavigationTabRef: React.RefObject<any> = React.createRef(); | ||
private webEventResponder: WebEventResponderInstance = WebEventResponder.create(this); | ||
|
||
public onMouseEnter = (): void => { | ||
this.bottomNavigationTabRef.current.props.dispatch([Interaction.HOVER]); | ||
|
||
if (this.props.onMouseEnter) { | ||
this.props.onMouseEnter(); | ||
} | ||
}; | ||
|
||
public onMouseLeave = (): void => { | ||
this.bottomNavigationTabRef.current.props.dispatch([]); | ||
|
||
if (this.props.onMouseLeave) { | ||
this.props.onMouseLeave(); | ||
} | ||
}; | ||
|
||
public onFocus = (): void => { | ||
if (this.props.onFocus) { | ||
this.props.onFocus(); | ||
} | ||
}; | ||
|
||
public onBlur = (): void => { | ||
if (this.props.onBlur) { | ||
this.props.onBlur(); | ||
} | ||
}; | ||
|
||
public render(): RNBottomNavigationTabElement { | ||
const { style, ...restProps } = this.props; | ||
|
||
return ( | ||
<RNBottomNavigationTab | ||
{...restProps} | ||
{...this.webEventResponder.eventHandlers} | ||
ref={this.bottomNavigationTabRef} | ||
style={[style, styles.element]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
element: { | ||
// @ts-ignore | ||
outlineWidth: 0, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { Interaction } from '@kitten/theme'; | ||
import { | ||
Button as RNButton, | ||
ButtonElement as RNButtonElement, | ||
ButtonProps as RNButtonProps, | ||
// @ts-ignore | ||
} from './button.component.tsx'; | ||
import { | ||
WebEventResponder, | ||
WebEventResponderCallbacks, | ||
WebEventResponderInstance, | ||
} from '../support/services'; | ||
|
||
export type ButtonProps = RNButtonProps & WebEventResponderCallbacks; | ||
export type ButtonElement = React.ReactElement<ButtonProps>; | ||
|
||
export class Button extends React.Component<ButtonProps> implements WebEventResponderCallbacks { | ||
|
||
private buttonRef: React.RefObject<any> = React.createRef(); | ||
private webEventResponder: WebEventResponderInstance = WebEventResponder.create(this); | ||
|
||
public onMouseEnter = (): void => { | ||
this.buttonRef.current.props.dispatch([Interaction.HOVER]); | ||
|
||
if (this.props.onMouseEnter) { | ||
this.props.onMouseEnter(); | ||
} | ||
}; | ||
|
||
public onMouseLeave = (): void => { | ||
this.buttonRef.current.props.dispatch([]); | ||
|
||
if (this.props.onMouseLeave) { | ||
this.props.onMouseLeave(); | ||
} | ||
}; | ||
|
||
public onFocus = (): void => { | ||
this.buttonRef.current.props.dispatch([Interaction.FOCUSED]); | ||
|
||
if (this.props.onFocus) { | ||
this.props.onFocus(); | ||
} | ||
}; | ||
|
||
public onBlur = (): void => { | ||
this.buttonRef.current.props.dispatch([]); | ||
|
||
if (this.props.onBlur) { | ||
this.props.onBlur(); | ||
} | ||
}; | ||
|
||
public render(): RNButtonElement { | ||
const { style, ...restProps } = this.props; | ||
|
||
return ( | ||
<RNButton | ||
{...restProps} | ||
{...this.webEventResponder.eventHandlers} | ||
ref={this.buttonRef} | ||
style={[style, styles.element]} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
element: { | ||
// @ts-ignore | ||
outlineWidth: 0, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.