@nakamura-123/pages 1.4.0 → 1.4.2

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.
Files changed (48) hide show
  1. package/dist/component/Article/ArticleContentView.d.ts +5 -1
  2. package/dist/component/Article/ArticleContentView.js +218 -37
  3. package/dist/component/Article/ArticleImage.d.ts +9 -0
  4. package/dist/component/Article/ArticleImage.js +46 -0
  5. package/dist/component/Article/ArticleSectionPager.d.ts +17 -0
  6. package/dist/component/Article/ArticleSectionPager.js +193 -0
  7. package/dist/component/Article/ArticleTable.d.ts +10 -0
  8. package/dist/component/Article/ArticleTable.js +74 -0
  9. package/dist/component/Article/ChipStrip.d.ts +10 -0
  10. package/dist/component/Article/ChipStrip.js +82 -0
  11. package/dist/component/Article/Cloze.d.ts +31 -0
  12. package/dist/component/Article/Cloze.js +338 -0
  13. package/dist/component/Article/FramesFigure.d.ts +27 -0
  14. package/dist/component/Article/FramesFigure.js +438 -0
  15. package/dist/component/Article/RefLink.d.ts +42 -0
  16. package/dist/component/Article/RefLink.js +184 -0
  17. package/dist/component/Rating/RatingBar.d.ts +9 -0
  18. package/dist/component/Rating/RatingBar.js +358 -0
  19. package/dist/component/Rating/keyboardScroll.d.ts +7 -0
  20. package/dist/component/Rating/keyboardScroll.js +37 -0
  21. package/dist/component/Result/QuizFlatList.js +11 -10
  22. package/dist/component/Result/ResultActions.js +152 -59
  23. package/dist/component/Result/ResultHero.js +19 -18
  24. package/dist/component/SettingBtns/LanguageModal.js +1 -0
  25. package/dist/functions/articleContentFnc.d.ts +49 -1
  26. package/dist/functions/articleContentFnc.js +191 -2
  27. package/dist/functions/questionFormatD.d.ts +1 -0
  28. package/dist/functions/questionFormatD.js +14 -13
  29. package/dist/functions/ratingFnc.d.ts +4 -0
  30. package/dist/functions/ratingFnc.js +30 -0
  31. package/dist/functions/retryQuizFnc.d.ts +1 -0
  32. package/dist/functions/retryQuizFnc.js +13 -0
  33. package/dist/hooks/resultHook.d.ts +3 -1
  34. package/dist/hooks/resultHook.js +29 -6
  35. package/dist/page/ArticleDetail.js +58 -15
  36. package/dist/page/ImgZoom.d.ts +4 -3
  37. package/dist/page/ImgZoom.js +16 -2
  38. package/dist/page/QuizPage.js +23 -11
  39. package/dist/page/ReportPage.js +3 -2
  40. package/dist/page/ResultPage.js +2 -1
  41. package/dist/quiz/QuizContentsDrill.js +26 -16
  42. package/dist/quiz/common/MyTextqqyy.d.ts +4 -0
  43. package/dist/quiz/common/MyTextqqyy.js +14 -4
  44. package/dist/quiz/explain/ExplainLogic.d.ts +1 -0
  45. package/dist/quiz/explain/ExplainLogic.js +3 -2
  46. package/dist/quiz/explain/NormalExplain.js +3 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatQuestions = void 0;
3
+ exports.shuffleMultiRow = exports.formatQuestions = void 0;
4
4
  const lib_1 = require("@nakamura-123/lib");
5
5
  // OO_メインの出力
6
6
  const formatQuestions = (questions) => {
@@ -71,16 +71,17 @@ const getMultiChoice = (choices) => {
71
71
  num: index + 1,
72
72
  isCorrect: index === 0,
73
73
  })));
74
- // 選択肢をシャッフル
75
- const shuffledChoices = formattedChoices.map((array) => {
76
- // 「○適当」のように記号の後に文字が続く選択肢もあるため、先頭の記号で判定する
77
- const markOrder = (choice) => MARU_BATSU_ORDER.findIndex((mark) => choice.startsWith(mark));
78
- const isMaruBatsu = array.length >= 2 && array.every(({ choice }) => markOrder(choice) !== -1);
79
- // ○△×の問題は記号の順に固定する
80
- if (isMaruBatsu) {
81
- return [...array].sort((a, b) => markOrder(a.choice) - markOrder(b.choice));
82
- }
83
- return lib_1.utilFnc.shuffleList(array);
84
- });
85
- return shuffledChoices;
74
+ return formattedChoices.map(exports.shuffleMultiRow);
75
+ };
76
+ // multiの1行分の選択肢をシャッフルする。渡した配列は書き換えない(やり直しではstoreの凍結された配列が来る)
77
+ const shuffleMultiRow = (array) => {
78
+ // 「○適当」のように記号の後に文字が続く選択肢もあるため、先頭の記号で判定する
79
+ const markOrder = (choice) => MARU_BATSU_ORDER.findIndex((mark) => choice.startsWith(mark));
80
+ const isMaruBatsu = array.length >= 2 && array.every(({ choice }) => markOrder(choice) !== -1);
81
+ // ○△×の問題は記号の順に固定する
82
+ if (isMaruBatsu) {
83
+ return [...array].sort((a, b) => markOrder(a.choice) - markOrder(b.choice));
84
+ }
85
+ return lib_1.utilFnc.shuffleList([...array]);
86
86
  };
87
+ exports.shuffleMultiRow = shuffleMultiRow;
@@ -0,0 +1,4 @@
1
+ export declare const explainTarget: (yearId: number | string, num: number | string) => string;
2
+ export declare const lessonTarget: (articleId: string, sectionId?: string) => string;
3
+ export declare const ratingVer: (text: string) => string;
4
+ export declare const makeDeviceId: () => string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeDeviceId = exports.ratingVer = exports.lessonTarget = exports.explainTarget = void 0;
4
+ // 評価の的の名前。Firebaseのルールで [A-Za-z0-9_-] の100字までに絞ってあるので、ほかの字は _ にする
5
+ const safe = (s) => s.replace(/[^A-Za-z0-9_-]/g, "_");
6
+ // 問題の解説(問題ごと。選択肢ごとにはしない)
7
+ const explainTarget = (yearId, num) => safe(`q-${yearId}-${num}`).slice(0, 100);
8
+ exports.explainTarget = explainTarget;
9
+ // LESSON。見出しのページごと。見出しで分かれていない記事は記事ごと
10
+ const lessonTarget = (articleId, sectionId) => safe(sectionId ? `l-${articleId}-${sectionId}` : `l-${articleId}`).slice(0, 100);
11
+ exports.lessonTarget = lessonTarget;
12
+ // 本文の印(FNV-1a 32bitの16進8字)。書き直した後の評価を前の評価と分けて数えるために送る
13
+ const ratingVer = (text) => {
14
+ let h = 0x811c9dc5;
15
+ for (let i = 0; i < text.length; i++) {
16
+ h ^= text.charCodeAt(i);
17
+ h = Math.imul(h, 0x01000193);
18
+ }
19
+ return (h >>> 0).toString(16).padStart(8, "0");
20
+ };
21
+ exports.ratingVer = ratingVer;
22
+ // 1台1票にするための端末の番号。名前やメールとは結び付かない乱数(ルールで20〜40字の英数字)
23
+ const makeDeviceId = () => {
24
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
25
+ let id = "";
26
+ for (let i = 0; i < 24; i++)
27
+ id += chars[Math.floor(Math.random() * chars.length)];
28
+ return id;
29
+ };
30
+ exports.makeDeviceId = makeDeviceId;
@@ -0,0 +1 @@
1
+ export declare const toRetryQuizList: (quizList: any[], onlyWrong: boolean) => any[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toRetryQuizList = void 0;
4
+ const lib_1 = require("@nakamura-123/lib");
5
+ const questionFormatD_1 = require("./questionFormatD");
6
+ // 結果画面からのやり直しで出す問題を作る。問題の順は保ち、答えの記録を消す。
7
+ // タグは今の段階から動く(文法は解き始めの段階を今の段階に置き直す)。
8
+ // 選択肢は、位置で答えを覚えないように混ぜ直す。
9
+ // shuffleListは渡した配列を書き換え、storeの配列は凍結されているので写しを渡す
10
+ const toRetryQuizList = (quizList, onlyWrong) => quizList
11
+ .filter((q) => !onlyWrong || q.isCorrected !== true)
12
+ .map((q) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, q), { isCorrected: undefined }), ("selectedIndexes" in q ? { selectedIndexes: [] } : {})), (q.choices ? { choices: lib_1.utilFnc.shuffleList([...q.choices]) } : {})), (q.multiSel ? { multiSel: q.multiSel.map(questionFormatD_1.shuffleMultiRow) } : {})), (q.system === "grammar" ? { startTag: q.tag } : {}))));
13
+ exports.toRetryQuizList = toRetryQuizList;
@@ -1,9 +1,11 @@
1
1
  import { Nav, QSelected } from "@nakamura-123/types";
2
+ export declare const useFrozenOnRetry: <T>(value: T) => T;
2
3
  export declare const useWrongCount: () => number;
3
4
  export declare const useRetryQuizAction: (navigation: Nav.NavigationProp<"Result">) => (onlyWrong: boolean) => void;
4
5
  export declare const useMakeNext: () => (via: "lesson" | "list", type: "unit" | "year", category: number, key: number) => QSelected.NextItem | undefined;
5
6
  export type NextInResult = {
6
- kind: "article" | "unit";
7
+ kind: "article" | "unit" | "year";
8
+ title: string;
7
9
  go: () => void;
8
10
  };
9
11
  export declare const useNextInResult: (navigation: Nav.NavigationProp<"Result">) => NextInResult | null;
@@ -1,24 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useNextInResult = exports.useMakeNext = exports.useRetryQuizAction = exports.useWrongCount = void 0;
3
+ exports.useNextInResult = exports.useMakeNext = exports.useRetryQuizAction = exports.useWrongCount = exports.useFrozenOnRetry = void 0;
4
+ const react_1 = require("react");
4
5
  const react_redux_1 = require("react-redux");
5
6
  const stores_1 = require("@nakamura-123/stores");
6
7
  const nextItemFnc_1 = require("../functions/nextItemFnc");
8
+ const retryQuizFnc_1 = require("../functions/retryQuizFnc");
9
+ // やり直すとstoreは先に次の出題の状態(点数0など)へ変わるが、結果画面は切り替えのアニメーションが
10
+ // 終わるまで見えている。その間は直前の結果を見せ続ける。
11
+ // 結果画面のmodeはcheckかresultで、quizになるのはやり直しで離れるときだけ
12
+ const useFrozenOnRetry = (value) => {
13
+ const isLeaving = (0, react_redux_1.useSelector)((state) => state.quiz.currentInfo.state.mode === "quiz");
14
+ const last = (0, react_1.useRef)(value);
15
+ if (!isLeaving)
16
+ last.current = value;
17
+ return last.current;
18
+ };
19
+ exports.useFrozenOnRetry = useFrozenOnRetry;
7
20
  // ○でなかった問題(×と、答えずに進めた問題)の数
8
21
  const useWrongCount = () => (0, react_redux_1.useSelector)((state) => state.quiz.quizList.filter((q) => q.isCorrected !== true).length);
9
22
  exports.useWrongCount = useWrongCount;
10
23
  // 結果画面から、同じ問題(または×だけ)を同じ順で1問目から解き直す。
11
- // 答えの記録だけを消し、タグは今の段階から動く(文法は解き始めの段階を今の段階に置き直す)。
12
24
  // 復習なので、試験の記録・履歴には残さない。その日の問題数には数える(isRetry)
13
25
  const useRetryQuizAction = (navigation) => {
14
26
  const dispatch = (0, react_redux_1.useDispatch)();
15
27
  const quizList = (0, react_redux_1.useSelector)((state) => state.quiz.quizList);
16
28
  const subject = (0, react_redux_1.useSelector)((state) => state.quiz.selected.subject);
17
29
  return (onlyWrong) => {
18
- const targets = quizList.filter((q) => !onlyWrong || q.isCorrected !== true);
19
- if (targets.length === 0)
30
+ const reset = (0, retryQuizFnc_1.toRetryQuizList)(quizList, onlyWrong);
31
+ if (reset.length === 0)
20
32
  return;
21
- const reset = targets.map((q) => (Object.assign(Object.assign(Object.assign(Object.assign({}, q), { isCorrected: undefined }), ("selectedIndexes" in q ? { selectedIndexes: [] } : {})), (q.system === "grammar" ? { startTag: q.tag } : {}))));
22
33
  dispatch(stores_1.quizAction.resetCurrentInfo());
23
34
  dispatch(stores_1.quizAction.markRetry());
24
35
  dispatch(stores_1.saveStorage.deleteQuizInStorage(subject));
@@ -41,8 +52,10 @@ const useMakeNext = () => {
41
52
  exports.useMakeNext = useMakeNext;
42
53
  // 結果画面の「次へ」。始めるときに決めておいた行き先(selected.next)へ進む。無ければnull
43
54
  const useNextInResult = (navigation) => {
55
+ var _a;
44
56
  const dispatch = (0, react_redux_1.useDispatch)();
45
57
  const selected = (0, react_redux_1.useSelector)((state) => state.quiz.selected);
58
+ const unitList = (0, react_redux_1.useSelector)((state) => state.app.unitList);
46
59
  const makeNext = (0, exports.useMakeNext)();
47
60
  if (selected.type !== "unit" && selected.type !== "year")
48
61
  return null;
@@ -52,6 +65,7 @@ const useNextInResult = (navigation) => {
52
65
  if (next.type === "article")
53
66
  return {
54
67
  kind: "article",
68
+ title: next.title,
55
69
  go: () => navigation.replace("ArticleDetail", {
56
70
  subject: selected.subject,
57
71
  chapterKey: next.chapterKey,
@@ -61,8 +75,17 @@ const useNextInResult = (navigation) => {
61
75
  system: selected.system,
62
76
  }),
63
77
  };
78
+ // lesson.title は「章の名前 単元名」(lessonTitleOf)。単元別は、狭い札では章の名前(「1章」「1.」)を外す(2026-11-09、本人)。
79
+ // 試験別は「2025上 第11問~第20問」のように試験の名前が要るので、そのまま
80
+ const label = selected.type === "unit"
81
+ ? (_a = unitList.find((chapter) => chapter.key === next.category)) === null || _a === void 0 ? void 0 : _a.label
82
+ : undefined;
83
+ const title = label && next.lesson.title.startsWith(`${label} `)
84
+ ? next.lesson.title.slice(label.length + 1)
85
+ : next.lesson.title;
64
86
  return {
65
- kind: "unit",
87
+ kind: selected.type,
88
+ title,
66
89
  go: () => {
67
90
  // 次の単元に進むときも、同じ並びでその次を決め直す
68
91
  const following = makeNext(next.via, selected.type, next.category, next.lesson.key);
@@ -33,13 +33,20 @@ const lib_1 = require("@nakamura-123/lib");
33
33
  const common_1 = require("@nakamura-123/common");
34
34
  const stores_1 = require("@nakamura-123/stores");
35
35
  const ArticleContentView_1 = __importDefault(require("../component/Article/ArticleContentView"));
36
+ const ArticleSectionPager_1 = __importDefault(require("../component/Article/ArticleSectionPager"));
37
+ const RefLink_1 = require("../component/Article/RefLink");
36
38
  const articleContentFnc_1 = require("../functions/articleContentFnc");
37
39
  const articleListFnc_1 = require("../functions/articleListFnc");
40
+ const ratingFnc_1 = require("../functions/ratingFnc");
41
+ const RatingBar_1 = __importDefault(require("../component/Rating/RatingBar"));
42
+ const keyboardScroll_1 = require("../component/Rating/keyboardScroll");
38
43
  const resultHook_1 = require("../hooks/resultHook");
39
44
  const ArticleDetail = ({ navigation, route }) => {
40
- const { subject, chapterKey, articleId, title, tag, system, isGuide } = route.params;
45
+ const { subject, chapterKey, articleId, title, tag, system, isGuide, sectionId, backTo, restorePosition, } = route.params;
41
46
  const dispatch = (0, react_redux_1.useDispatch)();
42
47
  const { t } = (0, common_1.useDrillTranslation)();
48
+ const scrollRef = (0, react_1.useRef)(null);
49
+ const { scrollToInput, onScroll } = (0, keyboardScroll_1.useKeyboardScroll)(scrollRef);
43
50
  const isRead = (0, react_redux_1.useSelector)((state) => { var _a; return !!((_a = state.setting.articles[articleId]) === null || _a === void 0 ? void 0 : _a.isRead); });
44
51
  const flagColor = (0, react_redux_1.useSelector)((state) => { var _a, _b; return (_b = (_a = state.setting.articles[articleId]) === null || _a === void 0 ? void 0 : _a.flag) !== null && _b !== void 0 ? _b : null; });
45
52
  const rawContent = (0, react_redux_1.useSelector)((state) => state.app.articleContents[articleId]);
@@ -107,16 +114,14 @@ const ArticleDetail = ({ navigation, route }) => {
107
114
  system,
108
115
  });
109
116
  };
110
- return (<react_native_1.ScrollView style={styles.container} contentContainerStyle={styles.content}>
111
- {rawContent ? (<ArticleContentView_1.default content={(0, articleContentFnc_1.parseArticleContent)(rawContent)} articleId={articleId}/>) : (<react_native_1.View style={styles.placeholder}>
112
- <common_1.MyText fsize="lg" weight={700} style={styles.placeholderTitle}>
113
- {title}
114
- </common_1.MyText>
115
- <common_1.MyText fsize="sm" color="ltBlack">
116
- {t("article.preparing")}
117
- </common_1.MyText>
118
- </react_native_1.View>)}
119
-
117
+ const content = (0, react_1.useMemo)(() => (rawContent ? (0, articleContentFnc_1.parseArticleContent)(rawContent) : null), [rawContent]);
118
+ const sections = (0, react_1.useMemo)(() => (content ? (0, articleContentFnc_1.splitArticleSections)(content.blocks) : null), [content]);
119
+ // typeIndex: 報告の種類を選んだ形で開く(評価で「間違っていそう」を押したときは 0「表示中の問題・解説の誤り」)
120
+ const openReport = (typeIndex) => navigation.navigate("Report", {
121
+ articleInfo: { subject, chapterKey, articleId, title, rawContent },
122
+ typeIndex,
123
+ });
124
+ const footer = (<>
120
125
  {(nextItem === null || nextItem === void 0 ? void 0 : nextItem.type) === "unit" && (<common_1.PressAnimatedWrap onPress={handleStartQuiz} style={styles.ctaButton}>
121
126
  <common_1.MyText fsize="sm" weight={700}>
122
127
  {t("article.startQuiz")}
@@ -143,15 +148,46 @@ const ArticleDetail = ({ navigation, route }) => {
143
148
  </common_1.PressAnimatedWrap>
144
149
  </react_native_1.View>
145
150
 
146
- <common_1.PressAnimatedWrap onPress={() => navigation.navigate("Report", {
147
- articleInfo: { subject, chapterKey, articleId, title, rawContent },
148
- })} style={styles.reportLink}>
151
+ <common_1.PressAnimatedWrap onPress={() => openReport()} style={styles.reportLink}>
149
152
  <common_1.Icon5 name="envelope" size={14} color="ltBlack" style={styles.bottomButtonIcon}/>
150
153
  <common_1.MyText fsize="xs" color="ltBlack">
151
154
  {t("article.report")}
152
155
  </common_1.MyText>
153
156
  </common_1.PressAnimatedWrap>
154
- </react_native_1.ScrollView>);
157
+ </>);
158
+ // 右下。LESSONの中の図の札で開いた図を開き直すボタンと、解説の札から開いたときの「解説に戻る」
159
+ const corner = (<react_native_1.View style={styles.corner} pointerEvents="box-none">
160
+ <RefLink_1.ReopenButton />
161
+ {backTo === "explain" && (<RefLink_1.CornerButton icon="arrow-left" label={t("article.backToExplain")} tone="back" onPress={() => navigation.goBack()}/>)}
162
+ </react_native_1.View>);
163
+ if (content && sections) {
164
+ return (<RefLink_1.RefLinkProvider navigation={navigation} origin="lesson">
165
+ <ArticleSectionPager_1.default title={content.title} sections={sections} articleId={articleId} navigation={navigation} footer={footer} startId={sectionId} restorePosition={restorePosition} onReportWrong={() => openReport(0)}/>
166
+ {corner}
167
+ </RefLink_1.RefLinkProvider>);
168
+ }
169
+ return (<RefLink_1.RefLinkProvider navigation={navigation} origin="lesson">
170
+ <keyboardScroll_1.KeyboardScrollContext.Provider value={scrollToInput}>
171
+ <react_native_1.ScrollView ref={scrollRef} onScroll={onScroll} scrollEventThrottle={16} style={styles.container} contentContainerStyle={styles.content}
172
+ // 評価の書く欄(記事の終わり)がキーボードに隠れないよう、iOSでキーボードの分の余白を足す
173
+ automaticallyAdjustKeyboardInsets keyboardShouldPersistTaps="handled">
174
+ {content ? (<>
175
+ <ArticleContentView_1.default content={content} articleId={articleId} navigation={navigation}/>
176
+ {/* 見出しで分かれていない記事は記事ごとに評価する */}
177
+ <RatingBar_1.default target={(0, ratingFnc_1.lessonTarget)(articleId)} ver={(0, ratingFnc_1.ratingVer)(rawContent !== null && rawContent !== void 0 ? rawContent : "")} kind="lesson" onReport={() => openReport(0)}/>
178
+ </>) : (<react_native_1.View style={styles.placeholder}>
179
+ <common_1.MyText fsize="lg" weight={700} style={styles.placeholderTitle}>
180
+ {title}
181
+ </common_1.MyText>
182
+ <common_1.MyText fsize="sm" color="ltBlack">
183
+ {t("article.preparing")}
184
+ </common_1.MyText>
185
+ </react_native_1.View>)}
186
+ {footer}
187
+ </react_native_1.ScrollView>
188
+ </keyboardScroll_1.KeyboardScrollContext.Provider>
189
+ {corner}
190
+ </RefLink_1.RefLinkProvider>);
155
191
  };
156
192
  const styles = react_native_1.StyleSheet.create({
157
193
  container: {
@@ -200,6 +236,13 @@ const styles = react_native_1.StyleSheet.create({
200
236
  bottomButtonIcon: {
201
237
  marginRight: 8,
202
238
  },
239
+ corner: {
240
+ position: "absolute",
241
+ right: 15,
242
+ bottom: 30,
243
+ gap: 10,
244
+ alignItems: "flex-end",
245
+ },
203
246
  reportLink: {
204
247
  marginTop: 16,
205
248
  flexDirection: "row",
@@ -1,9 +1,10 @@
1
+ import { Nav } from "@nakamura-123/types";
2
+ import { StackNavigationProp } from "@react-navigation/stack";
1
3
  import React from "react";
2
4
  type ImageZoomScreenProps = {
5
+ navigation: StackNavigationProp<Nav.RootStackParamList>;
3
6
  route: {
4
- params: {
5
- path: number;
6
- };
7
+ params: Nav.RootStackParamList["ImgZoom"];
7
8
  };
8
9
  };
9
10
  declare const ImageZoomScreen: React.FC<ImageZoomScreenProps>;
@@ -4,16 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lib_1 = require("@nakamura-123/lib");
7
+ const common_1 = require("@nakamura-123/common");
7
8
  const expo_image_1 = require("expo-image");
8
9
  const react_1 = __importDefault(require("react"));
9
10
  const react_native_1 = require("react-native");
10
11
  const react_native_image_zoom_viewer_1 = __importDefault(require("react-native-image-zoom-viewer")); // 拡大ライブラリ
11
- const ImageZoomScreen = ({ route }) => {
12
- const { path } = route.params;
12
+ const RefLink_1 = require("../component/Article/RefLink");
13
+ const ImageZoomScreen = ({ navigation, route, }) => {
14
+ const { path, backTo } = route.params;
15
+ const { t } = (0, common_1.useDrillTranslation)();
13
16
  // 画像データをライブラリの形式に変換
14
17
  const images = [{ url: "", props: { source: path } }];
15
18
  return (<react_native_1.View style={styles.container}>
16
19
  <react_native_image_zoom_viewer_1.default imageUrls={images} backgroundColor={lib_1.colors.beige} renderImage={renderImage}/>
20
+ {/* 解説・LESSONの図の札から開いたときだけ。図を押して開いたときは今までどおり出さない */}
21
+ {backTo && (<react_native_1.View style={styles.corner} pointerEvents="box-none">
22
+ <RefLink_1.CornerButton icon="arrow-left" label={t(backTo === "explain"
23
+ ? "article.backToExplain"
24
+ : "article.backToLesson")} tone="back" onPress={() => navigation.goBack()}/>
25
+ </react_native_1.View>)}
17
26
  </react_native_1.View>);
18
27
  };
19
28
  // Android標準のImage(Fresco)は長辺2048px超を縮小デコードし、拡大時に文字が潰れるため
@@ -22,5 +31,10 @@ const styles = react_native_1.StyleSheet.create({
22
31
  container: {
23
32
  flex: 1,
24
33
  },
34
+ corner: {
35
+ position: "absolute",
36
+ right: 15,
37
+ bottom: 30,
38
+ },
25
39
  });
26
40
  exports.default = ImageZoomScreen;
@@ -13,6 +13,7 @@ const Guide_1 = __importDefault(require("../component/Guide"));
13
13
  const components_1 = require("../engine/components");
14
14
  const basicHook_1 = require("../hooks/basicHook");
15
15
  const KeyboardCloseBar_1 = __importDefault(require("../component/KeyboardCloseBar"));
16
+ const RefLink_1 = require("../component/Article/RefLink");
16
17
  const QuizPage = ({ navigation }) => {
17
18
  // スワイプの動作処理
18
19
  const mode = (0, quizHook_1.useGetMode)();
@@ -33,17 +34,24 @@ const QuizPage = ({ navigation }) => {
33
34
  const guideName = turn === 1 ? "quizPageSwipe1" : "quizPageSwipe2";
34
35
  // クイズ終了確認フック
35
36
  (0, ExitQuizHook_1.useConfirmExit)(navigation);
36
- return (<react_native_1.View style={styles.wrapper}>
37
- <QuizContents navigation={navigation} guideName={guideName} showSwipe1Guide={showSwipe1Guide} showSwipe2Guide={showSwipe2Guide} isCheck={isCheck} isResult={isResult} isNotInput={isNotInput} isNotQuiz={isNotQuiz} isInputQuizMode={isInputQuizMode} turn={turn}/>
38
- {/* 下に固定しておくボタンを設置 */}
39
- {isNotQuiz && (<react_native_1.View style={styles.fixedBottom}>
40
- <Guide_1.default name="quizPageTag" isVisible={showTagGuide}>
41
- <Check_1.default navigation={navigation}/>
42
- </Guide_1.default>
43
- </react_native_1.View>)}
44
- {/* 記述解答欄のキーボードを閉じるバー。ScrollViewの外でないと画面下端に固定できない */}
45
- <KeyboardCloseBar_1.default />
46
- </react_native_1.View>);
37
+ return (
38
+ // 解説の札(LESSON・図)から開いたものは、問題が変わったら右下のボタンから消す
39
+ <RefLink_1.RefLinkProvider navigation={navigation} origin="explain" resetKey={turn}>
40
+ <react_native_1.View style={styles.wrapper}>
41
+ <QuizContents navigation={navigation} guideName={guideName} showSwipe1Guide={showSwipe1Guide} showSwipe2Guide={showSwipe2Guide} isCheck={isCheck} isResult={isResult} isNotInput={isNotInput} isNotQuiz={isNotQuiz} isInputQuizMode={isInputQuizMode} turn={turn}/>
42
+ {/* 下に固定しておくボタンを設置 */}
43
+ {isNotQuiz && (<react_native_1.View style={styles.fixedBottom} pointerEvents="box-none">
44
+ <react_native_1.View style={styles.reopenRow} pointerEvents="box-none">
45
+ <RefLink_1.ReopenButton />
46
+ </react_native_1.View>
47
+ <Guide_1.default name="quizPageTag" isVisible={showTagGuide}>
48
+ <Check_1.default navigation={navigation}/>
49
+ </Guide_1.default>
50
+ </react_native_1.View>)}
51
+ {/* 記述解答欄のキーボードを閉じるバー。ScrollViewの外でないと画面下端に固定できない */}
52
+ <KeyboardCloseBar_1.default />
53
+ </react_native_1.View>
54
+ </RefLink_1.RefLinkProvider>);
47
55
  };
48
56
  const styles = react_native_1.StyleSheet.create({
49
57
  wrapper: {
@@ -58,5 +66,9 @@ const styles = react_native_1.StyleSheet.create({
58
66
  paddingHorizontal: 15,
59
67
  paddingBottom: 5,
60
68
  },
69
+ reopenRow: {
70
+ alignItems: "flex-end",
71
+ marginBottom: 8,
72
+ },
61
73
  });
62
74
  exports.default = QuizPage;
@@ -40,10 +40,10 @@ const lib_1 = require("@nakamura-123/lib");
40
40
  const stores_1 = require("@nakamura-123/stores");
41
41
  const quizHook_1 = require("../hooks/quizHook");
42
42
  const ReportPage = ({ navigation, route }) => {
43
- var _a;
43
+ var _a, _b, _c;
44
44
  const articleInfo = (_a = route === null || route === void 0 ? void 0 : route.params) === null || _a === void 0 ? void 0 : _a.articleInfo;
45
45
  const { t } = (0, common_1.useDrillTranslation)();
46
- const [type, setType] = (0, react_1.useState)(null);
46
+ const typeIndex = (_b = route === null || route === void 0 ? void 0 : route.params) === null || _b === void 0 ? void 0 : _b.typeIndex;
47
47
  const [mail, setMail] = (0, react_1.useState)("");
48
48
  const [inquiry, setInquiry] = (0, react_1.useState)("");
49
49
  const storeSetting = (0, react_redux_1.useSelector)((state) => state.setting);
@@ -59,6 +59,7 @@ const ReportPage = ({ navigation, route }) => {
59
59
  t("report.type.type2"),
60
60
  t("report.type.type3"),
61
61
  ];
62
+ const [type, setType] = (0, react_1.useState)(typeIndex !== undefined ? ((_c = REPORT_TYPES[typeIndex]) !== null && _c !== void 0 ? _c : null) : null);
62
63
  const handleSend = () => __awaiter(void 0, void 0, void 0, function* () {
63
64
  if (inquiry === "")
64
65
  return react_native_1.Alert.alert(t("report.msg.errorTitle"), t("report.msg.inputContent"), [{ text: "OK" }]);
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  const react_1 = __importStar(require("react"));
39
39
  const react_native_1 = require("react-native");
40
40
  const quizHook_1 = require("../hooks/quizHook");
41
+ const resultHook_1 = require("../hooks/resultHook");
41
42
  const ResultHero_1 = __importDefault(require("../component/Result/ResultHero"));
42
43
  const ResultActions_1 = __importDefault(require("../component/Result/ResultActions"));
43
44
  const QuizFlatList_1 = __importDefault(require("../component/Result/QuizFlatList"));
@@ -82,7 +83,7 @@ const ResultPage = ({ navigation }) => {
82
83
  };
83
84
  // 依存は必要最小限。チェック条件が変わった時だけ再評価されるように。
84
85
  }, []);
85
- const scoreInfo = (0, quizHook_1.useScoreInfo)();
86
+ const scoreInfo = (0, resultHook_1.useFrozenOnRetry)((0, quizHook_1.useScoreInfo)());
86
87
  return (<react_native_1.View style={styles.page}>
87
88
  {!isJLPT && <AdCard_1.default />}
88
89
  {/* 上から、キャラと点数のカード → 大きいボタン・薄い段 → 見直す一覧(設計は result_lesson_overview.md) */}
@@ -39,29 +39,39 @@ const common_1 = require("@nakamura-123/common");
39
39
  const Bottom3Btn_1 = __importDefault(require("./setting/Bottom3Btn"));
40
40
  const react_native_gesture_handler_1 = require("react-native-gesture-handler");
41
41
  const PageContainerWrap_1 = __importDefault(require("./common/PageContainerWrap"));
42
+ const RefLink_1 = require("../component/Article/RefLink");
43
+ const keyboardScroll_1 = require("../component/Rating/keyboardScroll");
42
44
  const QuizContentDrill = ({ navigation, guideName, showSwipe1Guide, showSwipe2Guide, isCheck, isResult, isNotInput, isNotQuiz, isInputQuizMode, turn, }) => {
45
+ var _a;
43
46
  const scrollRef = (0, react_1.useRef)(null);
47
+ const { scrollToInput, onScroll } = (0, keyboardScroll_1.useKeyboardScroll)(scrollRef);
48
+ const hasReopen = !!((_a = (0, RefLink_1.useRefLink)()) === null || _a === void 0 ? void 0 : _a.last);
44
49
  // ターン変更時にスクロール位置をリセット
45
50
  (0, react_1.useEffect)(() => {
46
51
  var _a;
47
52
  (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ y: 0, animated: true });
48
53
  }, [turn]);
49
- return (<react_native_gesture_handler_1.ScrollView contentContainerStyle={styles.container} ref={scrollRef} showsVerticalScrollIndicator={false}>
50
- <PageContainerWrap_1.default scrollViewRef={scrollRef} navigation={navigation}>
51
- <Title_1.default />
52
- <Question_1.default navigation={navigation}/>
53
- <Guide_1.default name={guideName} isVisible={showSwipe1Guide || showSwipe2Guide}>
54
- <react_native_1.View></react_native_1.View>
55
- </Guide_1.default>
56
- <Answer_1.default />
57
- {isCheck && !isResult && isNotInput && <CorrectedBar_1.default />}
58
- {isNotQuiz && <Explain_1.default navigation={navigation}/>}
59
- {isInputQuizMode && <CollapseExplain_1.default navigation={navigation}/>}
60
- <common_1.HelpMark name="quizSwipe" top={0} right={10}/>
61
- <Bottom3Btn_1.default navigation={navigation}/>
62
- <react_native_1.View style={{ height: 70 }}/>
63
- </PageContainerWrap_1.default>
64
- </react_native_gesture_handler_1.ScrollView>);
54
+ return (<keyboardScroll_1.KeyboardScrollContext.Provider value={scrollToInput}>
55
+ <react_native_gesture_handler_1.ScrollView contentContainerStyle={styles.container} ref={scrollRef} onScroll={onScroll} scrollEventThrottle={16} showsVerticalScrollIndicator={false}
56
+ // 評価の書く欄(解説の終わり)がキーボードに隠れないよう、iOSでキーボードの分の余白を足す
57
+ automaticallyAdjustKeyboardInsets keyboardShouldPersistTaps="handled">
58
+ <PageContainerWrap_1.default scrollViewRef={scrollRef} navigation={navigation}>
59
+ <Title_1.default />
60
+ <Question_1.default navigation={navigation}/>
61
+ <Guide_1.default name={guideName} isVisible={showSwipe1Guide || showSwipe2Guide}>
62
+ <react_native_1.View></react_native_1.View>
63
+ </Guide_1.default>
64
+ <Answer_1.default />
65
+ {isCheck && !isResult && isNotInput && <CorrectedBar_1.default />}
66
+ {isNotQuiz && <Explain_1.default navigation={navigation}/>}
67
+ {isInputQuizMode && <CollapseExplain_1.default navigation={navigation}/>}
68
+ <common_1.HelpMark name="quizSwipe" top={0} right={10}/>
69
+ <Bottom3Btn_1.default navigation={navigation}/>
70
+ {/* 下に固定したボタンの分。右下の開き直すボタンが出たら、その分も空ける */}
71
+ <react_native_1.View style={{ height: hasReopen ? 122 : 70 }}/>
72
+ </PageContainerWrap_1.default>
73
+ </react_native_gesture_handler_1.ScrollView>
74
+ </keyboardScroll_1.KeyboardScrollContext.Provider>);
65
75
  };
66
76
  const styles = react_native_1.StyleSheet.create({
67
77
  container: { paddingTop: 20 },
@@ -12,3 +12,7 @@ interface MyTextqqyyProps {
12
12
  }
13
13
  declare const MyTextqqyy: React.FC<MyTextqqyyProps>;
14
14
  export default MyTextqqyy;
15
+ export declare const mathConfigs: Record<FontSize, {
16
+ em: number;
17
+ ex: number;
18
+ }>;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mathConfigs = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const react_native_1 = require("react-native");
8
9
  const react_redux_1 = require("react-redux");
@@ -11,6 +12,7 @@ const react_redux_2 = require("react-redux");
11
12
  const common_1 = require("@nakamura-123/common");
12
13
  const lib_1 = require("@nakamura-123/lib");
13
14
  const react_native_animatable_1 = require("react-native-animatable");
15
+ const RefLink_1 = require("../../component/Article/RefLink");
14
16
  const MyTextqqyy = ({ children, style, isNotSearch, fsize, selectable, weight, numberOfLines, }) => {
15
17
  const dispatch = (0, react_redux_2.useDispatch)();
16
18
  let fontSize = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fsize);
@@ -27,7 +29,7 @@ const MyTextqqyy = ({ children, style, isNotSearch, fsize, selectable, weight, n
27
29
  exports.default = MyTextqqyy;
28
30
  // 01_まず、文章をqqとyyで分割したうえで、オブジェクトを作る関数を作成します。
29
31
  const parseText = (text, isNotSearch) => {
30
- const parts = text.split(/(qq.*?qq|yy.*?yy|JJ.*?JJ|JB.*?BJ|ZZ[AB]ZZ|XX.*?XX|udl\[.*?\])/g);
32
+ const parts = text.split(/(qq.*?qq|yy.*?yy|JJ.*?JJ|JB.*?BJ|ZZ[AB]ZZ|XX.*?XX|udl\[.*?\]|lesson\[[\w-]+\]|figref\[[A-Za-z0-9_]+\])/g);
31
33
  return parts.map((chunk, index) => {
32
34
  // 共通処理: 前後の識別子を取り除くヘルパー
33
35
  const extractContent = (identifier) => chunk.slice(identifier.length, -identifier.length);
@@ -63,6 +65,11 @@ const parseText = (text, isNotSearch) => {
63
65
  content: chunk.slice(4, -1).replace(/yy/g, ""),
64
66
  key: index,
65
67
  };
68
+ // h.解説からLESSONの見出しへの札(lesson[名札])と、図の札(figref[図])
69
+ if (chunk.startsWith("lesson[") && chunk.endsWith("]"))
70
+ return { type: "lesson", content: chunk.slice(7, -1), key: index };
71
+ if (chunk.startsWith("figref[") && chunk.endsWith("]"))
72
+ return { type: "figref", content: chunk.slice(7, -1), key: index };
66
73
  // z.検索の無い、普通の文字
67
74
  return { type: "text", content: chunk, key: index };
68
75
  });
@@ -73,7 +80,7 @@ const renderText = (item, onSearch, fsize, fWeight, dispatch) => {
73
80
  const multiAnsElement = (color) => {
74
81
  const content = item.content || "";
75
82
  if (content.startsWith("qq") && content.endsWith("qq"))
76
- return (<MathView math={content.slice(2, -2)} key={item.key} color={lib_1.colors[color]} config={mathConfigs[fsize]}/>);
83
+ return (<MathView math={content.slice(2, -2)} key={item.key} color={lib_1.colors[color]} config={exports.mathConfigs[fsize]}/>);
77
84
  const text = content.replace(/yy/g, "");
78
85
  return (<common_1.MyText key={item.key} fsize={fsize} weight={fWeight} color={color} onPress={() => onSearch(text)}>
79
86
  {text}
@@ -81,7 +88,7 @@ const renderText = (item, onSearch, fsize, fWeight, dispatch) => {
81
88
  };
82
89
  // ここからが、02の各タイプに応じたレンダリング処理です。
83
90
  const renderContentByType = {
84
- math: (<MathView math={item.content} key={item.key} config={mathConfigs[fsize]}/>),
91
+ math: (<MathView math={item.content} key={item.key} config={exports.mathConfigs[fsize]}/>),
85
92
  search: (<common_1.MyText key={item.key} style={styles.searchText} onPress={() => onSearch(item.content || "")} fsize={fsize} weight={fWeight} color="ltBlack">
86
93
  {item.content}
87
94
  </common_1.MyText>),
@@ -104,6 +111,8 @@ const renderText = (item, onSearch, fsize, fWeight, dispatch) => {
104
111
  </common_1.MyText>
105
112
  <react_native_animatable_1.View style={[styles.udlLine, udlStyles[fsize].line]}/>
106
113
  </react_native_animatable_1.View>),
114
+ lesson: <RefLink_1.LessonChip key={item.key} id={item.content} fsize={fsize}/>,
115
+ figref: <RefLink_1.FigChip key={item.key} name={item.content} fsize={fsize}/>,
107
116
  text: (<common_1.MyText key={item.key} fsize={fsize} weight={fWeight}>
108
117
  {item.content}
109
118
  </common_1.MyText>),
@@ -112,7 +121,8 @@ const renderText = (item, onSearch, fsize, fWeight, dispatch) => {
112
121
  };
113
122
  // 数式を文字サイズの設定に合わせる。em の既定は16pxで、これが md(15px)のときの今の大きさ。
114
123
  // 同じ設定ならエンジンを使い回すので、設定ごとに1つずつ固定で持つ
115
- const mathConfigs = Object.fromEntries(lib_1.infoFontSize.map(({ size, fsize }) => [
124
+ // LESSONの穴埋めの文(ClozeText)でも同じ大きさで数式を描くので出す
125
+ exports.mathConfigs = Object.fromEntries(lib_1.infoFontSize.map(({ size, fsize }) => [
116
126
  size,
117
127
  { em: fsize + 1, ex: (fsize + 1) / 2 },
118
128
  ]));
@@ -27,6 +27,7 @@ export type ExplainBlock = {
27
27
  lines: string[];
28
28
  };
29
29
  export declare const groupExplainLines: (lines: string[]) => ExplainBlock[];
30
+ export declare const splitCells: (line: string) => string[];
30
31
  export declare const columnWeights: (rows: string[][]) => number[];
31
32
  export declare const getHeading: (word: string) => string | null;
32
33
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHeading = exports.columnWeights = exports.groupExplainLines = exports.getExplainDatas = void 0;
3
+ exports.getHeading = exports.columnWeights = exports.splitCells = exports.groupExplainLines = exports.getExplainDatas = void 0;
4
4
  const getExplainDatas = (word, Q) => {
5
5
  const { yearId, num, form } = Q;
6
6
  if (word.startsWith("lmn"))
@@ -83,7 +83,7 @@ const readBlock = (lines, start) => {
83
83
  return null;
84
84
  const next = end + 1;
85
85
  if (type === "表")
86
- return { block: { kind: "table", rows: inner.map(splitCells) }, next };
86
+ return { block: { kind: "table", rows: inner.map(exports.splitCells) }, next };
87
87
  return {
88
88
  block: {
89
89
  kind: "box",
@@ -103,6 +103,7 @@ const splitCells = (line) => {
103
103
  cells.pop();
104
104
  return cells;
105
105
  };
106
+ exports.splitCells = splitCells;
106
107
  // 表の列幅。均等に割ると、短い名前の列が空き、長い説明の列だけが何行にも折り返す。
107
108
  // 列ごとに「本文行の平均字数」と「見出しの字数」の大きいほうに3字を足した比で割る。
108
109
  // 見出しを数えないと本文の短い列で見出しが細かく折り返し、3字を足さないと短い列が