@nakamura-123/pages 1.4.1 → 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 (43) hide show
  1. package/dist/component/Article/ArticleContentView.d.ts +5 -1
  2. package/dist/component/Article/ArticleContentView.js +208 -34
  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 +9 -9
  22. package/dist/component/Result/ResultActions.js +151 -58
  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/ratingFnc.d.ts +4 -0
  28. package/dist/functions/ratingFnc.js +30 -0
  29. package/dist/hooks/resultHook.d.ts +2 -1
  30. package/dist/hooks/resultHook.js +13 -1
  31. package/dist/page/ArticleDetail.js +58 -15
  32. package/dist/page/ImgZoom.d.ts +4 -3
  33. package/dist/page/ImgZoom.js +16 -2
  34. package/dist/page/QuizPage.js +23 -11
  35. package/dist/page/ReportPage.js +3 -2
  36. package/dist/quiz/QuizContentsDrill.js +26 -16
  37. package/dist/quiz/common/MyTextqqyy.d.ts +4 -0
  38. package/dist/quiz/common/MyTextqqyy.js +14 -4
  39. package/dist/quiz/explain/ExplainLogic.d.ts +1 -0
  40. package/dist/quiz/explain/ExplainLogic.js +3 -2
  41. package/dist/quiz/explain/NormalExplain.js +3 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +2 -2
@@ -1,8 +1,12 @@
1
1
  import React from "react";
2
- import { ArticleContent } from "@nakamura-123/types";
2
+ import { StackNavigationProp } from "@react-navigation/stack";
3
+ import { ArticleContent, Nav } from "@nakamura-123/types";
3
4
  interface ArticleContentViewProps {
4
5
  content: ArticleContent;
5
6
  articleId: string;
7
+ navigation: StackNavigationProp<Nav.RootStackParamList>;
8
+ exampleOffset?: number;
9
+ isLesson?: boolean;
6
10
  }
7
11
  declare const ArticleContentView: React.FC<ArticleContentViewProps>;
8
12
  export default ArticleContentView;
@@ -32,24 +32,55 @@ const react_redux_1 = require("react-redux");
32
32
  const lib_1 = require("@nakamura-123/lib");
33
33
  const common_1 = require("@nakamura-123/common");
34
34
  const articleContentFnc_1 = require("../../functions/articleContentFnc");
35
+ const Cloze_1 = require("./Cloze");
35
36
  const MyTextqqyy_1 = __importDefault(require("../../quiz/common/MyTextqqyy"));
37
+ const ArticleTable_1 = __importDefault(require("./ArticleTable"));
38
+ const ArticleImage_1 = __importDefault(require("./ArticleImage"));
39
+ const FramesFigure_1 = __importDefault(require("./FramesFigure"));
36
40
  const isJudgmentBlock = (block) => (block === null || block === void 0 ? void 0 : block.type) === "incorrect" || (block === null || block === void 0 ? void 0 : block.type) === "correct";
37
- const ArticleContentView = ({ content, articleId, }) => {
38
- let exampleCount = 0;
41
+ const ArticleContentView = ({ content, articleId, navigation, exampleOffset = 0, isLesson = false, }) => {
42
+ let exampleCount = exampleOffset;
43
+ const rImgs = (0, react_redux_1.useSelector)((state) => state.app.imgs.rImgs);
44
+ // コマ送りの図のデータ(図の名前 → データ)。ある図はコマ送りで、無い図はJPGで描く
45
+ const rFrames = (0, react_redux_1.useSelector)((state) => state.app.imgs.rFrames);
39
46
  // 例文の絵。keyは「説明のkey-例文の番号」("2-1")。絵の無い例文・アプリは絵なしの形で出す
40
47
  const exImgs = (0, react_redux_1.useSelector)((state) => state.app.imgs.exImgs);
41
48
  const userFsize = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fsize);
42
49
  const userFWeight = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fWeight);
43
- return (<react_native_1.View style={styles.container}>
44
- <react_native_1.View style={styles.titleWrap}>
45
- <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xxxl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
46
- {content.title}
47
- </common_1.MyText>
48
- </react_native_1.View>
49
- <react_native_1.View style={styles.bodyWrap}>
50
- {content.blocks.map((block, index) => {
50
+ // 穴の数とボタンは、最初の#の見出しのすぐ下に置く(#が無ければ本文の頭)
51
+ const clozeBarAfter = content.blocks.findIndex((b) => b.type === "heading" && b.style === "bar");
52
+ return (<Cloze_1.ClozeProvider blocks={content.blocks} searchEnabled={isLesson}>
53
+ <react_native_1.View style={styles.container}>
54
+ {/* LESSONの2ページ目からはタイトルを出さない(ArticleSectionPagerが空で渡す) */}
55
+ {content.title ? (<react_native_1.View style={styles.titleWrap}>
56
+ <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xxxl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
57
+ {content.title}
58
+ </common_1.MyText>
59
+ </react_native_1.View>) : null}
60
+ <react_native_1.View style={styles.bodyWrap}>
61
+ {clozeBarAfter === -1 && <Cloze_1.ClozeBar />}
62
+ {content.blocks.map((block, index) => {
51
63
  if (block.type === "example")
52
64
  exampleCount += 1;
65
+ if (block.type === "image") {
66
+ const path = rImgs
67
+ ? lib_1.utilFnc.getrImgPath(rImgs, block.name)
68
+ : undefined;
69
+ const frames = rFrames === null || rFrames === void 0 ? void 0 : rFrames[block.name];
70
+ // コマ送りの図。最初は完成図を出し、押すと1コマ目から動く。拡大の印からは完成図のJPGを開く
71
+ if (frames)
72
+ return (<react_native_1.View key={index} style={styles.imageWrap}>
73
+ <FramesFigure_1.default name={block.name} data={frames} startAt="last" navigation={navigation} zoomPath={path}/>
74
+ </react_native_1.View>);
75
+ if (path === undefined) {
76
+ if (__DEV__)
77
+ console.warn(`[articleContent] 図がrImgsにありません: "${block.name}"`);
78
+ return null;
79
+ }
80
+ return (<react_native_1.View key={index} style={styles.imageWrap}>
81
+ <ArticleImage_1.default path={path} navigation={navigation}/>
82
+ </react_native_1.View>);
83
+ }
53
84
  let groupPosition;
54
85
  if (isJudgmentBlock(block)) {
55
86
  const hasPrev = isJudgmentBlock(content.blocks[index - 1]);
@@ -63,22 +94,28 @@ const ArticleContentView = ({ content, articleId, }) => {
63
94
  ? "top"
64
95
  : "only";
65
96
  }
66
- return (<ArticleBlockView key={index} block={block} exampleNumber={exampleCount} exampleImg={block.type === "example"
97
+ return (<react_1.default.Fragment key={index}>
98
+ <ArticleBlockView block={block} blockIndex={index} exampleNumber={exampleCount} exampleImg={block.type === "example"
67
99
  ? exImgs === null || exImgs === void 0 ? void 0 : exImgs[`${articleId}-${exampleCount}`]
68
- : undefined} groupPosition={groupPosition} userFsize={userFsize} userFWeight={userFWeight}/>);
100
+ : undefined} groupPosition={groupPosition}
101
+ // タイトルの無いページ(LESSONの2ページ目から)は#で始まるので、上の空きを詰める
102
+ isPageTop={index === 0 && !content.title} userFsize={userFsize} userFWeight={userFWeight}/>
103
+ {index === clozeBarAfter && <Cloze_1.ClozeBar />}
104
+ </react_1.default.Fragment>);
69
105
  })}
106
+ </react_native_1.View>
70
107
  </react_native_1.View>
71
- </react_native_1.View>);
108
+ </Cloze_1.ClozeProvider>);
72
109
  };
73
- const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, userFsize, userFWeight, }) => {
110
+ const ArticleBlockView = ({ block, blockIndex, exampleNumber, exampleImg, groupPosition, isPageTop, userFsize, userFWeight, }) => {
74
111
  const { t } = (0, common_1.useDrillTranslation)();
75
112
  const [isRevealed, setIsRevealed] = (0, react_1.useState)(false);
76
113
  switch (block.type) {
77
114
  case "heading":
78
115
  if (block.style === "bar") {
79
- return (<react_native_1.View style={styles.headingBarRow}>
116
+ return (<react_native_1.View style={[styles.headingBarRow, isPageTop && styles.pageTop]}>
80
117
  <react_native_1.View style={styles.headingBar}/>
81
- <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xxl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
118
+ <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="darkGray" style={styles.headingBarText}>
82
119
  {block.text}
83
120
  </common_1.MyText>
84
121
  </react_native_1.View>);
@@ -90,11 +127,13 @@ const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, use
90
127
  </common_1.MyText>
91
128
  </react_native_1.View>);
92
129
  }
93
- return (<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("lg", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="gray" style={styles.headingBold}>
94
- {block.text}
95
- </common_1.MyText>);
130
+ return (<react_native_1.View style={styles.headingBold}>
131
+ <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("lg", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
132
+ {block.text}
133
+ </common_1.MyText>
134
+ </react_native_1.View>);
96
135
  case "paragraph":
97
- return (<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.paragraph}/>);
136
+ return (<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={Object.assign(Object.assign({}, styles.paragraph), { lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 22) })}/>);
98
137
  case "example": {
99
138
  const exampleLabel = (<common_1.MyText fsize="sm" weight={700} color="green">
100
139
  {String(exampleNumber).padStart(2, "0")}
@@ -110,14 +149,12 @@ const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, use
110
149
  exampleImg !== undefined && styles.exampleTopWithImg,
111
150
  ]}>
112
151
  {exampleImg === undefined && exampleLabel}
113
- <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.exampleText}>
114
- {block.japanese}
115
- </common_1.MyText>
152
+ <Cloze_1.ExampleText text={block.japanese} group={(0, articleContentFnc_1.exampleHoleGroup)(blockIndex)} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.exampleText}/>
116
153
  </react_native_1.View>
117
154
  {block.translation && (<react_native_1.TouchableOpacity onPress={() => setIsRevealed(!isRevealed)} style={styles.exampleBottom}>
118
155
  {/* 非表示時もopacity:0で全幅描画し、訳文の実際の高さ分の領域を最初から確保する(アイコンの有無で幅が変わって高さがずれないよう、アイコンは重ねて表示する別レイヤーにする) */}
119
156
  <common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} color="text" style={!isRevealed && styles.invisibleText}>
120
- {block.translation}
157
+ {renderTransUdl(block.translation)}
121
158
  </common_1.MyText>
122
159
  {!isRevealed && (<react_native_1.View style={styles.exampleBottomOverlay}>
123
160
  <common_1.Icon5 name="eye" size={14} color="ltBlack" style={styles.exampleBottomIcon}/>
@@ -148,17 +185,76 @@ const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, use
148
185
  <BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.judgmentText}/>
149
186
  </react_native_1.View>);
150
187
  }
188
+ case "table":
189
+ return (<ArticleTable_1.default rows={block.rows} blockIndex={blockIndex} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)}/>);
190
+ // 上の例文の補足。例文の枠の下に縦線でつなぎ、どの話の続きかを頭の札で示す
191
+ case "exampleNote":
192
+ return (<react_native_1.View style={styles.exampleNote}>
193
+ <react_native_1.View style={styles.exampleNoteLabel}>
194
+ <common_1.Icon5 name="level-up-alt" size={11} color="ltBlack" style={styles.exampleNoteIcon}/>
195
+ <common_1.MyText fsize="xs" weight={700} color="ltBlack">
196
+ {t("article.exampleNote")}
197
+ </common_1.MyText>
198
+ </react_native_1.View>
199
+ <BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={{
200
+ lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 22),
201
+ }}/>
202
+ </react_native_1.View>);
203
+ // 解説のポイント枠(ExplainBox)は全アプリの解説で使っているので変えず、記事は別の形にする
204
+ case "point":
205
+ return (<react_native_1.View style={styles.pointBox}>
206
+ <react_native_1.View style={styles.pointLabel}>
207
+ <common_1.Icon5 name="lightbulb" size={11} color="black" solid style={styles.pointLabelIcon}/>
208
+ <common_1.MyText fsize="xs" weight={700} color="black">
209
+ POINT
210
+ </common_1.MyText>
211
+ </react_native_1.View>
212
+ <BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} style={{
213
+ lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 24),
214
+ }}/>
215
+ </react_native_1.View>);
151
216
  default:
152
217
  return null;
153
218
  }
154
219
  };
220
+ // 例文の訳の中の、空欄に当たる部分(udl[…])に下線を引く。外側の文字の大きさ・太さを受け継ぐので、中は色と線だけ持つ
221
+ const renderTransUdl = (text) => text
222
+ .split(/(udl\[[^\]]+\])/)
223
+ .filter((chunk) => chunk.length > 0)
224
+ .map((chunk, i) => {
225
+ const m = chunk.match(/^udl\[([^\]]+)\]$/);
226
+ return m ? (<react_native_1.Text key={i} style={styles.transUdl}>
227
+ {m[1]}
228
+ </react_native_1.Text>) : (chunk);
229
+ });
230
+ // 説明の文の【文法名】を太字・緑に、使い分けの決め手(udl[…])に下線を引く(n2bのunit。dk2の記事には【】もudl[]も無い)
231
+ // 太さはfontFamilyで決まるので、太字は700の書体に替える
232
+ const renderBodyMarks = (text) => text
233
+ .split(/(【[^】]*】|udl\[[^\]]+\])/)
234
+ .filter((chunk) => chunk.length > 0)
235
+ .map((chunk, i) => {
236
+ const m = chunk.match(/^udl\[([^\]]+)\]$/);
237
+ if (m) {
238
+ return (<react_native_1.Text key={i} style={styles.bodyUdl}>
239
+ {m[1]}
240
+ </react_native_1.Text>);
241
+ }
242
+ return chunk.startsWith("【") ? (<react_native_1.Text key={i} style={styles.bodyGrammar}>
243
+ {chunk}
244
+ </react_native_1.Text>) : (chunk);
245
+ });
155
246
  // 数式(qq…qq)がある文だけ、解説と同じ部品で描く。ない文を今までどおりにするのは、
156
247
  // 解説の部品がyy(検索語)やudl[]も読み替えるため(記事の文はその記法を前提に書かれていない)
157
- const BodyText = ({ text, fsize, weight, style }) => text.includes("qq") ? (<MyTextqqyy_1.default fsize={fsize} weight={weight} style={style} isNotSearch>
248
+ // 解説の部品はmargin: 5を持つので、数式の無い文と左がそろうよう左右だけ0に戻す(上は式の行の間隔として残す)
249
+ // 穴(ana[])のある文と、LESSONの検索語(yy…yy)のある文は穴埋めの部品で描く(数式も一緒に描ける)
250
+ const BodyText = ({ text, fsize, weight, style }) => {
251
+ const searchEnabled = (0, Cloze_1.useLessonSearch)();
252
+ return (0, articleContentFnc_1.usesClozeText)(text, searchEnabled) ? (<Cloze_1.ClozeText text={text} fsize={fsize} weight={weight} style={style}/>) : text.includes("qq") ? (<MyTextqqyy_1.default fsize={fsize} weight={weight} style={Object.assign(Object.assign({}, styles.qqReset), style)} isNotSearch>
158
253
  {text}
159
254
  </MyTextqqyy_1.default>) : (<common_1.MyText fsize={fsize} weight={weight} color="text" style={style}>
160
- {text}
255
+ {renderBodyMarks(text)}
161
256
  </common_1.MyText>);
257
+ };
162
258
  const styles = react_native_1.StyleSheet.create({
163
259
  container: {
164
260
  // marginHorizontal: -20,
@@ -175,17 +271,25 @@ const styles = react_native_1.StyleSheet.create({
175
271
  paddingTop: 16,
176
272
  paddingBottom: 20,
177
273
  },
274
+ pageTop: {
275
+ marginTop: 4,
276
+ },
178
277
  headingBarRow: {
179
278
  flexDirection: "row",
180
279
  alignItems: "center",
181
- marginTop: 32,
280
+ marginTop: 28,
182
281
  marginBottom: 12,
183
282
  },
184
283
  headingBar: {
185
- width: 4,
186
- height: 18,
187
- backgroundColor: lib_1.colors.green,
188
- marginRight: 11,
284
+ width: 5,
285
+ height: 22,
286
+ borderRadius: 3,
287
+ backgroundColor: lib_1.colors.darkGray,
288
+ marginRight: 10,
289
+ },
290
+ // 長い見出しは線の右で折り返す
291
+ headingBarText: {
292
+ flexShrink: 1,
189
293
  },
190
294
  headingUnderline: {
191
295
  alignSelf: "flex-start",
@@ -196,12 +300,15 @@ const styles = react_native_1.StyleSheet.create({
196
300
  borderBottomColor: lib_1.colors.text,
197
301
  },
198
302
  headingBold: {
199
- marginTop: 16,
200
- marginBottom: 6,
303
+ alignSelf: "flex-start",
304
+ marginTop: 20,
305
+ marginBottom: 8,
306
+ paddingBottom: 3,
307
+ borderBottomWidth: 2,
308
+ borderBottomColor: lib_1.colors.darkGray,
201
309
  },
202
310
  paragraph: {
203
311
  marginBottom: 10,
204
- lineHeight: 22,
205
312
  },
206
313
  exampleBox: {
207
314
  borderRadius: 8,
@@ -245,6 +352,21 @@ const styles = react_native_1.StyleSheet.create({
245
352
  invisibleText: {
246
353
  opacity: 0,
247
354
  },
355
+ // 下線だけだと細くて見えにくい(太さは変えられない)ので、空欄の答えと同じ色にもする
356
+ transUdl: {
357
+ color: lib_1.colors.red,
358
+ textDecorationLine: "underline",
359
+ textDecorationColor: lib_1.colors.red,
360
+ },
361
+ // 共通の緑(#8ACBB7)は地のベージュの上の文字には薄いので、同じ系統の濃い緑にする
362
+ bodyGrammar: {
363
+ color: "#2F8A6E",
364
+ fontFamily: "ZenKakuGothicNew_700Bold",
365
+ },
366
+ bodyUdl: {
367
+ textDecorationLine: "underline",
368
+ textDecorationColor: lib_1.colors.red,
369
+ },
248
370
  exampleBottomOverlay: {
249
371
  position: "absolute",
250
372
  top: 12,
@@ -284,5 +406,57 @@ const styles = react_native_1.StyleSheet.create({
284
406
  judgmentText: {
285
407
  flex: 1,
286
408
  },
409
+ imageWrap: {
410
+ marginVertical: 8,
411
+ },
412
+ qqReset: {
413
+ marginHorizontal: 0,
414
+ },
415
+ // 例文の枠(marginBottom: 10)の真下から線を始めて、例文とつながって見えるようにする
416
+ exampleNote: {
417
+ marginTop: -10,
418
+ marginBottom: 12,
419
+ marginLeft: 14,
420
+ paddingTop: 8,
421
+ paddingLeft: 12,
422
+ borderLeftWidth: 3,
423
+ borderLeftColor: lib_1.colors.beige,
424
+ },
425
+ exampleNoteLabel: {
426
+ flexDirection: "row",
427
+ alignItems: "center",
428
+ marginBottom: 2,
429
+ },
430
+ exampleNoteIcon: {
431
+ marginRight: 6,
432
+ },
433
+ // 札を枠の上の線に重ねるので、その分だけ上を空ける
434
+ pointBox: {
435
+ marginTop: 22,
436
+ marginBottom: 14,
437
+ paddingTop: 20,
438
+ paddingBottom: 14,
439
+ paddingHorizontal: 14,
440
+ borderWidth: 1.5,
441
+ borderColor: lib_1.colors.darkGray,
442
+ borderRadius: 14,
443
+ backgroundColor: lib_1.colors.white,
444
+ },
445
+ pointLabel: {
446
+ position: "absolute",
447
+ top: -12,
448
+ left: 12,
449
+ flexDirection: "row",
450
+ alignItems: "center",
451
+ paddingHorizontal: 11,
452
+ paddingVertical: 2,
453
+ borderRadius: 999,
454
+ borderWidth: 1.5,
455
+ borderColor: lib_1.colors.darkGray,
456
+ backgroundColor: lib_1.colors.yellow,
457
+ },
458
+ pointLabelIcon: {
459
+ marginRight: 6,
460
+ },
287
461
  });
288
462
  exports.default = ArticleContentView;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { StackNavigationProp } from "@react-navigation/stack";
3
+ import { Nav } from "@nakamura-123/types";
4
+ interface Props {
5
+ path: number;
6
+ navigation: StackNavigationProp<Nav.RootStackParamList>;
7
+ }
8
+ declare const ArticleImage: React.FC<Props>;
9
+ export default ArticleImage;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const react_native_1 = require("react-native");
28
+ const MAX_HEIGHT = 1000;
29
+ // 記事の図。枠の幅が決まったらすぐ図の高さの場所を取り、読み込みが遅れても下の文章が押し下げられないようにする(11/08、本人)。
30
+ // 共通のMyImageは幅を測ったあと、もう一度描き直してから図を置くので、図が後から出て下の文章が動く。
31
+ // MyImageは全アプリの問題の解説でも使うので、記事だけこの部品にした。
32
+ // 幅を"100%"と縦横の比だけで決めると、Androidで図が画面より大きく出た(2026-11-08、Pixel 8a)ので、幅を測って数字で決める
33
+ const ArticleImage = ({ path, navigation }) => {
34
+ const [boxWidth, setBoxWidth] = (0, react_1.useState)(0);
35
+ // 縦横の大きさは、読み込む前から同期で分かる
36
+ const source = react_native_1.Image.resolveAssetSource(path);
37
+ // 元の大きさより広げない(MyImageと同じ)
38
+ const width = Math.min(boxWidth, source.width);
39
+ const height = Math.min((width * source.height) / source.width, MAX_HEIGHT);
40
+ return (<react_native_1.View style={{ alignItems: "center" }} onLayout={(e) => setBoxWidth(e.nativeEvent.layout.width)}>
41
+ {boxWidth > 0 && (<react_native_1.TouchableOpacity onPress={() => navigation.navigate("ImgZoom", { path })} activeOpacity={0.7}>
42
+ <react_native_1.Image source={path} resizeMode="contain" style={{ width, height }}/>
43
+ </react_native_1.TouchableOpacity>)}
44
+ </react_native_1.View>);
45
+ };
46
+ exports.default = ArticleImage;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { StackNavigationProp } from "@react-navigation/stack";
3
+ import { Nav } from "@nakamura-123/types";
4
+ import { ArticleSection } from "../../functions/articleContentFnc";
5
+ type Navigation = StackNavigationProp<Nav.RootStackParamList>;
6
+ interface Props {
7
+ title: string;
8
+ sections: ArticleSection[];
9
+ articleId: string;
10
+ navigation: Navigation;
11
+ footer: React.ReactNode;
12
+ startId?: string;
13
+ restorePosition?: boolean;
14
+ onReportWrong: () => void;
15
+ }
16
+ declare const ArticleSectionPager: React.FC<Props>;
17
+ export default ArticleSectionPager;
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const react_native_1 = require("react-native");
31
+ const react_native_pager_view_1 = __importDefault(require("react-native-pager-view"));
32
+ const lib_1 = require("@nakamura-123/lib");
33
+ const common_1 = require("@nakamura-123/common");
34
+ const ArticleContentView_1 = __importDefault(require("./ArticleContentView"));
35
+ const ChipStrip_1 = __importDefault(require("./ChipStrip"));
36
+ const RatingBar_1 = __importDefault(require("../Rating/RatingBar"));
37
+ const keyboardScroll_1 = require("../Rating/keyboardScroll");
38
+ const ratingFnc_1 = require("../../functions/ratingFnc");
39
+ const articleContentFnc_1 = require("../../functions/articleContentFnc");
40
+ // 記事ごとに、最後に見ていたページと各ページの縦の位置。アプリを閉じるまで覚えておく
41
+ const positions = new Map();
42
+ const positionOf = (articleId) => {
43
+ const found = positions.get(articleId);
44
+ if (found)
45
+ return found;
46
+ const created = { page: 0, ys: [] };
47
+ positions.set(articleId, created);
48
+ return created;
49
+ };
50
+ const sectionKey = (section, i) => { var _a; return `${i}-${(_a = section.id) !== null && _a !== void 0 ? _a : ""}`; };
51
+ // LESSONを見出し(#)ごとのページにし、横に払って進む。上の見出しの帯で今どこかが分かり、押せば飛べる
52
+ const ArticleSectionPager = ({ title, sections, articleId, navigation, footer, startId, restorePosition, onReportWrong, }) => {
53
+ const pagerRef = (0, react_1.useRef)(null);
54
+ // 開いたときのページと、各ページの縦の位置。開いたあとは変えない
55
+ const [start] = (0, react_1.useState)(() => {
56
+ const saved = positions.get(articleId);
57
+ if (restorePosition && saved)
58
+ return { page: saved.page, ys: [...saved.ys] };
59
+ const found = startId ? (0, articleContentFnc_1.findSectionIndex)(sections, startId) : -1;
60
+ return { page: Math.max(found, 0), ys: [] };
61
+ });
62
+ const [index, setIndex] = (0, react_1.useState)(start.page);
63
+ // 開き直しでなければ、前の位置は捨てて今開いたところから覚え直す
64
+ (0, react_1.useEffect)(() => {
65
+ if (restorePosition && positions.has(articleId))
66
+ return;
67
+ positions.set(articleId, { page: start.page, ys: [] });
68
+ }, []);
69
+ // 今のページはonPageSelectedだけで決める(ここでも決めると、押したときに2回描き直す)
70
+ const goTo = (i) => { var _a; return (_a = pagerRef.current) === null || _a === void 0 ? void 0 : _a.setPage(i); };
71
+ return (<react_native_1.View style={styles.container}>
72
+ {/* ヘッダーは透明で、戻るボタンと設定ボタンが画面の上に浮いている。帯はその間に置く */}
73
+ <react_native_1.View style={styles.stripRow}>
74
+ <ChipStrip_1.default labels={sections.map((section) => section.title)} index={index} onSelect={goTo} style={styles.stripScroll}/>
75
+ </react_native_1.View>
76
+
77
+ <react_native_pager_view_1.default ref={pagerRef} style={styles.pager} initialPage={start.page} onPageSelected={(e) => {
78
+ setIndex(e.nativeEvent.position);
79
+ positionOf(articleId).page = e.nativeEvent.position;
80
+ }}>
81
+ {sections.map((section, i) => {
82
+ var _a, _b, _c;
83
+ return (<react_native_1.View key={sectionKey(section, i)} collapsable={false} style={styles.page}>
84
+ <SectionPage section={section} index={i} initialY={(_a = start.ys[i]) !== null && _a !== void 0 ? _a : 0} title={i === 0 ? title : ""} articleId={articleId} navigation={navigation} prevTitle={(_b = sections[i - 1]) === null || _b === void 0 ? void 0 : _b.title} nextTitle={(_c = sections[i + 1]) === null || _c === void 0 ? void 0 : _c.title} onReportWrong={onReportWrong} onPrev={() => goTo(i - 1)} onNext={() => goTo(i + 1)} footer={i === sections.length - 1 ? footer : null}/>
85
+ </react_native_1.View>);
86
+ })}
87
+ </react_native_pager_view_1.default>
88
+ </react_native_1.View>);
89
+ };
90
+ // ページを払うたびに帯の色を変えるので、ページの中身はそのたびに描き直さないようにする(式の多いLESSONで重くなるため)。
91
+ // onPrev・onNextは毎回新しく作られるが、中身はページの番号で決まるので比べない
92
+ const SectionPage = (0, react_1.memo)(({ section, index, initialY, title, articleId, navigation, prevTitle, nextTitle, onReportWrong, onPrev, onNext, footer, }) => {
93
+ var _a;
94
+ const scrollRef = (0, react_1.useRef)(null);
95
+ const { scrollToInput, onScroll } = (0, keyboardScroll_1.useKeyboardScroll)(scrollRef);
96
+ return (<keyboardScroll_1.KeyboardScrollContext.Provider value={scrollToInput}>
97
+ <react_native_1.ScrollView ref={scrollRef} contentContainerStyle={styles.pageContent} contentOffset={{ x: 0, y: initialY }}
98
+ // 評価の書く欄(ページの終わり)がキーボードに隠れないよう、iOSでキーボードの分の余白を足す
99
+ automaticallyAdjustKeyboardInsets keyboardShouldPersistTaps="handled" onScroll={onScroll} scrollEventThrottle={16} onScrollEndDrag={(e) => {
100
+ positionOf(articleId).ys[index] = e.nativeEvent.contentOffset.y;
101
+ }} onMomentumScrollEnd={(e) => {
102
+ positionOf(articleId).ys[index] = e.nativeEvent.contentOffset.y;
103
+ }}>
104
+ <ArticleContentView_1.default content={{ title, blocks: section.blocks }} articleId={articleId} navigation={navigation} exampleOffset={section.exampleOffset} isLesson/>
105
+ {/* 見出しのページごとに評価する。本文の印は、そのページの中身から作る */}
106
+ <RatingBar_1.default target={(0, ratingFnc_1.lessonTarget)(articleId, (_a = section.id) !== null && _a !== void 0 ? _a : `p${index}`)} ver={(0, ratingFnc_1.ratingVer)(JSON.stringify(section.blocks))} kind="lesson" onReport={onReportWrong}/>
107
+ {/* 前後の見出しへ。片方しか無いページでも、前は左・次は右の位置のまま置く */}
108
+ <react_native_1.View style={styles.navRow}>
109
+ {prevTitle !== undefined ? (<common_1.PressAnimatedWrap onPress={onPrev} outerStyle={styles.navOuter} style={[styles.navButton, styles.navPrev]}>
110
+ <common_1.Icon5 name="arrow-left" size={14} color="ltBlack"/>
111
+ <common_1.MyText fsize="sm" weight={700} color="text" style={styles.navTextPrev} numberOfLines={1}>
112
+ {prevTitle}
113
+ </common_1.MyText>
114
+ </common_1.PressAnimatedWrap>) : (<react_native_1.View style={styles.navOuter}/>)}
115
+ {nextTitle !== undefined ? (<common_1.PressAnimatedWrap onPress={onNext} outerStyle={styles.navOuter} style={[styles.navButton, styles.navNext]}>
116
+ <common_1.MyText fsize="sm" weight={700} color="text" style={styles.navTextNext} numberOfLines={1}>
117
+ {nextTitle}
118
+ </common_1.MyText>
119
+ <common_1.Icon5 name="arrow-right" size={14} color="ltBlack"/>
120
+ </common_1.PressAnimatedWrap>) : (<react_native_1.View style={styles.navOuter}/>)}
121
+ </react_native_1.View>
122
+ {footer}
123
+ </react_native_1.ScrollView>
124
+ </keyboardScroll_1.KeyboardScrollContext.Provider>);
125
+ }, (prev, next) => prev.section === next.section &&
126
+ prev.index === next.index &&
127
+ prev.title === next.title &&
128
+ prev.articleId === next.articleId &&
129
+ prev.prevTitle === next.prevTitle &&
130
+ prev.nextTitle === next.nextTitle &&
131
+ prev.footer === next.footer);
132
+ const styles = react_native_1.StyleSheet.create({
133
+ container: {
134
+ flex: 1,
135
+ backgroundColor: lib_1.colors.beige,
136
+ },
137
+ // 高さと左右の空きは、透明なヘッダーの戻るボタン(左・幅40+余白10)と設定ボタン(右)に合わせる
138
+ stripRow: {
139
+ height: 52,
140
+ justifyContent: "center",
141
+ borderBottomWidth: 1,
142
+ borderBottomColor: lib_1.colors.light,
143
+ backgroundColor: lib_1.colors.beige,
144
+ },
145
+ stripScroll: {
146
+ marginLeft: 58,
147
+ marginRight: 70,
148
+ },
149
+ pager: {
150
+ flex: 1,
151
+ },
152
+ page: {
153
+ flex: 1,
154
+ },
155
+ // 右下のボタン(解説に戻る・図を開き直す)に最後のページの下のボタンが隠れないようにする
156
+ pageContent: {
157
+ paddingBottom: 110,
158
+ },
159
+ navRow: {
160
+ flexDirection: "row",
161
+ marginHorizontal: 10,
162
+ marginTop: 10,
163
+ gap: 10,
164
+ },
165
+ navOuter: {
166
+ flex: 1,
167
+ },
168
+ navButton: {
169
+ height: 44,
170
+ paddingHorizontal: 12,
171
+ flexDirection: "row",
172
+ alignItems: "center",
173
+ borderRadius: 10,
174
+ borderWidth: 1,
175
+ borderColor: lib_1.colors.light,
176
+ backgroundColor: lib_1.colors.bkBeige,
177
+ },
178
+ navPrev: {
179
+ justifyContent: "flex-start",
180
+ },
181
+ navNext: {
182
+ justifyContent: "flex-end",
183
+ },
184
+ navTextPrev: {
185
+ flexShrink: 1,
186
+ marginLeft: 8,
187
+ },
188
+ navTextNext: {
189
+ flexShrink: 1,
190
+ marginRight: 8,
191
+ },
192
+ });
193
+ exports.default = ArticleSectionPager;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { FontSize, FontWeight } from "@nakamura-123/lib";
3
+ interface Props {
4
+ rows: string[][];
5
+ blockIndex: number;
6
+ fsize: FontSize;
7
+ weight: FontWeight;
8
+ }
9
+ declare const ArticleTable: React.FC<Props>;
10
+ export default ArticleTable;