Skip to content

Commit

Permalink
feat: use assets image as play sound icon
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed May 21, 2022
1 parent cfb4d40 commit 44eb56e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Binary file added assets/speak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions src/eudic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export default function () {
function translate(fromLanguage: string, targetLanguage: string) {
requestYoudaoAPI(inputState!, fromLanguage, targetLanguage).then((res) => {
const resData: ITranslateResult = res.data;

console.log(
"fromLanguage 0: " + fromLanguage,
"targetLanguage: " + targetLanguage
);
// const result = JSON.stringify(resData);
// console.log(JSON.stringify(resData));
// Clipboard.copy(result);
Expand All @@ -92,12 +97,14 @@ export default function () {
setCurrentTargetLanguage(defaultLanguage1);
}

console.log("from===to: " + from + target);
translate(from, target);
return;
}

if (res.data.errorCode === "207") {
delayUpdateTargetLanguageTimer = setTimeout(() => {
console.log("207: " + from + to);
translate(from, to);
}, delayRequestTime);
return;
Expand All @@ -122,6 +129,9 @@ export default function () {
if (inputState) {
updateLoadingState(true);
clearTimeout(delayUpdateTargetLanguageTimer);
console.log(
"useEffect==>: " + "auto" + translateTargetLanguage.languageId
);
translate("auto", translateTargetLanguage.languageId);
return;
}
Expand Down Expand Up @@ -183,11 +193,19 @@ export default function () {
let wordAccessories = wordExamTypeAccessory.concat(pronunciationAccessory);
if (sectionType === SectionType.Translation) {
if (item.subtitle) {
wordExamTypeAccessory = [{ icon: Icon.Star }, { text: item.subtitle }];
wordExamTypeAccessory = [
{ icon: { source: Icon.Star, tintColor: Color.SecondaryText } },
{ text: item.subtitle },
];
}
if (item.phonetic) {
pronunciationAccessory = [
{ icon: Icon.SpeakerArrowUp },
{
icon: {
source: "speak.png",
tintColor: "gray", //"#696969",
},
},
{ text: item.phonetic },
];
}
Expand Down Expand Up @@ -229,6 +247,9 @@ export default function () {
onLanguageUpdate={(value) => {
setCurrentTargetLanguage(value);
updateTranslateTargetLanguage(value);
console.log(
"onLanguageUpdate: " + "auto" + value.languageId
);
translate("auto", value.languageId);
}}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/shared.func.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function reformatTranslateResult(
): ITranslateReformatResult[] {
const reformatData: ITranslateReformatResult[] = [];

// const result = JSON.stringify(data);
// console.log(JSON.stringify(data));
const result = JSON.stringify(data);
console.log(JSON.stringify(data));
// Clipboard.copy(result);

reformatData.push({
Expand Down

0 comments on commit 44eb56e

Please sign in to comment.