jornada-ui 0.4.13 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/activities-progress/index.js +10 -10
- package/lib/commonjs/components/activities-progress/index.js.map +1 -1
- package/lib/commonjs/components/card-work-session/index.js +50 -17
- package/lib/commonjs/components/card-work-session/index.js.map +1 -1
- package/lib/commonjs/components/list-devices/components/list-device-empty/index.js +68 -0
- package/lib/commonjs/components/list-devices/components/list-device-empty/index.js.map +1 -0
- package/lib/commonjs/components/list-devices/components/list-device-render-item/index.js +77 -0
- package/lib/commonjs/components/list-devices/components/list-device-render-item/index.js.map +1 -0
- package/lib/commonjs/components/list-devices/index.js +22 -54
- package/lib/commonjs/components/list-devices/index.js.map +1 -1
- package/lib/commonjs/components/list-devices/interface.js +2 -0
- package/lib/commonjs/components/list-devices/interface.js.map +1 -0
- package/lib/commonjs/components/list-devices/styles.js +14 -3
- package/lib/commonjs/components/list-devices/styles.js.map +1 -1
- package/lib/commonjs/stories/card-work-session/card-work-session.stories.js +62 -9
- package/lib/commonjs/stories/card-work-session/card-work-session.stories.js.map +1 -1
- package/lib/module/components/activities-progress/index.js +10 -10
- package/lib/module/components/activities-progress/index.js.map +1 -1
- package/lib/module/components/card-work-session/index.js +50 -17
- package/lib/module/components/card-work-session/index.js.map +1 -1
- package/lib/module/components/list-devices/components/list-device-empty/index.js +63 -0
- package/lib/module/components/list-devices/components/list-device-empty/index.js.map +1 -0
- package/lib/module/components/list-devices/components/list-device-render-item/index.js +74 -0
- package/lib/module/components/list-devices/components/list-device-render-item/index.js.map +1 -0
- package/lib/module/components/list-devices/index.js +25 -57
- package/lib/module/components/list-devices/index.js.map +1 -1
- package/lib/module/components/list-devices/interface.js +2 -0
- package/lib/module/components/list-devices/interface.js.map +1 -0
- package/lib/module/components/list-devices/styles.js +14 -3
- package/lib/module/components/list-devices/styles.js.map +1 -1
- package/lib/module/stories/card-work-session/card-work-session.stories.js +62 -9
- package/lib/module/stories/card-work-session/card-work-session.stories.js.map +1 -1
- package/lib/typescript/commonjs/src/components/card-work-session/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/card-work-session/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/list-devices/components/list-device-empty/index.d.ts +10 -0
- package/lib/typescript/commonjs/src/components/list-devices/components/list-device-empty/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/list-devices/components/list-device-render-item/index.d.ts +22 -0
- package/lib/typescript/commonjs/src/components/list-devices/components/list-device-render-item/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/list-devices/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/list-devices/interface.d.ts +29 -0
- package/lib/typescript/commonjs/src/components/list-devices/interface.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/list-devices/styles.d.ts +5 -5
- package/lib/typescript/commonjs/src/components/list-devices/styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/stories/card-work-session/card-work-session.stories.d.ts.map +1 -1
- package/lib/typescript/module/src/components/card-work-session/index.d.ts +2 -1
- package/lib/typescript/module/src/components/card-work-session/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/list-devices/components/list-device-empty/index.d.ts +10 -0
- package/lib/typescript/module/src/components/list-devices/components/list-device-empty/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/list-devices/components/list-device-render-item/index.d.ts +22 -0
- package/lib/typescript/module/src/components/list-devices/components/list-device-render-item/index.d.ts.map +1 -0
- package/lib/typescript/module/src/components/list-devices/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/list-devices/interface.d.ts +29 -0
- package/lib/typescript/module/src/components/list-devices/interface.d.ts.map +1 -0
- package/lib/typescript/module/src/components/list-devices/styles.d.ts +5 -5
- package/lib/typescript/module/src/components/list-devices/styles.d.ts.map +1 -1
- package/lib/typescript/module/src/stories/card-work-session/card-work-session.stories.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/activities-progress/index.tsx +172 -172
- package/src/components/card-work-session/index.tsx +190 -172
- package/src/components/card-work-session/interface.d.ts +151 -150
- package/src/components/list-devices/components/list-device-empty/index.tsx +60 -0
- package/src/components/list-devices/components/list-device-render-item/index.tsx +86 -0
- package/src/components/list-devices/index.tsx +26 -58
- package/src/components/list-devices/{interface.d.ts → interface.ts} +36 -36
- package/src/components/list-devices/styles.ts +73 -68
- package/src/stories/card-work-session/card-work-session.stories.tsx +106 -53
- package/lib/commonjs/components/list-devices/interface.d.js +0 -2
- package/lib/commonjs/components/list-devices/interface.d.js.map +0 -1
- package/lib/module/components/list-devices/interface.d.js +0 -2
- package/lib/module/components/list-devices/interface.d.js.map +0 -1
|
@@ -1,150 +1,151 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* IMPORTS
|
|
3
|
-
*/
|
|
4
|
-
import type React from "react";
|
|
5
|
-
import { ViewProps, type DimensionValue } from "react-native";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* INTERFACE
|
|
9
|
-
*/
|
|
10
|
-
type ICardWorkSession = ViewProps & {
|
|
11
|
-
/**
|
|
12
|
-
* props que mostra o nome do usuário
|
|
13
|
-
*/
|
|
14
|
-
name: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* props que mostra a data
|
|
18
|
-
*/
|
|
19
|
-
workDate: string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* props que mostra o
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* props que mostra
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* props que mostra
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| "flex-
|
|
88
|
-
| "
|
|
89
|
-
| "
|
|
90
|
-
| "space-
|
|
91
|
-
| "space-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import type React from "react";
|
|
5
|
+
import { ViewProps, type DimensionValue } from "react-native";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* INTERFACE
|
|
9
|
+
*/
|
|
10
|
+
type ICardWorkSession = ViewProps & {
|
|
11
|
+
/**
|
|
12
|
+
* props que mostra o nome do usuário
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* props que mostra a data
|
|
18
|
+
*/
|
|
19
|
+
workDate: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* props que mostra o horário inicial
|
|
23
|
+
*/
|
|
24
|
+
initialTime?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* props que mostra a duração
|
|
28
|
+
*/
|
|
29
|
+
duration?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* props que mostra o avatar do usuário
|
|
33
|
+
*/
|
|
34
|
+
avatar: string;
|
|
35
|
+
|
|
36
|
+
handleNavigation: () => void;
|
|
37
|
+
handleNavigationNotification: () => void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* props que mostra a quantidade de notificações
|
|
41
|
+
*/
|
|
42
|
+
counterBadge: number;
|
|
43
|
+
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* TestID para testes automático e identificação
|
|
48
|
+
*/
|
|
49
|
+
testID?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A propriedade CSS abreviada border define a borda de um elemento. Ele define os valores de largura da borda, estilo da borda e cor da borda.
|
|
53
|
+
*/
|
|
54
|
+
borderStyled?: {
|
|
55
|
+
borderStyle?: "solid" | "dotted" | "dashed";
|
|
56
|
+
|
|
57
|
+
borderRadius?: number | DimensionValue;
|
|
58
|
+
borderTopRightRadius?: number | DimensionValue;
|
|
59
|
+
borderTopLeftRadius?: number | DimensionValue;
|
|
60
|
+
borderBottomRightRadius?: number | DimensionValue;
|
|
61
|
+
borderBottomLeftRadius?: number | DimensionValue;
|
|
62
|
+
|
|
63
|
+
borderWidth?: number | DimensionValue;
|
|
64
|
+
borderLeftWidth?: number | DimensionValue;
|
|
65
|
+
borderRightWidth?: number | DimensionValue;
|
|
66
|
+
borderTopWidth?: number | DimensionValue;
|
|
67
|
+
borderBottomWidth?: number | DimensionValue;
|
|
68
|
+
|
|
69
|
+
borderColor?: string;
|
|
70
|
+
borderBottomColor?: string;
|
|
71
|
+
borderLeftColor?: string;
|
|
72
|
+
borderRightColor?: string;
|
|
73
|
+
borderTopColor?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Propriedades que define a orientação do button que é usada para representar uma página. Na maioria das vezes, esse valores corresponde ao posicionamento alvo da página impressa, se aplicável.
|
|
78
|
+
*/
|
|
79
|
+
flexStyle?: {
|
|
80
|
+
alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
81
|
+
alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
82
|
+
flex?: string | number;
|
|
83
|
+
flexDirection?: "column" | "column-reverse" | "row" | "row-reverse";
|
|
84
|
+
flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
|
|
85
|
+
textAlign?: "auto" | "center" | "left" | "right" | "justify";
|
|
86
|
+
justifyContent?:
|
|
87
|
+
| "flex-start"
|
|
88
|
+
| "flex-end"
|
|
89
|
+
| "center"
|
|
90
|
+
| "space-between"
|
|
91
|
+
| "space-around"
|
|
92
|
+
| "space-evenly";
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A propriedade margin do CSS define a área de margem nos quatro lados do elemento. É uma abreviação que define todas as margens individuais de uma só vez: margin-top, margin-right (en-US), margin-bottom, e margin-left (en-US).
|
|
97
|
+
*/
|
|
98
|
+
marginStyle?: {
|
|
99
|
+
margin?: number | DimensionValue;
|
|
100
|
+
marginLeft?: number | DimensionValue;
|
|
101
|
+
marginRight?: number | DimensionValue;
|
|
102
|
+
marginTop?: number | DimensionValue;
|
|
103
|
+
marginBottom?: number | DimensionValue;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A propriedade padding define uma a distância entre o conteúdo de um elemento e suas bordas. É um atalho que evita definir uma distância para cada lado separadamente (padding-top, padding-right, padding-bottom, padding-left).
|
|
108
|
+
*/
|
|
109
|
+
paddingStyle?: {
|
|
110
|
+
padding?: number | DimensionValue;
|
|
111
|
+
paddingLeft?: number | DimensionValue;
|
|
112
|
+
paddingRight?: number | DimensionValue;
|
|
113
|
+
paddingTop?: number | DimensionValue;
|
|
114
|
+
paddingBottom?: number | DimensionValue;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A propriedade CSS height define a altura de um elemento. A altura de um elemento é a distância do topo da borda superior do elemento ao fundo da borda inferior.
|
|
119
|
+
*/
|
|
120
|
+
height?: number | DimensionValue;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A propriedade CSS width define a largura de um elemento. A largura de um elemento é a distância do topo da borda esquerda do elemento ao fundo da borda direita.
|
|
124
|
+
*/
|
|
125
|
+
width?: number | DimensionValue;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* O fundo abreviado CSS Propriedade define todas as propriedades do estilo de fundo de uma só vez, como cor, imagem, origem e tamanho ou método de repetição. As propriedades dos componentes não definidas no fundo da declaração de valor da propriedade abreviada são definidas como seus valores padrão..
|
|
129
|
+
*/
|
|
130
|
+
backgroundColor?: string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Propriedade texto que sera renderizado pro usuário final
|
|
134
|
+
*/
|
|
135
|
+
text?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* A propriedade CSS color define o valor da cor de primeiro plano do texto e das decorações de texto de um elemento e define o valor currentcolor. currentcolor pode ser usado como um valor indireto em outras propriedades e é o padrão para outras propriedades de cores, como border-color.
|
|
139
|
+
*/
|
|
140
|
+
color?: {
|
|
141
|
+
colorSvg?: string;
|
|
142
|
+
colorText?: string;
|
|
143
|
+
colorTextBold?: string;
|
|
144
|
+
colorTextData?: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* EXPORTS
|
|
150
|
+
*/
|
|
151
|
+
export type { ICardWorkSession };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import React, { forwardRef } from "react";
|
|
5
|
+
|
|
6
|
+
// components
|
|
7
|
+
import Box from "../../../box";
|
|
8
|
+
import Typography from "../../../typography";
|
|
9
|
+
|
|
10
|
+
// typings
|
|
11
|
+
import { asBaseComponent } from "../../../../@types/as-base-component";
|
|
12
|
+
|
|
13
|
+
// styles
|
|
14
|
+
import { Icons } from "../../../../common/icons-svg";
|
|
15
|
+
import { theme } from "../../../../styles/theme/theme";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Componente ListDeviceEmpty para a exibição de messagens
|
|
19
|
+
*/
|
|
20
|
+
const ListDeviceEmpty = forwardRef<any, any>((_prop, ref): React.ReactElement => {
|
|
21
|
+
return (
|
|
22
|
+
<Box
|
|
23
|
+
ref={ref}
|
|
24
|
+
width={"100%"}
|
|
25
|
+
flexStyle={{
|
|
26
|
+
flex: 1,
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Box
|
|
33
|
+
width={"100%"}
|
|
34
|
+
height={60}
|
|
35
|
+
flexStyle={{
|
|
36
|
+
flex: 1,
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<Icons icon={"FILES"} size={28} color={theme.colors.gray[800]} />
|
|
43
|
+
<Typography
|
|
44
|
+
text={"Sem Relações de dispositivos."}
|
|
45
|
+
align={"center"}
|
|
46
|
+
size={theme.fontSizes.md}
|
|
47
|
+
fontFamily={theme.fonts.inter_regular_400}
|
|
48
|
+
color={theme.colors.gray[800]}
|
|
49
|
+
lineHeight={24}
|
|
50
|
+
letterSpacing={"regular"}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
</Box>
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Componente ListDeviceEmpty para a interação da ui.
|
|
59
|
+
*/
|
|
60
|
+
export default asBaseComponent(ListDeviceEmpty);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* IMPORTS
|
|
5
|
+
*/
|
|
6
|
+
import React, { useMemo } from "react";
|
|
7
|
+
|
|
8
|
+
import { Text, TouchableOpacity, View } from "react-native";
|
|
9
|
+
|
|
10
|
+
// commons / svg
|
|
11
|
+
import { Icons } from "../../../../common/icons-svg";
|
|
12
|
+
|
|
13
|
+
// typings
|
|
14
|
+
import type { IData } from "../../interface";
|
|
15
|
+
|
|
16
|
+
// styles
|
|
17
|
+
import { theme } from "../../../../styles/theme/theme";
|
|
18
|
+
import { styles as makeStyles } from "../../styles";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Componente DeviceRow para a exibição de um item da lista de dispositivos
|
|
22
|
+
*/
|
|
23
|
+
const DeviceRow = React.memo(function DeviceRow({
|
|
24
|
+
device,
|
|
25
|
+
isSelected,
|
|
26
|
+
isLast,
|
|
27
|
+
disabled,
|
|
28
|
+
onPress,
|
|
29
|
+
titleColor,
|
|
30
|
+
textColorDescription,
|
|
31
|
+
}: {
|
|
32
|
+
device: IData;
|
|
33
|
+
isSelected: boolean;
|
|
34
|
+
isLast: boolean;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
onPress: (d: IData) => void;
|
|
37
|
+
titleColor?: string;
|
|
38
|
+
textColorDescription?: string;
|
|
39
|
+
}) {
|
|
40
|
+
// estilos base/memoizados (evite recriar objetos grandes)
|
|
41
|
+
const s = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
makeStyles({
|
|
44
|
+
titleColor,
|
|
45
|
+
textColorDescription,
|
|
46
|
+
disabled,
|
|
47
|
+
isSelected,
|
|
48
|
+
}),
|
|
49
|
+
[titleColor, textColorDescription, disabled, isSelected]
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<TouchableOpacity
|
|
54
|
+
activeOpacity={0.7}
|
|
55
|
+
testID="list-devices"
|
|
56
|
+
onPress={() => onPress(device)}
|
|
57
|
+
disabled={disabled}
|
|
58
|
+
accessibilityRole="button"
|
|
59
|
+
accessibilityState={{ selected: isSelected, disabled }}
|
|
60
|
+
accessibilityLabel={`Dispositivo ${device.nameDevice}`}
|
|
61
|
+
style={[
|
|
62
|
+
s.containerIndicator,
|
|
63
|
+
!isLast && s.separator,
|
|
64
|
+
isSelected && s.containerIndicatorSelected,
|
|
65
|
+
]}
|
|
66
|
+
>
|
|
67
|
+
<Icons
|
|
68
|
+
icon="BLUETOOTH"
|
|
69
|
+
size={26}
|
|
70
|
+
background={theme.colors.gray[600]}
|
|
71
|
+
color={theme.colors.gray[300]}
|
|
72
|
+
/>
|
|
73
|
+
<View style={s.containerMain}>
|
|
74
|
+
<Text style={[s.title, isSelected && s.titleSelected]}>{device.nameDevice}</Text>
|
|
75
|
+
{!!device.macDevice && (
|
|
76
|
+
<Text style={[s.titleDescription, isSelected && s.descSelected]}>{device.macDevice}</Text>
|
|
77
|
+
)}
|
|
78
|
+
</View>
|
|
79
|
+
</TouchableOpacity>
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* EXPORTS
|
|
85
|
+
*/
|
|
86
|
+
export { DeviceRow };
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IMPORTS
|
|
3
3
|
*/
|
|
4
|
-
import React, { forwardRef } from "react";
|
|
5
|
-
import {
|
|
4
|
+
import React, { forwardRef, useCallback } from "react";
|
|
5
|
+
import { FlatList, type ListRenderItem } from "react-native";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
// icons
|
|
11
|
-
import { Icons } from "../../common/icons-svg";
|
|
7
|
+
import { DeviceRow } from "./components/list-device-render-item";
|
|
8
|
+
import ListDeviceEmpty from "./components/list-device-empty";
|
|
12
9
|
|
|
13
10
|
// typings
|
|
14
11
|
import type { IListDevices, IData } from "./interface";
|
|
15
12
|
import { asBaseComponent } from "../../@types/as-base-component";
|
|
16
13
|
|
|
17
|
-
// styles
|
|
18
|
-
import { styles as makeStyles } from "./styles";
|
|
19
|
-
import { theme } from "../../styles/theme/theme";
|
|
20
|
-
|
|
21
14
|
/**
|
|
22
15
|
* Componente ListDevices para a interação da ui.
|
|
23
16
|
*/
|
|
@@ -28,7 +21,7 @@ const ListDevices = forwardRef<any, IListDevices>(
|
|
|
28
21
|
): React.ReactElement => {
|
|
29
22
|
const isControlled = selectedId !== undefined;
|
|
30
23
|
const [internalSelected, setInternalSelected] = React.useState<number | null>(
|
|
31
|
-
defaultSelectedId
|
|
24
|
+
defaultSelectedId ?? null
|
|
32
25
|
);
|
|
33
26
|
|
|
34
27
|
const currentSelected = isControlled ? (selectedId ?? null) : internalSelected;
|
|
@@ -39,57 +32,32 @@ const ListDevices = forwardRef<any, IListDevices>(
|
|
|
39
32
|
onSelect?.(device);
|
|
40
33
|
};
|
|
41
34
|
|
|
42
|
-
|
|
35
|
+
const renderItem: ListRenderItem<IData> = useCallback(
|
|
36
|
+
({ item: device, index }) => {
|
|
37
|
+
const isLast = index === data?.length! - 1;
|
|
38
|
+
const isSelected = currentSelected === device.id;
|
|
39
|
+
return (
|
|
40
|
+
<DeviceRow
|
|
41
|
+
device={device}
|
|
42
|
+
isSelected={isSelected}
|
|
43
|
+
isLast={isLast}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
onPress={handlePress}
|
|
46
|
+
titleColor={titleColor}
|
|
47
|
+
textColorDescription={textColorDescription}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
[currentSelected, disabled, handlePress, titleColor, textColorDescription]
|
|
52
|
+
);
|
|
43
53
|
|
|
44
54
|
return (
|
|
45
55
|
<FlatList
|
|
56
|
+
ref={ref}
|
|
46
57
|
data={data}
|
|
47
58
|
keyExtractor={({ id }) => String(id)}
|
|
48
|
-
renderItem={
|
|
49
|
-
|
|
50
|
-
const isSelected = currentSelected === device.id;
|
|
51
|
-
|
|
52
|
-
const s = makeStyles({
|
|
53
|
-
titleColor,
|
|
54
|
-
textColorDescription,
|
|
55
|
-
disabled,
|
|
56
|
-
isSelected,
|
|
57
|
-
});
|
|
58
|
-
return (
|
|
59
|
-
<TouchableOpacity
|
|
60
|
-
ref={ref}
|
|
61
|
-
activeOpacity={0.7}
|
|
62
|
-
testID="list-devices"
|
|
63
|
-
key={device.id}
|
|
64
|
-
onPress={() => handlePress(device)}
|
|
65
|
-
disabled={disabled}
|
|
66
|
-
accessibilityRole="button"
|
|
67
|
-
accessibilityState={{ selected: isSelected, disabled }}
|
|
68
|
-
accessibilityLabel={`Dispositivo ${device.nameDevice}`}
|
|
69
|
-
style={[
|
|
70
|
-
s.containerIndicator,
|
|
71
|
-
!isLast && s.separator,
|
|
72
|
-
isSelected && s.containerIndicatorSelected,
|
|
73
|
-
]}
|
|
74
|
-
>
|
|
75
|
-
<Icons
|
|
76
|
-
icon={"BLUETOOTH"}
|
|
77
|
-
size={26}
|
|
78
|
-
background={theme.colors.gray[600]}
|
|
79
|
-
color={theme.colors.gray[300]}
|
|
80
|
-
/>
|
|
81
|
-
|
|
82
|
-
<View style={s.containerMain}>
|
|
83
|
-
<Text style={[s.title, isSelected && s.titleSelected]}>{device.nameDevice}</Text>
|
|
84
|
-
{!!device.macDevice && (
|
|
85
|
-
<Text style={[s.titleDescription, isSelected && s.descSelected]}>
|
|
86
|
-
{device.macDevice}
|
|
87
|
-
</Text>
|
|
88
|
-
)}
|
|
89
|
-
</View>
|
|
90
|
-
</TouchableOpacity>
|
|
91
|
-
);
|
|
92
|
-
}}
|
|
59
|
+
renderItem={renderItem}
|
|
60
|
+
ListEmptyComponent={ListDeviceEmpty}
|
|
93
61
|
/>
|
|
94
62
|
);
|
|
95
63
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
interface IData {
|
|
3
|
+
id: number;
|
|
4
|
+
macDevice: string;
|
|
5
|
+
nameDevice: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type Extra = { disabled?: boolean; isSelected?: boolean };
|
|
9
|
+
|
|
10
|
+
interface IListDevices {
|
|
11
|
+
/** dados que vão ser renderizados */
|
|
12
|
+
data?: IData[];
|
|
13
|
+
|
|
14
|
+
/** cor do texto */
|
|
15
|
+
titleColor?: string;
|
|
16
|
+
|
|
17
|
+
/** cor do titulo (não está sendo usada no componente atual, mantida por compat) */
|
|
18
|
+
titleNumberColor?: string;
|
|
19
|
+
|
|
20
|
+
/** cor do texto da descrição */
|
|
21
|
+
textColorDescription?: string;
|
|
22
|
+
|
|
23
|
+
/** (opcional) id selecionado - modo controlado */
|
|
24
|
+
selectedId?: number | null;
|
|
25
|
+
|
|
26
|
+
/** (opcional) seleção inicial - modo não-controlado */
|
|
27
|
+
defaultSelectedId?: number | null;
|
|
28
|
+
|
|
29
|
+
/** callback ao selecionar um item */
|
|
30
|
+
onSelect?: (device: IData) => void;
|
|
31
|
+
|
|
32
|
+
/** desabilita interação */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type { IData, IListDevices, Extra };
|