Skip to content

Commit d094e6e

Browse files
♻️ Refine typescript typings
🔥 Remove unnecessary stuff
1 parent ed0c938 commit d094e6e

File tree

5 files changed

+51
-38
lines changed

5 files changed

+51
-38
lines changed

index.d.ts

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import React from 'react';
22
import { ImageStyle, TextStyle, ViewStyle } from 'react-native';
33

4-
export type TableProps = {
4+
export type Theme = 'light' | 'dark' | 'midnight';
5+
6+
export interface ColorPalette {
7+
background: string,
8+
section: string,
9+
separator: string,
10+
header: string,
11+
footer: string,
12+
accessory: string,
13+
title: string,
14+
subtitle: string,
15+
disabled: string,
16+
progress: string,
17+
18+
underlay: string,
19+
ripple: string,
20+
}
21+
22+
export interface TableProps {
523
accentColor?: string,
6-
theme?: 'light' | 'dark' | 'midnight',
24+
theme?: Theme,
725
blendAccent?: boolean,
826
disabled?: boolean,
927

@@ -13,7 +31,8 @@ export type TableProps = {
1331
children: React.ReactNode,
1432
scrollable?: boolean,
1533
}
16-
export type SectionProps = {
34+
35+
export interface SectionProps {
1736
disabled?: boolean,
1837

1938
children: React.ReactNode,
@@ -31,7 +50,8 @@ export type SectionProps = {
3150
separatorInsetLeft?: number,
3251
separatorInsetRight?: number,
3352
}
34-
export type CommonCellProps = {
53+
54+
export interface CommonCellProps {
3555
style?: ViewStyle,
3656

3757
disabled?: boolean,
@@ -42,18 +62,21 @@ export type CommonCellProps = {
4262
customActionType?: 'call' | 'compose' | 'openUrl',
4363
customActionTrigger?: 'onPress' | 'onLongPress',
4464
}
45-
export type CellProps = CommonCellProps & {
65+
66+
export interface CellProps extends CommonCellProps {
4667
children: React.ReactNode,
4768
}
48-
export type AccessoryCellProps = CommonCellProps & {
69+
70+
export interface AccessoryCellProps extends CommonCellProps {
4971
accessory?: 'disclosure' | 'details' | 'checkmark',
5072
accessoryComponent?: React.ReactNode,
5173
hideAccessorySeparator?: boolean,
5274
loading?: boolean,
5375

5476
onAccessoryPress?: () => void,
5577
}
56-
export type StaticCellProps = AccessoryCellProps & {
78+
79+
export interface StaticCellProps extends AccessoryCellProps {
5780
title: string,
5881
titleStyle?: TextStyle,
5982
subtitle?: string,
@@ -62,11 +85,13 @@ export type StaticCellProps = AccessoryCellProps & {
6285

6386
iconComponent?: React.ReactNode,
6487
}
65-
export type TouchableCellProps = AccessoryCellProps | {
88+
89+
export interface TouchableCellProps extends AccessoryCellProps {
6690
title: string,
6791
titleStyle?: TextStyle,
6892
}
69-
export type BioCellProps = AccessoryCellProps & {
93+
94+
export interface BioCellProps extends AccessoryCellProps {
7095
title: string,
7196
titleStyle?: TextStyle,
7297

@@ -79,7 +104,8 @@ export type BioCellProps = AccessoryCellProps & {
79104
photoSource?: object,
80105
photoStyle?: ImageStyle,
81106
}
82-
export type KeyValueCellProps = AccessoryCellProps & {
107+
108+
export interface KeyValueCellProps extends AccessoryCellProps {
83109
title: string,
84110
titleStyle?: TextStyle,
85111
value?: string,
@@ -88,7 +114,8 @@ export type KeyValueCellProps = AccessoryCellProps & {
88114

89115
iconComponent?: React.ReactNode,
90116
}
91-
export type SwitchCellProps = AccessoryCellProps & {
117+
118+
export interface SwitchCellProps extends AccessoryCellProps {
92119
title: string,
93120
titleStyle?: TextStyle,
94121
value?: boolean,
@@ -125,3 +152,9 @@ export class KeyValueCell extends React.Component<KeyValueCellProps> {
125152

126153
export class SwitchCell extends React.Component<SwitchCellProps> {
127154
}
155+
156+
declare const ThemeContext: React.Context<Theme>;
157+
declare const ThemeProvider: React.Provider<Theme>;
158+
declare const ThemeConsumer: React.Consumer<Theme>;
159+
160+
export { ThemeContext, ThemeProvider, ThemeConsumer };

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TouchableCell from './src/TouchableCell';
77
import BioCell from './src/BioCell';
88
import KeyValueCell from './src/KeyValueCell';
99
import SwitchCell from './src/SwitchCell';
10+
import { ThemeConsumer, ThemeContext, ThemeProvider } from './src/ThemeContext';
1011

1112
export default Table;
1213
export {
@@ -19,4 +20,7 @@ export {
1920
BioCell,
2021
KeyValueCell,
2122
SwitchCell,
23+
ThemeContext,
24+
ThemeConsumer,
25+
ThemeProvider,
2226
};

src/assets/colors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const getColorPalette = (theme, blend, accent) => {
3535
footer: Platform.OS === 'ios' ? '#8F8F95' : '#9f9fa6',
3636
accessory: Platform.OS === 'ios' ? '#969696' : '#9c9ca0',
3737
title: Platform.OS === 'ios' ? 'white' : '#e6e6e6',
38-
subtitle: '#8E8E93', // <-
38+
subtitle: '#8E8E93',
3939
disabled: '#4b4b4b',
4040
progress: Platform.OS === 'ios' ? '#c8c8c8' : accent,
4141

@@ -51,7 +51,7 @@ export const getColorPalette = (theme, blend, accent) => {
5151
footer: Platform.OS === 'ios' ? '#919191' : '#a2a2a2',
5252
accessory: Platform.OS === 'ios' ? '#5c5c5c' : '#666666',
5353
title: Platform.OS === 'ios' ? 'white' : '#E1E1E1',
54-
subtitle: '#99989D', // <-
54+
subtitle: '#99989D',
5555
disabled: '#4b4b4b',
5656
progress: Platform.OS === 'ios' ? '#c8c8c8' : accent,
5757

src/assets/icons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Image, I18nManager } from 'react-native';
2+
import { I18nManager, Image } from 'react-native';
33
import PropTypes from 'prop-types';
44

55
import disclosure from './disclosure.png';

src/assets/utilites.js

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

0 commit comments

Comments
 (0)