Skip to content

Typescript/loader screen #1458

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 5 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generatedTypes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export {default as PageControl, PageControlProps} from './components/pageControl
export {default as Carousel, CarouselProps, PageControlPosition} from './components/carousel';
export {default as ActionSheet} from './components/actionSheet';
export {default as Wizard, WizardProps, WizardStepProps, WizardStepStates, WizardStepConfig, WizardStepsConfig} from './components/wizard';
export {default as LoaderScreen, LoaderScreenProps} from './components/loaderScreen';

/* All components with manual typings */
export {
Expand All @@ -101,7 +102,6 @@ export {
UIComponent,
forwardRef,
AvatarHelper,
LoaderScreen,
StateScreen,
WheelPicker,
WheelPickerProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,15 @@
import PropTypes from 'prop-types';
import React from 'react';
import React, {Component} from 'react';
import {StyleSheet, ActivityIndicator} from 'react-native';
import {Colors, Typography} from '../../style';
import {Constants} from '../../helpers';
import {BaseComponent} from '../../commons';
import {asBaseComponent} from '../../commons/new';
import View from '../../components/view';
import Text from '../../components/text';
import {LoaderScreenProps} from './types';

/**
* @description: Component that shows a full screen with an activity indicator
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/LoadingScreen.js
*
*/
export default class LoaderScreen extends BaseComponent {
class LoaderScreen extends Component<LoaderScreenProps> {
static displayName = 'LoaderScreen';

static propTypes = {
...ActivityIndicator.propTypes,
/**
* Color of the loading indicator
*/
loaderColor: PropTypes.string,
/**
* Custom loader
*/
customLoader: PropTypes.element,
/**
* Color of the loader background (only when passing 'overlay')
*/
backgroundColor: PropTypes.string,
/**
* loader message
*/
message: PropTypes.string,
/**
* message style
*/
messageStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
/**
* Show the screen as an absolute overlay
*/
overlay: PropTypes.bool
/**
* Custom container style
*/
};

render() {
const {
message,
Expand Down Expand Up @@ -76,6 +40,9 @@ export default class LoaderScreen extends BaseComponent {
}
}

export {LoaderScreenProps};
export default asBaseComponent<LoaderScreenProps>(LoaderScreen);

const styles = StyleSheet.create({
container: {
flex: 1
Expand Down
47 changes: 47 additions & 0 deletions src/components/loaderScreen/types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {PureComponent} from 'react';
import {ActivityIndicatorProps, TextStyle, ViewStyle} from 'react-native';

export type LoaderScreenProps = ActivityIndicatorProps & {
/**
* Color of the loading indicator
*/
loaderColor?: string;
/**
* Custom loader
*/
customLoader?: React.ReactChild;
/**
* Color of the loader background (only when passing 'overlay')
*/
backgroundColor?: string;
/**
* loader message
*/
message?: string;
/**
* message style
*/
messageStyle?: TextStyle,
/**
* Show the screen as an absolute overlay
*/
overlay?: boolean;
/**
* Custom container style
*/
containerStyle?: ViewStyle;
};


/**
* @description: Component that shows a full screen with an activity indicator
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/LoadingScreen.tsx
*/
// @ts-ignore
class FakeLoaderScreenForDocs extends PureComponent<LoaderScreenProps> { // eslint-disable-line
static displayName = 'LoaderScreen';

render() {
return null;
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export {default as Slider, SliderProps} from './components/slider';
export {default as GradientSlider, GradientSliderProps} from './components/slider/GradientSlider';
export {default as ColorSliderGroup, ColorSliderGroupProps} from './components/slider/ColorSliderGroup';
export {default as LogService} from './services/LogService';
export {default as LoaderScreen, LoaderScreenProps} from './components/loaderScreen';

//================ Manual typings (all those exports should be removed one day) ==========
export {
Expand All @@ -86,5 +87,5 @@ export {
PickerProps, ProgressBar, Stepper,
TagsInput, SharedTransition, Toast, WheelPickerDialog, Assets,
BaseComponent, PureBaseComponent, UIComponent, forwardRef,
LoaderScreen, StateScreen, WheelPicker, WheelPickerProps
StateScreen, WheelPicker, WheelPickerProps
} from '../typings';
13 changes: 0 additions & 13 deletions typings/components/LoaderScreen.d.ts

This file was deleted.