Skip to content

Commit c0a3e36

Browse files
committed
Revert "Assets Typing (#3051)"
This reverts commit 83ff9a6.
1 parent eb0f0e4 commit c0a3e36

File tree

20 files changed

+50
-63
lines changed

20 files changed

+50
-63
lines changed

demo/src/assets/Assets.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

demo/src/configurations.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1-
import {Colors, Typography, Spacings, TextField} from 'react-native-ui-lib'; // eslint-disable-line
1+
import {Assets, Colors, Typography, Spacings, Incubator} from 'react-native-ui-lib'; // eslint-disable-line
22

33
export const loadDemoConfigurations = () => {
4-
require('./assets/Assets');
4+
Assets.loadAssetsGroup('icons.demo', {
5+
chevronDown: require('./assets/icons/chevronDown.png'),
6+
chevronRight: require('./assets/icons/chevronRight.png'),
7+
add: require('./assets/icons/add.png'),
8+
camera: require('./assets/icons/cameraSelected.png'),
9+
close: require('./assets/icons/close.png'),
10+
dashboard: require('./assets/icons/dashboard.png'),
11+
drag: require('./assets/icons/drag.png'),
12+
image: require('./assets/icons/image.png'),
13+
plus: require('./assets/icons/plus.png'),
14+
refresh: require('./assets/icons/refresh.png'),
15+
search: require('./assets/icons/search.png'),
16+
settings: require('./assets/icons/settings.png'),
17+
share: require('./assets/icons/share.png')
18+
});
19+
20+
Assets.loadAssetsGroup('images.demo', {
21+
brokenImage: require('./assets/images/placeholderMissingImage.png')
22+
});
23+
24+
Assets.loadAssetsGroup('svgs.demo', {
25+
logo: require('./assets/svgs/headerLogo.svg').default
26+
});
27+
528
Typography.loadTypographies({
629
h1: {...Typography.text40},
730
h2: {...Typography.text50},

demo/src/screens/componentScreens/DrawerScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, {Component} from 'react';
22
import {StyleSheet, ScrollView, LayoutAnimation} from 'react-native';
3-
import {Colors, Typography, View, Drawer, Text, Button, Avatar, Badge, DrawerProps} from 'react-native-ui-lib';
3+
import {Assets, Colors, Typography, View, Drawer, Text, Button, Avatar, Badge, DrawerProps} from 'react-native-ui-lib';
44
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
55
import conversations from '../../data/conversations';
6-
import Assets from '../../assets/Assets';
76

87
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';
98

demo/src/screens/componentScreens/HintsScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {Alert, ViewStyle} from 'react-native';
4-
import {Colors, View, Text, Hint, Button, Incubator} from 'react-native-ui-lib';
4+
import {Colors, View, Text, Hint, Button, Assets, Incubator} from 'react-native-ui-lib';
55
import {renderMultipleSegmentOptions, renderBooleanOption} from '../ExampleScreenPresenter';
6-
import Assets from '../../assets/Assets';
76

87
const settingsIcon = require('../../assets/icons/settings.png');
98
const reactions = ['❤️', '😮', '😔', '😂', '😡'];

demo/src/screens/componentScreens/ImageScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, {Component} from 'react';
22
import {ScrollView} from 'react-native';
3-
import {View, Text, Icon, Image, Colors, OverlayTypes} from 'react-native-ui-lib';
3+
import {View, Text, Icon, Image, Colors, Assets, OverlayTypes} from 'react-native-ui-lib';
44
import {renderBooleanOption, renderRadioGroup, renderSliderOption} from '../ExampleScreenPresenter';
5-
import Assets from '../../assets/Assets';
65

76
const IMAGE_URL =
87
'https://images.pexels.com/photos/748837/pexels-photo-748837.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260';

demo/src/screens/componentScreens/ModalScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, {Component} from 'react';
22
import {Alert, StyleSheet} from 'react-native';
33
import {Navigation} from 'react-native-navigation';
4-
import {Colors, Carousel, PageControl, Modal, View, Text} from 'react-native-ui-lib'; // eslint-disable-line
5-
import Assets from '../../assets/Assets';
4+
import {Colors, Carousel, PageControl, Modal, View, Text, Assets} from 'react-native-ui-lib'; // eslint-disable-line
65

76
const BUTTONS_HIT_SLOP = {right: 5, left: 5, top: 10, bottom: 10};
87
interface ModalScreenProps {

demo/src/screens/componentScreens/SortableListScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
TouchableOpacity,
99
Text,
1010
Icon,
11+
Assets,
1112
Colors,
1213
Button
1314
} from 'react-native-ui-lib';
14-
import Assets from '../../assets/Assets';
1515
import {renderHeader} from '../ExampleScreenPresenter';
1616

1717
interface Item extends SortableListItemProps {

demo/src/screens/componentScreens/TabControllerScreen/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {ActivityIndicator, StyleSheet} from 'react-native';
44
import {
5+
Assets,
56
TabController,
67
Colors,
78
View,
@@ -11,7 +12,6 @@ import {
1112
TabControllerImperativeMethods
1213
} from 'react-native-ui-lib';
1314
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
14-
import Assets from '../../../assets/Assets';
1515

1616
import Tab1 from './tab1';
1717
import Tab2 from './tab2';

demo/src/screens/componentScreens/TextFieldScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
TextFieldRef,
1212
FieldContextType,
1313
TextFieldProps,
14-
SegmentedControl
14+
SegmentedControl,
15+
Assets
1516
} from 'react-native-ui-lib';
16-
import Assets from '../../assets/Assets';
1717
const {KeyboardAwareInsetsView} = Keyboard;
1818
const priceFormatter = Intl.NumberFormat('en-US');
1919
const validationIcon = require('../../assets/icons/exclamationFillSmall.png');

demo/src/screens/componentScreens/TimelineScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useCallback, useRef, useState} from 'react';
22
import {StyleSheet, ScrollView} from 'react-native';
3-
import {Colors, Timeline, View, Card, Text, Button} from 'react-native-ui-lib';
4-
import Assets from '../../assets/Assets';
3+
import {Assets, Colors, Timeline, View, Card, Text, Button} from 'react-native-ui-lib';
4+
55
const contents = [
66
'CURRENT (default) state with dashed line.\nAligned to title',
77
'SUCCESS state with label.',

demo/src/screens/incubatorScreens/IncubatorToastScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, {Component} from 'react';
22
import {ScrollView, StyleSheet} from 'react-native';
3-
import {Colors, View, Button, Text, Incubator} from 'react-native-ui-lib';
3+
import {Assets, Colors, View, Button, Text, Incubator} from 'react-native-ui-lib';
44
import {renderMultipleSegmentOptions, renderBooleanOption, renderRadioGroup} from '../ExampleScreenPresenter';
55
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
6-
import Assets from '../../assets/Assets';
6+
77
const {Toast} = Incubator;
88

99
const TOAST_ACTIONS = {

demo/src/screens/incubatorScreens/PanViewScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {Component} from 'react';
22
import {StyleSheet, ScrollView} from 'react-native';
33
import {GestureHandlerRootView, FlatList} from 'react-native-gesture-handler';
44
import {
5+
Assets,
56
View,
67
Text,
78
Colors,
@@ -14,7 +15,7 @@ import {
1415
TouchableOpacity
1516
} from 'react-native-ui-lib';
1617
const {PanView} = Incubator;
17-
import Assets from '../../assets/Assets';
18+
1819
interface Item {
1920
value: string;
2021
label: string;

demo/src/screens/realExamples/Pinterest/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, {Component} from 'react';
22
import {StyleSheet, ScrollView} from 'react-native';
3-
import {Colors, Spacings, View, Card, Text, Image, Button, Constants} from 'react-native-ui-lib';
3+
import {Assets, Colors, Spacings, View, Card, Text, Image, Button, Constants} from 'react-native-ui-lib';
44
import _ from 'lodash';
5-
import Assets from '../../../assets/Assets';
65

76
import './configurations';
87

demo/src/screens/realExamples/ProductPage/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, {Component} from 'react';
22
import {ScrollView} from 'react-native';
3-
import {View, Text, Icon, Colors, Image, Button, Carousel, Picker, PickerValue} from 'react-native-ui-lib';
3+
import {Assets, View, Text, Icon, Colors, Image, Button, Carousel, Picker, PickerValue} from 'react-native-ui-lib';
44
import _ from 'lodash';
5-
import Assets from '../../../assets/Assets';
65

76
const colorOptions = [
87
{label: 'Red', value: 'red', color: Colors.red30},

src/assets/Assets.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import _ from 'lodash';
2-
import type {AssetRecord} from '../typings/assets';
32

43
interface CustomObject {
54
[key: string]: any;
@@ -42,7 +41,7 @@ function ensurePath(obj: CustomObject, path: string) {
4241
export class Assets {
4342
[key: string]: any;
4443

45-
loadAssetsGroup<T extends string, K extends object>(groupName: T, assets: K): asserts this is AssetRecord<typeof this, T, K> {
44+
loadAssetsGroup(groupName: string, assets: object) {
4645
if (!_.isString(groupName)) {
4746
throw new Error('group name should be a string');
4847
}
@@ -56,6 +55,8 @@ export class Assets {
5655
} else {
5756
assignProperties(ensurePath(this, groupName), assets);
5857
}
58+
59+
return this;
5960
}
6061

6162
getAssetByPath(path: string) {

src/assets/__tests__/Assets.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('Assets', () => {
88
});
99

1010
describe('.loadAssetsGroup(groupName, assets)', () => {
11-
it.skip('should return the assets object itself', () => {
11+
it('should return the assets object itself', () => {
1212
expect(assets.loadAssetsGroup('emojis', {})).toBe(assets);
1313
});
1414

src/assets/emojis/index.ts renamed to src/assets/emojis/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,5 +1342,5 @@ export const emojis = {
13421342
"woman-woman-girl-girl": "👩‍👩‍👧‍👧",
13431343
"woman-heart-woman": "👩‍❤️‍👩",
13441344
"woman-kiss-woman": "👩‍❤️‍💋‍👩"
1345-
} as const;
1345+
}
13461346

File renamed without changes.
File renamed without changes.

src/assets/index.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import {Assets} from './Assets';
2-
import type {icons} from './icons';
3-
import type {emojis} from './emojis';
4-
import type {images} from './images';
52

6-
7-
const assets: Assets = new Assets();
8-
assets.loadAssetsGroup('', {
9-
get icons(): typeof icons {
3+
export default new Assets().loadAssetsGroup('', {
4+
get icons() {
105
return require('./icons').icons;
116
},
12-
get emojis(): typeof emojis {
7+
get emojis() {
138
return require('./emojis').emojis;
149
},
15-
get images(): typeof images {
10+
get images() {
1611
return require('./images').images;
1712
}
1813
});
19-
const ExportedAssets: typeof assets = assets;
20-
export default ExportedAssets;

0 commit comments

Comments
 (0)