-
Notifications
You must be signed in to change notification settings - Fork 734
Typescript/connection status bar #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f851f03
ConnectionStatusBar migrate to typescript
mendyEdri b968812
migrate screen and index to typescript
mendyEdri 1c1e3c0
docs
mendyEdri 82e057e
generated types
mendyEdri 755bd92
types file and export asBaseComponent
mendyEdri 3364a4c
Fix tests import
mendyEdri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,28 @@ | ||
export declare type ConnectionStatusBarProps = { | ||
/** | ||
* Text to show as the status | ||
*/ | ||
label?: string; | ||
/** | ||
* Handler to get connection change events propagation | ||
*/ | ||
onConnectionChange?: (isConnected: boolean, isInitial: boolean) => void; | ||
/** | ||
* Text to show as the status | ||
*/ | ||
allowDismiss?: boolean; | ||
/** | ||
* Use absolute position for the component | ||
*/ | ||
useAbsolutePosition?: boolean; | ||
}; | ||
export declare type ConnectionStatusBarState = { | ||
type?: string; | ||
isConnected: boolean; | ||
isCancelled: boolean; | ||
}; | ||
export declare const DEFAULT_PROPS: { | ||
label: string; | ||
allowDismiss: boolean; | ||
useAbsolutePosition: boolean; | ||
}; |
This file contains hidden or 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,35 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { ConnectionStatusBarProps, ConnectionStatusBarState } from './Types'; | ||
export { ConnectionStatusBarProps }; | ||
/** | ||
* @description: Top bar to show a "no internet" connection status. Note: Run on real device for best results | ||
* @image: https://user-images.githubusercontent.com/33805983/34683190-f3b1904c-f4a9-11e7-9d46-9a340bd35448.png, https://user-images.githubusercontent.com/33805983/34484206-edc6c6e4-efcb-11e7-88b2-cd394c19dd5e.png | ||
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ConnectionStatusBarScreen.js | ||
* @notes: The component requires installing the '@react-native-community/netinfo' native library | ||
*/ | ||
declare class ConnectionStatusBar extends PureComponent<ConnectionStatusBarProps, ConnectionStatusBarState> { | ||
static displayName: string; | ||
static defaultProps: { | ||
label: string; | ||
allowDismiss: boolean; | ||
useAbsolutePosition: boolean; | ||
}; | ||
styles?: any; | ||
unsubscribe?: any; | ||
static onConnectionLost?: () => void; | ||
static registerGlobalOnConnectionLost(callback: () => void): void; | ||
static unregisterGlobalOnConnectionLost(): void; | ||
constructor(props: ConnectionStatusBarProps); | ||
generateStyles(): void; | ||
componentDidMount(): void; | ||
componentWillUnmount(): void; | ||
onConnectionChange(state: ConnectionStatusBarState): void; | ||
getInitialConnectionState(): Promise<void>; | ||
isStateConnected(state: ConnectionStatusBarState): boolean; | ||
render(): false | JSX.Element; | ||
} | ||
export { ConnectionStatusBar }; | ||
declare const _default: React.ComponentClass<ConnectionStatusBarProps & { | ||
useCustomTheme?: boolean | undefined; | ||
}, any> & typeof ConnectionStatusBar; | ||
export default _default; |
This file contains hidden or 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,50 @@ | ||
import {PureComponent} from 'react'; | ||
|
||
export type ConnectionStatusBarProps = { | ||
/** | ||
* Text to show as the status | ||
*/ | ||
label?: string; | ||
/** | ||
* Handler to get connection change events propagation | ||
*/ | ||
onConnectionChange?: (isConnected: boolean, isInitial: boolean) => void; | ||
/** | ||
* Text to show as the status | ||
*/ | ||
allowDismiss?: boolean; | ||
/** | ||
* Use absolute position for the component | ||
*/ | ||
useAbsolutePosition?: boolean; | ||
}; | ||
|
||
export type ConnectionStatusBarState = { | ||
/* Current connection type */ | ||
type?: string; | ||
isConnected: boolean; | ||
isCancelled: boolean; | ||
}; | ||
|
||
export const DEFAULT_PROPS = { | ||
label: 'No internet. Check your connection.', | ||
allowDismiss: false, | ||
useAbsolutePosition: true | ||
}; | ||
|
||
/** | ||
* @description: Top bar to show a "no internet" connection status. Note: Run on real device for best results | ||
* @image: https://user-images.githubusercontent.com/33805983/34683190-f3b1904c-f4a9-11e7-9d46-9a340bd35448.png, https://user-images.githubusercontent.com/33805983/34484206-edc6c6e4-efcb-11e7-88b2-cd394c19dd5e.png | ||
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ConnectionStatusBarScreen.js | ||
* @notes: The component requires installing the '@react-native-community/netinfo' native library | ||
*/ | ||
// @ts-ignore | ||
class FakeConnectionStatusBarForDocs extends PureComponent<ConnectionStatusBarProps, ConnectionStatusBarState> { // eslint-disable-line | ||
static displayName = 'ConnectionStatusBar'; | ||
|
||
static defaultProps = DEFAULT_PROPS; | ||
|
||
render() { | ||
return null; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this long name? Can't jusr use 'State'?