Skip to content

Commit

Permalink
feat: frontend implement sounds on questions & answer
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNumericite committed Jul 6, 2021
1 parent 73fa9a8 commit f7c0155
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tumeplay-app/src/screens/QuizzScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {EventRegister} from 'react-native-event-listeners';
import UserService from '../services/User';
import Tracking from '../services/Tracking';
import AnswerScreen from './components/quizz/AnswerScreen';
import TextWithSound from './components/global/TextWithSound';
import NextButton from './components/quizz/NextButton';
import AnswerButton from './components/quizz/AnswerButton';
import QuizService from '../services/Quiz';
Expand Down Expand Up @@ -174,9 +175,7 @@ export default function QuizzScreen(props) {
alignSelf: 'center',
height: '20%',
}}>
<Text style={Styles.questionText}>
{_currentQuestion.text_question}
</Text>
<TextWithSound sound={process.env.REACT_APP_API_URL + _currentQuestion.sound_question.url} style={Styles.questionText} useUrl>{_currentQuestion.text_question}</TextWithSound>
</View>

<View style={{paddingBottom: 50, height: '52%'}}>
Expand All @@ -189,6 +188,7 @@ export default function QuizzScreen(props) {
question={_currentQuestion}
lastTokenAmount={lastTokenAmount}
setFeedback={setFeedback}
sound={_currentQuestion.sound_answer.url}
/>
)}
</View>
Expand Down
4 changes: 3 additions & 1 deletion tumeplay-app/src/screens/components/global/ExpandableText.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export default function ExpandableText(props) {
const isMounted = useIsMounted();
const _text = useRef();

const soundIconStyle = props.soundStyle || {position: 'absolute', right: 15, top: 20}

const [play, setPlay] = useState(false);

const soundPicture = require('../../../assets/pictures/sound.png');
Expand Down Expand Up @@ -249,7 +251,7 @@ export default function ExpandableText(props) {
togglePlay(e);
return false;
}}
style={{position: 'absolute', right: 15, top: 20}}>
style={soundIconStyle}>
<Image
style={{
marginLeft: 10,
Expand Down
6 changes: 3 additions & 3 deletions tumeplay-app/src/screens/components/global/TextWithSound.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import CustomTouchableOpacity from './CustomTouchableOpacity';

TextWithSound.propTypes = {
sound: PropTypes.string,
useUrl: PropTypes.bool,
children: PropTypes.object,
style: PropTypes.object,
};
export default function TextWithSound(props) {
const [play, setPlay] = useState(false);
const targetSound = props.sound
? require('../../../assets/sounds/' + props.sound)
: false;
const targetSound = props.sound ? ( props.useUrl ? props.sound : require('../../../assets/sounds/' + props.sound) ) : false;

const soundPicture = require('../../../assets/pictures/sound.png');

function onPlayStart() {
Expand Down
6 changes: 6 additions & 0 deletions tumeplay-app/src/screens/components/quizz/AnswerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ export default function AnswerScreen(props) {
onReadMore={() => {
Tracking.knowMoreTriggered('question', content.id);
}}
sound={props.sound}
soundStyle={{
position: 'absolute',
bottom: '10px',
left: '0'
}}
/>
<CommentLikesView
onPressComment={_toggleCommentModal}
Expand Down
6 changes: 6 additions & 0 deletions tumeplay-app/src/services/api/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export const GET_QUESTIONS = gql`
image {
url
}
sound_question {
url
}
sound_answer {
url
}
}
}
`;

0 comments on commit f7c0155

Please sign in to comment.