| 1
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
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
88
89
90
91
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244 |
2x
109x
109x
498x
266x
266x
266x
266x
4x
1x
266x
266x
266x
266x
94x
266x
266x
265x
265x
265x
266x
266x
265x
265x
265x
266x
266x
265x
265x
530x
266x
266x
265x
530x
266x
266x
2x
2x
| /**
* @author Xiuliang Li (xiuliang.li@samsung.com)
* @fileoverview This module manages Image item.
* @date 2017/06/9 (last modified date)
*
* Copyright 2017 by Samsung Electronics, Inc.,
*
* This software is the confidential and proprietary information
* of Samsung Electronics, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Samsung.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { is, Map, fromJS } from 'immutable'; // List and Map imparts the immutability feature to only the level-1 members of the List/Map
import ScrollText from './common/ScrollText';
import Image from './common/Image';
import TTS from './common/TTS';
import BreathMotion from './common/BreathMotion';
import PressFeedback from './common/PressFeedback';
import ProgressBar from './ProgressBar';
import { AnimationEffect, VOICE_GUIDE_DELAY } from './common/CommonDefine';
const ShadowImage = {
NORMAL: 'images/res_components/shadowbg/r_highlight_bg_focus_9patch.png',
HIGHCONTRAST: 'images/res_components/shadowbg/c_imageitem_highlight_bg_focus_9patch.png',
};
export default class ImageItem extends Component {
constructor(props) {
super(props);
// bind function
this.getBGComponent = this.getBGComponent.bind(this);
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
shouldComponentUpdate(nextProps, nextState) {
return (JSON.stringify(nextProps) !== JSON.stringify(this.props));
}
componentDidUpdate(prevProps, prevState) {
}
componentWillUnmount() {
}
/**
* get Shadow Component
* @name getShadowComponent
* @method
* @memberof todo, make a component for background.
*/
getBGComponent() {
const { OSD, highContrast, focus } = this.props;
const shadowStyle = {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
borderStyle: 'solid',
margin: '-11px -6px -13px -6px',
borderWidth: '20px 14px',
borderImage: highContrast ?
`url(${ShadowImage.HIGHCONTRAST}) 20 14 fill stretch` :
`url(${ShadowImage.NORMAL}) 20 14 fill stretch`,
};
const normalStyle = {
// todo, normal bg strech
};
return (<div style={focus ? shadowStyle : normalStyle} />);
}
/**
* voice guide play
* @name playTTS
* @method
* @param
* @memberof
*/
playTTS() {
if (this.props.ttsEnable && this.props.focus) {
this.TTSnode.playTTS();
}
}
render() {
const { enlarge, highContrast, scaleFactor, ttsEnable, focus, OSD, enter, enterCB } = this.props;
const bgComponent = this.getBGComponent();
let TTSComponent = null;
if (ttsEnable) {
TTSComponent = <TTS ref={(TTSnode) => { this.TTSnode = TTSnode; }} ttsEnable={ttsEnable} ttsText={OSD.ttsText} />;
}
let idx;
let len;
const imageComponentList = [];
if (typeof OSD.image !== 'undefined') {
len = OSD.image.length;
for (idx = 0; idx < len; idx++) {
imageComponentList.push(<Image key={`image${idx}`} OSD={OSD.image[idx]} />);
}
}
const iconComponentList = [];
if (typeof OSD.icon !== 'undefined') {
len = OSD.icon.length;
for (idx = 0; idx < len; idx++) {
iconComponentList.push(<Image key={`icon${idx}`} OSD={OSD.icon[idx]} />);
}
}
const textComponentList = [];
if (typeof OSD.text !== 'undefined') {
len = OSD.text.length;
for (idx = 0; idx < len; idx++) {
textComponentList.push(<ScrollText
key={`text${idx}`}
top={OSD.text[idx].t}
left={OSD.text[idx].l}
width={OSD.text[idx].w}
height={OSD.text[idx].h}
lineHeight={`${OSD.text[idx].h}px`}
scroll={focus && !highContrast && !enlarge}// In a High Contrast || enlarge mode, do not support sliding text feature.
fontSize={enlarge ? OSD.text[idx].fontSizel : OSD.text[idx].fontSize}
fontFamily={OSD.text[idx].fontType}
textGap={OSD.text[idx].scrollGap}
textAlign={OSD.text[idx].textAlign}
verticalAlign={OSD.text[idx].verticalAlign}
color={(focus || enlarge) ? '#000000' : '#262626'}
>
{OSD.text[idx].text}
</ScrollText>);
}
}
let progressComponent = null;
if (typeof OSD.progress !== 'undefined') {
progressComponent = (<ProgressBar
ref={(progress) => { this.progress = progress; }}
top={OSD.progress.t}
left={OSD.progress.l}
progressRate={OSD.progress.rate}
bgWidth={OSD.progress.w}
bgHeight={OSD.progress.h}
highContarstValue={highContrast}
/>);
}
const layoutStyle = {
position: 'relative',
zIndex: focus ? 2 : 1,
left: OSD.layout.l,
top: OSD.layout.t,
width: OSD.layout.w,
height: OSD.layout.h,
borderRadius: '3px',
overflow: 'visible',
backgroundColor: focus ? 'hsla(0,0%,100%,1)' : 'hsla(0,0%,100%,0.5)',
transform: `scale(${focus ? scaleFactor : 1.0}) translateZ(10px)`,
transition: focus ? `all 1.1s ${AnimationEffect.Elastic}` : `all 0.3s ${AnimationEffect.Basic}`,
};
return (
<BreathMotion doBreath={focus}>
<PressFeedback start={enter} animationDoneCB={enterCB}>
<div style={layoutStyle}>
{bgComponent}
{TTSComponent}
{imageComponentList}
{iconComponentList}
{textComponentList}
{progressComponent}
</div>
</PressFeedback>
</BreathMotion>
);
}
}
ImageItem.defaultProps = {
enter: false, // enter key flag
enterCB: null, // enter key callback function
enlarge: false,
highContrast: false,
scaleFactor: 1.2,
ttsEnable: false,
};
ImageItem.propTypes = {
focus: PropTypes.bool.isRequired, // The item is focus or not
enter: PropTypes.bool, // PressFeedBack animation flag
enterCB: PropTypes.func, // Animation done callback
enlarge: PropTypes.bool, // enlarge title and SubTitle font size flag
highContrast: PropTypes.bool, // Background image, false use r_highlight_bg_focus_9patch.png ,true use c_imageitem_highlight_bg_focus_9patch.png
scaleFactor: PropTypes.number, // focus scale size.
ttsEnable: PropTypes.bool,
OSD: PropTypes.shape({ // UI content
layout: PropTypes.shape({
l: PropTypes.number,
t: PropTypes.number,
w: PropTypes.number,
h: PropTypes.number,
}),
image: PropTypes.array,
icon: PropTypes.array,
text: PropTypes.arrayOf(PropTypes.shape({
l: PropTypes.number,
t: PropTypes.number,
w: PropTypes.number,
h: PropTypes.number,
fontSize: PropTypes.number,
fontSizel: PropTypes.number,
fontType: PropTypes.string,
textAlign: PropTypes.oneOf(['left', 'center', 'right']),
verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
scrollGap: PropTypes.number,
text: PropTypes.string,
})),
ttsText: PropTypes.string,
progress: PropTypes.shape({
l: PropTypes.number,
t: PropTypes.number,
w: PropTypes.number,
h: PropTypes.number,
rate: PropTypes.number,
}),
}).isRequired,
};
|