@nakamura-123/pages 1.1.25 → 1.2.0
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.
- package/dist/component/Article/ArticleCategoryList.d.ts +10 -0
- package/dist/component/Article/ArticleCategoryList.js +155 -0
- package/dist/component/Article/ArticleContentView.d.ts +7 -0
- package/dist/component/Article/ArticleContentView.js +246 -0
- package/dist/component/Article/ArticleContents.d.ts +10 -0
- package/dist/component/Article/ArticleContents.js +132 -0
- package/dist/component/Article/ArticleRow.d.ts +15 -0
- package/dist/component/Article/ArticleRow.js +67 -0
- package/dist/component/Basic/SubCategoryList.js +11 -6
- package/dist/functions/articleContentFnc.d.ts +5 -0
- package/dist/functions/articleContentFnc.js +80 -0
- package/dist/functions/articleListFnc.d.ts +8 -0
- package/dist/functions/articleListFnc.js +43 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -1
- package/dist/page/ArticleDetail.d.ts +11 -0
- package/dist/page/ArticleDetail.js +197 -0
- package/dist/page/ArticlePage.d.ts +9 -0
- package/dist/page/ArticlePage.js +83 -0
- package/dist/page/HomePage.js +0 -24
- package/dist/page/QuizSettingPage.d.ts +3 -0
- package/dist/page/QuizSettingPage.js +10 -5
- package/dist/page/ReportPage.d.ts +3 -0
- package/dist/page/ReportPage.js +7 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -22,6 +22,7 @@ const SubCategoryList = ({ navigation, topSubject, index, }) => {
|
|
|
22
22
|
// Redux states
|
|
23
23
|
const categoryList = (0, react_redux_1.useSelector)((state) => state.app[topSubject.list]);
|
|
24
24
|
const preSelect = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[topSubject.name].preSelect);
|
|
25
|
+
const preSelectArticle = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[topSubject.name].preSelectArticle);
|
|
25
26
|
const outOfYearRange = (0, react_redux_1.useSelector)((state) => state.quizCfg.startCfg.outOfYearRange);
|
|
26
27
|
const startCfg = (0, react_redux_1.useSelector)((state) => state.quizCfg.startCfg);
|
|
27
28
|
// Derived states
|
|
@@ -74,11 +75,13 @@ const SubCategoryList = ({ navigation, topSubject, index, }) => {
|
|
|
74
75
|
const quizList = system === "JLPT"
|
|
75
76
|
? (0, createQuizFncJ_1.getBasicQuizListJ)(query, startCfg, selected)
|
|
76
77
|
: (0, createQuizFncD_1.getBasicQuizList)(query, startCfg, selected);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
78
|
+
dispatch(stores_1.setAction.saveBasicPreSelect({
|
|
79
|
+
subject: topSubject.name,
|
|
80
|
+
category: selectKey,
|
|
81
|
+
lessonKey: subCategories[index].key,
|
|
82
|
+
}));
|
|
83
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
84
|
+
const { subject } = selected;
|
|
82
85
|
const isExistQuiz = useStartQuiz(subject, quizList);
|
|
83
86
|
if (!isExistQuiz)
|
|
84
87
|
return;
|
|
@@ -96,7 +99,9 @@ const SubCategoryList = ({ navigation, topSubject, index, }) => {
|
|
|
96
99
|
const subTags = system === "JLPT"
|
|
97
100
|
? (0, tagFncJ_1.getUnitSubTagLevelCntsJ)(query, selectKey, key, topSubject.tag)
|
|
98
101
|
: getTagFnc(query, selectKey, key, outOfYearRange);
|
|
99
|
-
const isPreSelect =
|
|
102
|
+
const isPreSelect = !preSelectArticle &&
|
|
103
|
+
preSelect.category === selectKey &&
|
|
104
|
+
preSelect.lessonKey === key;
|
|
100
105
|
return (<common_1.RectangleCard key={key} title={title} left={<SubCategoryLeft_1.default rate={(0, tagFncD_1.getCategoryRate)(subTags)} isLocked={isLocked}/>} bottom={<Tag5s_1.default tags={subTags}/>} onPress={() => handleSubCategory(i)} borderColor={isPreSelect ? "ltRed" : undefined} outerStyle={styles.cardSpacing} onLongPress={() => handleLongPress(i)}/>);
|
|
101
106
|
})}
|
|
102
107
|
</react_native_1.View>);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FontSize, FontWeight } from "@nakamura-123/lib";
|
|
2
|
+
import { ArticleContent } from "@nakamura-123/types";
|
|
3
|
+
export declare const getScaledFsize: (base: FontSize, userFsize: FontSize) => FontSize;
|
|
4
|
+
export declare const getScaledWeight: (base: FontWeight, userWeight: FontWeight) => FontWeight;
|
|
5
|
+
export declare const parseArticleContent: (raw: string) => ArticleContent;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArticleContent = exports.getScaledWeight = exports.getScaledFsize = void 0;
|
|
4
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
5
|
+
const REI_PATTERN = /^rei\d*$/;
|
|
6
|
+
const FSIZE_ORDER = lib_1.infoFontSize.map((i) => i.size);
|
|
7
|
+
const FWEIGHT_ORDER = [400, 500, 700];
|
|
8
|
+
// ユーザー設定値(current)の、基準値(neutral)からのズレ分だけbaseをずらす
|
|
9
|
+
const shift = (order, base, current, neutral) => {
|
|
10
|
+
const offset = order.indexOf(current) - order.indexOf(neutral);
|
|
11
|
+
const idx = Math.min(order.length - 1, Math.max(0, order.indexOf(base) + offset));
|
|
12
|
+
return order[idx];
|
|
13
|
+
};
|
|
14
|
+
// 記事内の各要素のfsizeを、ユーザー設定(quizCfg.inQuizOption.fsize)に応じて
|
|
15
|
+
// 相対的に拡大縮小する(見出し階層の大小関係は維持したまま全体をシフトする)
|
|
16
|
+
const getScaledFsize = (base, userFsize) => shift(FSIZE_ORDER, base, userFsize, "md");
|
|
17
|
+
exports.getScaledFsize = getScaledFsize;
|
|
18
|
+
// weightも同様に、ユーザー設定(quizCfg.inQuizOption.fWeight)からの相対シフトで適用する
|
|
19
|
+
const getScaledWeight = (base, userWeight) => shift(FWEIGHT_ORDER, base, userWeight, 500);
|
|
20
|
+
exports.getScaledWeight = getScaledWeight;
|
|
21
|
+
// 記事本文の生テキスト(行頭トークン形式)をArticleContentにパースする
|
|
22
|
+
const parseArticleContent = (raw) => {
|
|
23
|
+
const lines = raw
|
|
24
|
+
.split("\n")
|
|
25
|
+
.map((line) => line.trim())
|
|
26
|
+
.filter((line) => line.length > 0);
|
|
27
|
+
let title = "";
|
|
28
|
+
const blocks = [];
|
|
29
|
+
let lastExampleBlock = null;
|
|
30
|
+
lines.forEach((line) => {
|
|
31
|
+
const spaceIndex = line.indexOf(" ");
|
|
32
|
+
const token = spaceIndex === -1 ? line : line.slice(0, spaceIndex);
|
|
33
|
+
const content = spaceIndex === -1 ? "" : line.slice(spaceIndex + 1).trim();
|
|
34
|
+
if (token === "title") {
|
|
35
|
+
title = content;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (token === "#" || token === "##" || token === "###") {
|
|
39
|
+
const style = token === "#" ? "bar" : token === "##" ? "underline" : "bold";
|
|
40
|
+
blocks.push({ type: "heading", style, text: content });
|
|
41
|
+
lastExampleBlock = null;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (token === "p") {
|
|
45
|
+
blocks.push({ type: "paragraph", text: content });
|
|
46
|
+
lastExampleBlock = null;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (REI_PATTERN.test(token)) {
|
|
50
|
+
const block = { type: "example", japanese: content };
|
|
51
|
+
blocks.push(block);
|
|
52
|
+
lastExampleBlock = block;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (token === "trans") {
|
|
56
|
+
if (lastExampleBlock) {
|
|
57
|
+
lastExampleBlock.translation = content;
|
|
58
|
+
}
|
|
59
|
+
else if (__DEV__) {
|
|
60
|
+
console.warn(`[articleContent] transの直前にreiがありません: "${line}"`);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (token === "batu") {
|
|
65
|
+
blocks.push({ type: "incorrect", text: content });
|
|
66
|
+
lastExampleBlock = null;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (token === "maru") {
|
|
70
|
+
blocks.push({ type: "correct", text: content });
|
|
71
|
+
lastExampleBlock = null;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (__DEV__) {
|
|
75
|
+
console.warn(`[articleContent] 未知のトークンです: "${line}"`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return { title, blocks };
|
|
79
|
+
};
|
|
80
|
+
exports.parseArticleContent = parseArticleContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UnitList, ArticleList } from "@nakamura-123/types";
|
|
2
|
+
export interface ArticleListMissingUnitError {
|
|
3
|
+
chapterKey: number;
|
|
4
|
+
missingKeys: number[];
|
|
5
|
+
}
|
|
6
|
+
export declare const getArticleListMissingUnitKeys: (unitList: UnitList[], articleList: ArticleList[]) => ArticleListMissingUnitError[];
|
|
7
|
+
export declare const getArticleId: (articleKey: number) => string;
|
|
8
|
+
export declare const getDuplicateArticleKeys: (articleList: ArticleList[]) => number[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDuplicateArticleKeys = exports.getArticleId = exports.getArticleListMissingUnitKeys = void 0;
|
|
4
|
+
// articleListにエントリがある章について、その章のunitList.subの全keyが
|
|
5
|
+
// type:"unit"として使われているかを検証する。未定義の章はチェック対象外(フォールバック仕様のため)。
|
|
6
|
+
const getArticleListMissingUnitKeys = (unitList, articleList) => {
|
|
7
|
+
const errors = [];
|
|
8
|
+
articleList.forEach((entry) => {
|
|
9
|
+
const chapter = unitList.find((u) => u.key === entry.key);
|
|
10
|
+
if (!chapter)
|
|
11
|
+
return;
|
|
12
|
+
const usedUnitKeys = new Set(entry.items
|
|
13
|
+
.filter((item) => item.type === "unit")
|
|
14
|
+
.map((item) => item.key));
|
|
15
|
+
const missingKeys = chapter.sub
|
|
16
|
+
.map((s) => s.key)
|
|
17
|
+
.filter((key) => !usedUnitKeys.has(key));
|
|
18
|
+
if (missingKeys.length > 0)
|
|
19
|
+
errors.push({ chapterKey: entry.key, missingKeys });
|
|
20
|
+
});
|
|
21
|
+
return errors;
|
|
22
|
+
};
|
|
23
|
+
exports.getArticleListMissingUnitKeys = getArticleListMissingUnitKeys;
|
|
24
|
+
// article.keyはunitList.subのkeyと異なり、articleList全体でグローバルに一意である必要がある
|
|
25
|
+
// (章をまたいで記事を移動しても付箋・既読データが引き継がれるようにするため)。
|
|
26
|
+
const getArticleId = (articleKey) => String(articleKey);
|
|
27
|
+
exports.getArticleId = getArticleId;
|
|
28
|
+
// articleList全体でarticle keyが重複していないかを検証する
|
|
29
|
+
const getDuplicateArticleKeys = (articleList) => {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
const duplicates = new Set();
|
|
32
|
+
articleList.forEach((entry) => {
|
|
33
|
+
entry.items
|
|
34
|
+
.filter((item) => item.type === "article")
|
|
35
|
+
.forEach((item) => {
|
|
36
|
+
if (seen.has(item.key))
|
|
37
|
+
duplicates.add(item.key);
|
|
38
|
+
seen.add(item.key);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return [...duplicates];
|
|
42
|
+
};
|
|
43
|
+
exports.getDuplicateArticleKeys = getDuplicateArticleKeys;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import HomePage from "./page/HomePage";
|
|
2
2
|
import BasicPage from "./page/BasicPage";
|
|
3
|
+
import ArticlePage from "./page/ArticlePage";
|
|
4
|
+
import ArticleDetail from "./page/ArticleDetail";
|
|
3
5
|
import TestPage from "./page/TestPage";
|
|
4
6
|
import BootPage from "./page/BootPage";
|
|
5
7
|
import QuizSetupPage from "./page/QuizSetupPage";
|
|
@@ -21,6 +23,7 @@ import GuidePage from "./page/GuidePage";
|
|
|
21
23
|
import InformationPage from "./page/InformationPage";
|
|
22
24
|
import * as basicHooks from "./hooks/basicHook";
|
|
23
25
|
import * as quizHooks from "./hooks/quizHook";
|
|
26
|
+
import * as articleListFnc from "./functions/articleListFnc";
|
|
24
27
|
import ReturnBtn from "./quiz/setting/ReturnBtn";
|
|
25
28
|
import TransBtn from "./component/SettingBtns/TransBtn";
|
|
26
|
-
export { HomePage, BasicPage, TestPage, BootPage, QuizSetupPage, QuizPage, QuizSettingPage, ResultPage, GradePage, HistoryPage, ImgZoom, BadgePage, GetBadgePage, SettingPage, ReportPage, CoinPage, FAQPage, OnlineInputPage, JDetailSettingPage, GuidePage, InformationPage, basicHooks, quizHooks, ReturnBtn, TransBtn, };
|
|
29
|
+
export { HomePage, BasicPage, ArticlePage, ArticleDetail, TestPage, BootPage, QuizSetupPage, QuizPage, QuizSettingPage, ResultPage, GradePage, HistoryPage, ImgZoom, BadgePage, GetBadgePage, SettingPage, ReportPage, CoinPage, FAQPage, OnlineInputPage, JDetailSettingPage, GuidePage, InformationPage, basicHooks, quizHooks, articleListFnc, ReturnBtn, TransBtn, };
|
package/dist/index.js
CHANGED
|
@@ -26,11 +26,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.TransBtn = exports.ReturnBtn = exports.quizHooks = exports.basicHooks = exports.InformationPage = exports.GuidePage = exports.JDetailSettingPage = exports.OnlineInputPage = exports.FAQPage = exports.CoinPage = exports.ReportPage = exports.SettingPage = exports.GetBadgePage = exports.BadgePage = exports.ImgZoom = exports.HistoryPage = exports.GradePage = exports.ResultPage = exports.QuizSettingPage = exports.QuizPage = exports.QuizSetupPage = exports.BootPage = exports.TestPage = exports.BasicPage = exports.HomePage = void 0;
|
|
29
|
+
exports.TransBtn = exports.ReturnBtn = exports.articleListFnc = exports.quizHooks = exports.basicHooks = exports.InformationPage = exports.GuidePage = exports.JDetailSettingPage = exports.OnlineInputPage = exports.FAQPage = exports.CoinPage = exports.ReportPage = exports.SettingPage = exports.GetBadgePage = exports.BadgePage = exports.ImgZoom = exports.HistoryPage = exports.GradePage = exports.ResultPage = exports.QuizSettingPage = exports.QuizPage = exports.QuizSetupPage = exports.BootPage = exports.TestPage = exports.ArticleDetail = exports.ArticlePage = exports.BasicPage = exports.HomePage = void 0;
|
|
30
30
|
const HomePage_1 = __importDefault(require("./page/HomePage"));
|
|
31
31
|
exports.HomePage = HomePage_1.default;
|
|
32
32
|
const BasicPage_1 = __importDefault(require("./page/BasicPage"));
|
|
33
33
|
exports.BasicPage = BasicPage_1.default;
|
|
34
|
+
const ArticlePage_1 = __importDefault(require("./page/ArticlePage"));
|
|
35
|
+
exports.ArticlePage = ArticlePage_1.default;
|
|
36
|
+
const ArticleDetail_1 = __importDefault(require("./page/ArticleDetail"));
|
|
37
|
+
exports.ArticleDetail = ArticleDetail_1.default;
|
|
34
38
|
const TestPage_1 = __importDefault(require("./page/TestPage"));
|
|
35
39
|
exports.TestPage = TestPage_1.default;
|
|
36
40
|
const BootPage_1 = __importDefault(require("./page/BootPage"));
|
|
@@ -74,6 +78,9 @@ const basicHooks = __importStar(require("./hooks/basicHook"));
|
|
|
74
78
|
exports.basicHooks = basicHooks;
|
|
75
79
|
const quizHooks = __importStar(require("./hooks/quizHook"));
|
|
76
80
|
exports.quizHooks = quizHooks;
|
|
81
|
+
// functions
|
|
82
|
+
const articleListFnc = __importStar(require("./functions/articleListFnc"));
|
|
83
|
+
exports.articleListFnc = articleListFnc;
|
|
77
84
|
// components
|
|
78
85
|
const ReturnBtn_1 = __importDefault(require("./quiz/setting/ReturnBtn"));
|
|
79
86
|
exports.ReturnBtn = ReturnBtn_1.default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StackNavigationProp } from "@react-navigation/stack";
|
|
3
|
+
import { Nav } from "@nakamura-123/types";
|
|
4
|
+
type ArticleDetailProps = {
|
|
5
|
+
navigation: StackNavigationProp<Nav.RootStackParamList>;
|
|
6
|
+
route: {
|
|
7
|
+
params: Nav.RootStackParamList["ArticleDetail"];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare const ArticleDetail: React.FC<ArticleDetailProps>;
|
|
11
|
+
export default ArticleDetail;
|
|
@@ -0,0 +1,197 @@
|
|
|
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_redux_1 = require("react-redux");
|
|
32
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
33
|
+
const common_1 = require("@nakamura-123/common");
|
|
34
|
+
const stores_1 = require("@nakamura-123/stores");
|
|
35
|
+
const ArticleContentView_1 = __importDefault(require("../component/Article/ArticleContentView"));
|
|
36
|
+
const articleContentFnc_1 = require("../functions/articleContentFnc");
|
|
37
|
+
const articleListFnc_1 = require("../functions/articleListFnc");
|
|
38
|
+
const ArticleDetail = ({ navigation, route }) => {
|
|
39
|
+
const { subject, chapterKey, articleId, title } = route.params;
|
|
40
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
41
|
+
const isRead = (0, react_redux_1.useSelector)((state) => { var _a; return !!((_a = state.setting.articles[articleId]) === null || _a === void 0 ? void 0 : _a.isRead); });
|
|
42
|
+
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; });
|
|
43
|
+
const rawContent = (0, react_redux_1.useSelector)((state) => state.app.articleContents[articleId]);
|
|
44
|
+
const articleList = (0, react_redux_1.useSelector)((state) => state.app.articleList);
|
|
45
|
+
const unitList = (0, react_redux_1.useSelector)((state) => state.app.unitList);
|
|
46
|
+
// 未読の場合のみ既読を記録する(既読済みなら毎回AsyncStorageへ書き込まない)
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
if (isRead)
|
|
49
|
+
return;
|
|
50
|
+
dispatch({ type: "setting/markArticleAsRead", payload: { articleId } });
|
|
51
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
52
|
+
}, [articleId, isRead]);
|
|
53
|
+
// この記事を開いたことを記録する(単元一覧の赤枠と排他表示するため)
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
dispatch({
|
|
56
|
+
type: "setting/saveArticlePreSelect",
|
|
57
|
+
payload: { subject, articleId },
|
|
58
|
+
});
|
|
59
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
60
|
+
}, [subject, articleId]);
|
|
61
|
+
const handleToggleFlag = () => {
|
|
62
|
+
dispatch({ type: "setting/toggleArticleFlag", payload: { articleId } });
|
|
63
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
64
|
+
};
|
|
65
|
+
// articleListの並び順で「次の要素」を見て末尾ボタンの内容を決める
|
|
66
|
+
const chapterEntry = articleList.find((entry) => entry.key === chapterKey);
|
|
67
|
+
const itemIndex = chapterEntry === null || chapterEntry === void 0 ? void 0 : chapterEntry.items.findIndex((item) => item.type === "article" && item.key === Number(articleId));
|
|
68
|
+
const nextItem = chapterEntry && itemIndex !== undefined && itemIndex !== -1
|
|
69
|
+
? chapterEntry.items[itemIndex + 1]
|
|
70
|
+
: undefined;
|
|
71
|
+
const handleStartQuiz = () => {
|
|
72
|
+
if (!nextItem || nextItem.type !== "unit")
|
|
73
|
+
return;
|
|
74
|
+
const chapter = unitList.find((u) => u.key === chapterKey);
|
|
75
|
+
const subUnit = chapter === null || chapter === void 0 ? void 0 : chapter.sub.find((s) => s.key === nextItem.key);
|
|
76
|
+
if (!chapter || !subUnit)
|
|
77
|
+
return;
|
|
78
|
+
const selected = {
|
|
79
|
+
type: "unit",
|
|
80
|
+
subject,
|
|
81
|
+
category: chapterKey,
|
|
82
|
+
lesson: Object.assign(Object.assign({}, subUnit), { title: `${chapter.label} ${subUnit.title}` }),
|
|
83
|
+
};
|
|
84
|
+
dispatch(stores_1.quizAction.setLesson(selected));
|
|
85
|
+
navigation.replace("QuizSetup");
|
|
86
|
+
};
|
|
87
|
+
const handleGoToNextArticle = () => {
|
|
88
|
+
if (!nextItem || nextItem.type !== "article")
|
|
89
|
+
return;
|
|
90
|
+
navigation.replace("ArticleDetail", {
|
|
91
|
+
subject,
|
|
92
|
+
chapterKey,
|
|
93
|
+
articleId: (0, articleListFnc_1.getArticleId)(nextItem.key),
|
|
94
|
+
title: nextItem.title,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
return (<react_native_1.ScrollView style={styles.container} contentContainerStyle={styles.content}>
|
|
98
|
+
{rawContent ? (<ArticleContentView_1.default content={(0, articleContentFnc_1.parseArticleContent)(rawContent)}/>) : (<react_native_1.View style={styles.placeholder}>
|
|
99
|
+
<common_1.MyText fsize="lg" weight={700} style={styles.placeholderTitle}>
|
|
100
|
+
{title}
|
|
101
|
+
</common_1.MyText>
|
|
102
|
+
<common_1.MyText fsize="sm" color="ltBlack">
|
|
103
|
+
この記事は準備中です。
|
|
104
|
+
</common_1.MyText>
|
|
105
|
+
</react_native_1.View>)}
|
|
106
|
+
|
|
107
|
+
{(nextItem === null || nextItem === void 0 ? void 0 : nextItem.type) === "unit" && (<common_1.PressAnimatedWrap onPress={handleStartQuiz} style={styles.ctaButton}>
|
|
108
|
+
<common_1.MyText fsize="sm" weight={700}>
|
|
109
|
+
この単元の問題を解く
|
|
110
|
+
</common_1.MyText>
|
|
111
|
+
</common_1.PressAnimatedWrap>)}
|
|
112
|
+
{(nextItem === null || nextItem === void 0 ? void 0 : nextItem.type) === "article" && (<common_1.PressAnimatedWrap onPress={handleGoToNextArticle} style={styles.ctaButton}>
|
|
113
|
+
<common_1.MyText fsize="sm" weight={700} color="white">
|
|
114
|
+
次の解説へ
|
|
115
|
+
</common_1.MyText>
|
|
116
|
+
</common_1.PressAnimatedWrap>)}
|
|
117
|
+
|
|
118
|
+
<react_native_1.View style={styles.bottomRow}>
|
|
119
|
+
<common_1.PressAnimatedWrap onPress={handleToggleFlag} outerStyle={styles.bottomButtonOuter} style={styles.bottomButton}>
|
|
120
|
+
<common_1.Icon5 name="bookmark" size={16} color={flagColor ? "yellow" : "ltBlack"} solid={!!flagColor} style={styles.bottomButtonIcon}/>
|
|
121
|
+
<common_1.MyText fsize="sm" weight={700} color="text">
|
|
122
|
+
ふせん
|
|
123
|
+
</common_1.MyText>
|
|
124
|
+
</common_1.PressAnimatedWrap>
|
|
125
|
+
<common_1.PressAnimatedWrap onPress={() => navigation.goBack()} outerStyle={styles.bottomButtonOuter} style={styles.bottomButton}>
|
|
126
|
+
<common_1.Icon5 name="arrow-left" size={16} color="ltBlack" style={styles.bottomButtonIcon}/>
|
|
127
|
+
<common_1.MyText fsize="sm" weight={700} color="text">
|
|
128
|
+
一覧に戻る
|
|
129
|
+
</common_1.MyText>
|
|
130
|
+
</common_1.PressAnimatedWrap>
|
|
131
|
+
</react_native_1.View>
|
|
132
|
+
|
|
133
|
+
<common_1.PressAnimatedWrap onPress={() => navigation.navigate("Report", {
|
|
134
|
+
articleInfo: { subject, chapterKey, articleId, title, rawContent },
|
|
135
|
+
})} style={styles.reportLink}>
|
|
136
|
+
<common_1.Icon5 name="envelope" size={14} color="ltBlack" style={styles.bottomButtonIcon}/>
|
|
137
|
+
<common_1.MyText fsize="xs" color="ltBlack">
|
|
138
|
+
運営に報告する
|
|
139
|
+
</common_1.MyText>
|
|
140
|
+
</common_1.PressAnimatedWrap>
|
|
141
|
+
</react_native_1.ScrollView>);
|
|
142
|
+
};
|
|
143
|
+
const styles = react_native_1.StyleSheet.create({
|
|
144
|
+
container: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
backgroundColor: lib_1.colors.beige,
|
|
147
|
+
},
|
|
148
|
+
content: {
|
|
149
|
+
// padding: 10,
|
|
150
|
+
paddingBottom: 40,
|
|
151
|
+
},
|
|
152
|
+
placeholder: {
|
|
153
|
+
paddingVertical: 40,
|
|
154
|
+
},
|
|
155
|
+
placeholderTitle: {
|
|
156
|
+
marginBottom: 12,
|
|
157
|
+
},
|
|
158
|
+
ctaButton: {
|
|
159
|
+
marginHorizontal: 10,
|
|
160
|
+
height: 44,
|
|
161
|
+
marginTop: 10,
|
|
162
|
+
flexDirection: "row",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
justifyContent: "center",
|
|
165
|
+
borderRadius: 10,
|
|
166
|
+
backgroundColor: lib_1.colors.ltGreen,
|
|
167
|
+
},
|
|
168
|
+
bottomRow: {
|
|
169
|
+
marginHorizontal: 10,
|
|
170
|
+
flexDirection: "row",
|
|
171
|
+
marginTop: 10,
|
|
172
|
+
gap: 10,
|
|
173
|
+
},
|
|
174
|
+
bottomButtonOuter: {
|
|
175
|
+
flex: 1,
|
|
176
|
+
},
|
|
177
|
+
bottomButton: {
|
|
178
|
+
height: 38,
|
|
179
|
+
flexDirection: "row",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
justifyContent: "center",
|
|
182
|
+
borderRadius: 7,
|
|
183
|
+
borderWidth: 1,
|
|
184
|
+
borderColor: lib_1.colors.light,
|
|
185
|
+
backgroundColor: lib_1.colors.bkBeige,
|
|
186
|
+
},
|
|
187
|
+
bottomButtonIcon: {
|
|
188
|
+
marginRight: 8,
|
|
189
|
+
},
|
|
190
|
+
reportLink: {
|
|
191
|
+
marginTop: 16,
|
|
192
|
+
flexDirection: "row",
|
|
193
|
+
alignItems: "center",
|
|
194
|
+
justifyContent: "center",
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
exports.default = ArticleDetail;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StackNavigationProp } from "@react-navigation/stack";
|
|
3
|
+
import { Nav, Db } from "@nakamura-123/types";
|
|
4
|
+
interface Prop {
|
|
5
|
+
navigation: StackNavigationProp<Nav.RootStackParamList>;
|
|
6
|
+
subject: Db.SubjectInfo;
|
|
7
|
+
}
|
|
8
|
+
declare const ArticlePage: React.FC<Prop>;
|
|
9
|
+
export default ArticlePage;
|
|
@@ -0,0 +1,83 @@
|
|
|
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_redux_1 = require("react-redux");
|
|
32
|
+
const react_native_tab_view_1 = require("react-native-tab-view");
|
|
33
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
34
|
+
const ArticleContents_1 = __importDefault(require("../component/Article/ArticleContents"));
|
|
35
|
+
const QuizSaveData_1 = __importDefault(require("../quiz/save/QuizSaveData"));
|
|
36
|
+
const TabAnimeView_1 = __importDefault(require("../component/TabAnimeView"));
|
|
37
|
+
const ArticlePage = react_1.default.memo(({ navigation, subject }) => {
|
|
38
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
39
|
+
(0, react_1.useEffect)(() => {
|
|
40
|
+
dispatch({ type: "setting/setSelectedSubject", payload: subject.name });
|
|
41
|
+
}, []);
|
|
42
|
+
const categoryList = (0, react_redux_1.useSelector)((state) => state.app[subject.list]);
|
|
43
|
+
const activeIndex = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[subject.name].activeIndex);
|
|
44
|
+
// ラベルを取得
|
|
45
|
+
const labels = categoryList.map((category) => category.label + category.title);
|
|
46
|
+
const routeLists = labels.map((label, index) => ({
|
|
47
|
+
key: index.toString(),
|
|
48
|
+
title: label,
|
|
49
|
+
}));
|
|
50
|
+
const [routes] = (0, react_1.useState)(routeLists);
|
|
51
|
+
// タブの描画
|
|
52
|
+
const renderScene = ({ route, }) => {
|
|
53
|
+
const routeIndex = routes.findIndex((r) => r.key === route.key);
|
|
54
|
+
return (<TabAnimeView_1.default activeIndex={activeIndex}>
|
|
55
|
+
<ArticleContents_1.default navigation={navigation} subject={subject} index={routeIndex}/>
|
|
56
|
+
</TabAnimeView_1.default>);
|
|
57
|
+
};
|
|
58
|
+
const handleIndexChange = (newIndex) => {
|
|
59
|
+
dispatch({ type: "setting/changeTabIndex", payload: newIndex });
|
|
60
|
+
dispatch({ type: "setting/setScrollY", payload: 0 });
|
|
61
|
+
};
|
|
62
|
+
return (<react_native_1.View style={{ flex: 1 }}>
|
|
63
|
+
<react_native_tab_view_1.TabView navigationState={{ index: activeIndex, routes }} renderScene={renderScene} onIndexChange={handleIndexChange} initialLayout={{ width: react_native_1.Dimensions.get("window").width }} animationEnabled={false} renderTabBar={(props) => (<react_native_tab_view_1.TabBar {...props} activeColor={lib_1.colors.red} inactiveColor={lib_1.colors.ltBlack} scrollEnabled // スクロール可能にする
|
|
64
|
+
style={{
|
|
65
|
+
backgroundColor: lib_1.colors.beige,
|
|
66
|
+
}} contentContainerStyle={{ paddingLeft: 30 }} tabStyle={{ width: "auto" }} // タブ幅を調整
|
|
67
|
+
indicatorStyle={{
|
|
68
|
+
backgroundColor: lib_1.colors.red,
|
|
69
|
+
height: 3,
|
|
70
|
+
}}/>)}/>
|
|
71
|
+
<react_native_1.View style={styles.saveData}>
|
|
72
|
+
<QuizSaveData_1.default navigation={navigation} saveKey={subject.name}/>
|
|
73
|
+
</react_native_1.View>
|
|
74
|
+
</react_native_1.View>);
|
|
75
|
+
});
|
|
76
|
+
const styles = react_native_1.StyleSheet.create({
|
|
77
|
+
saveData: {
|
|
78
|
+
width: "100%",
|
|
79
|
+
position: "absolute",
|
|
80
|
+
bottom: 0,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
exports.default = ArticlePage;
|
package/dist/page/HomePage.js
CHANGED
|
@@ -49,7 +49,6 @@ const WaitingPayBanner_1 = __importDefault(require("../component/Coin/WaitingPay
|
|
|
49
49
|
const oldStorageFnc_1 = require("../functions/oldStorageFnc");
|
|
50
50
|
const OpeningMsg_1 = __importDefault(require("../component/Home/OpeningMsg"));
|
|
51
51
|
const TransBtn_1 = __importDefault(require("../component/SettingBtns/TransBtn"));
|
|
52
|
-
const CoinFnc_1 = require("../component/Coin/CoinFnc");
|
|
53
52
|
const MenuRectangle = ({ menu, navigation, }) => {
|
|
54
53
|
const { title, note, icon, color, link } = menu;
|
|
55
54
|
const handlePress = () => {
|
|
@@ -87,29 +86,6 @@ const HomePage = ({ menuLists, navigation, warningContent, }) => {
|
|
|
87
86
|
});
|
|
88
87
|
fetchOldData();
|
|
89
88
|
}, [showLoadOldData, settingAsyncLoaded, language]);
|
|
90
|
-
// 🔧 修正6: アプリ起動時にKeychainから購入情報を復元
|
|
91
|
-
(0, react_1.useEffect)(() => {
|
|
92
|
-
if (!settingAsyncLoaded)
|
|
93
|
-
return;
|
|
94
|
-
const restorePurchaseState = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
-
try {
|
|
96
|
-
const receipts = yield stores_1.coinStorage.loadPurchasedItems();
|
|
97
|
-
if (receipts && receipts.length > 0) {
|
|
98
|
-
console.log(`HomePage起動時: ${receipts.length}件の購入情報を復元します`);
|
|
99
|
-
receipts.forEach((receipt) => {
|
|
100
|
-
dispatch((0, CoinFnc_1.updateAllFreeState)(receipt));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
console.log("HomePage起動時: 購入情報が見つかりませんでした");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
console.error("購入情報の読み込みに失敗しました:", error);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
restorePurchaseState();
|
|
112
|
-
}, [settingAsyncLoaded]);
|
|
113
89
|
// これはデバッグ用です。
|
|
114
90
|
(0, react_1.useEffect)(() => {
|
|
115
91
|
if (__DEV__)
|
|
@@ -2,6 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { Nav } from "@nakamura-123/types";
|
|
3
3
|
interface ResultPageProps {
|
|
4
4
|
navigation: Nav.NavigationProp<"QuizSetting">;
|
|
5
|
+
route: {
|
|
6
|
+
params: Nav.RootStackParamList["QuizSetting"];
|
|
7
|
+
};
|
|
5
8
|
}
|
|
6
9
|
declare const QuizSetting: React.FC<ResultPageProps>;
|
|
7
10
|
export default QuizSetting;
|
|
@@ -36,13 +36,18 @@ const QuizOptionSelector_1 = __importDefault(require("../component/SettingBtns/Q
|
|
|
36
36
|
const MyTextqqyy_1 = __importDefault(require("../quiz/common/MyTextqqyy"));
|
|
37
37
|
const common_1 = require("@nakamura-123/common");
|
|
38
38
|
const react_redux_2 = require("react-redux");
|
|
39
|
-
const QuizSetting = ({}) => {
|
|
39
|
+
const QuizSetting = ({ route }) => {
|
|
40
|
+
var _a;
|
|
40
41
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
41
42
|
const isJLPT = (0, react_redux_2.useSelector)((state) => state.app.appSetting.setting.appSystem) === "JLPT";
|
|
42
43
|
const { t } = (0, common_1.useDrillTranslation)();
|
|
43
|
-
const
|
|
44
|
+
const isArticleScope = ((_a = route === null || route === void 0 ? void 0 : route.params) === null || _a === void 0 ? void 0 : _a.scope) === "article";
|
|
45
|
+
const allOptions = isJLPT
|
|
44
46
|
? lib_1.inQuizOption.jInQuizOption
|
|
45
47
|
: lib_1.inQuizOption.dInQuizOption;
|
|
48
|
+
const options = isArticleScope
|
|
49
|
+
? allOptions.filter((O) => O.type === "fsize" || O.type === "fWeight")
|
|
50
|
+
: allOptions;
|
|
46
51
|
// タイトル
|
|
47
52
|
(0, react_1.useEffect)(() => {
|
|
48
53
|
return () => {
|
|
@@ -50,9 +55,9 @@ const QuizSetting = ({}) => {
|
|
|
50
55
|
};
|
|
51
56
|
}, []);
|
|
52
57
|
return (<react_native_gesture_handler_1.ScrollView style={styles.wrapper}>
|
|
53
|
-
<react_native_1.View style={styles.sampleBox}>
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
{!isArticleScope && (<react_native_1.View style={styles.sampleBox}>
|
|
59
|
+
<MyTextqqyy_1.default>{t("quiz.sample")}</MyTextqqyy_1.default>
|
|
60
|
+
</react_native_1.View>)}
|
|
56
61
|
{options.map((O, i) => (<QuizOptionSelector_1.default key={i} type={O.type} options={O.options}/>))}
|
|
57
62
|
</react_native_gesture_handler_1.ScrollView>);
|
|
58
63
|
};
|
|
@@ -3,6 +3,9 @@ import { StackNavigationProp } from "@react-navigation/stack";
|
|
|
3
3
|
import { Nav } from "@nakamura-123/types";
|
|
4
4
|
type Props = {
|
|
5
5
|
navigation: StackNavigationProp<Nav.RootStackParamList>;
|
|
6
|
+
route: {
|
|
7
|
+
params: Nav.RootStackParamList["Report"];
|
|
8
|
+
};
|
|
6
9
|
};
|
|
7
10
|
declare const ReportPage: React.FC<Props>;
|
|
8
11
|
export default ReportPage;
|
package/dist/page/ReportPage.js
CHANGED
|
@@ -39,7 +39,9 @@ const common_1 = require("@nakamura-123/common");
|
|
|
39
39
|
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
|
-
const ReportPage = ({ navigation }) => {
|
|
42
|
+
const ReportPage = ({ navigation, route }) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const articleInfo = (_a = route === null || route === void 0 ? void 0 : route.params) === null || _a === void 0 ? void 0 : _a.articleInfo;
|
|
43
45
|
const { t } = (0, common_1.useDrillTranslation)();
|
|
44
46
|
const [type, setType] = (0, react_1.useState)(null);
|
|
45
47
|
const [mail, setMail] = (0, react_1.useState)("");
|
|
@@ -73,6 +75,10 @@ const ReportPage = ({ navigation }) => {
|
|
|
73
75
|
quizTitle: selectedTitle,
|
|
74
76
|
storeSetting,
|
|
75
77
|
errorLogs,
|
|
78
|
+
articleId: articleInfo === null || articleInfo === void 0 ? void 0 : articleInfo.articleId,
|
|
79
|
+
articleTitle: articleInfo === null || articleInfo === void 0 ? void 0 : articleInfo.title,
|
|
80
|
+
articleChapterKey: articleInfo === null || articleInfo === void 0 ? void 0 : articleInfo.chapterKey,
|
|
81
|
+
articleContent: articleInfo === null || articleInfo === void 0 ? void 0 : articleInfo.rawContent,
|
|
76
82
|
});
|
|
77
83
|
if (send) {
|
|
78
84
|
react_native_1.Alert.alert(t("report.msg.recievedTitle"), t("report.msg.recieved"), [
|