@nakamura-123/pages 1.1.26 → 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/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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StackNavigationProp } from "@react-navigation/stack";
|
|
3
|
+
import { Nav, Db } from "@nakamura-123/types";
|
|
4
|
+
interface ArticleCategoryListProps {
|
|
5
|
+
navigation: StackNavigationProp<Nav.RootStackParamList>;
|
|
6
|
+
topSubject: Db.SubjectInfo;
|
|
7
|
+
index: number;
|
|
8
|
+
}
|
|
9
|
+
declare const ArticleCategoryList: React.FC<ArticleCategoryListProps>;
|
|
10
|
+
export default ArticleCategoryList;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const react_redux_1 = require("react-redux");
|
|
9
|
+
const common_1 = require("@nakamura-123/common");
|
|
10
|
+
const stores_1 = require("@nakamura-123/stores");
|
|
11
|
+
const SubCategoryLeft_1 = __importDefault(require("../Basic/SubCategoryLeft"));
|
|
12
|
+
const tagFncD_1 = require("../../functions/tagFncD");
|
|
13
|
+
const Tag5s_1 = __importDefault(require("../Tag5s"));
|
|
14
|
+
const createQuizFncD_1 = require("../../functions/createQuizFncD");
|
|
15
|
+
const quizActionHook_1 = require("../../hooks/quizActionHook");
|
|
16
|
+
const basicHook_1 = require("../../hooks/basicHook");
|
|
17
|
+
const createQuizFncJ_1 = require("../../functions/createQuizFncJ");
|
|
18
|
+
const tagFncJ_1 = require("../../functions/tagFncJ");
|
|
19
|
+
const articleListFnc_1 = require("../../functions/articleListFnc");
|
|
20
|
+
const ArticleRow_1 = __importDefault(require("./ArticleRow"));
|
|
21
|
+
const ArticleCategoryList = ({ navigation, topSubject, index, }) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
24
|
+
// Redux states
|
|
25
|
+
const categoryList = (0, react_redux_1.useSelector)((state) => state.app[topSubject.list]);
|
|
26
|
+
const articleList = (0, react_redux_1.useSelector)((state) => state.app.articleList);
|
|
27
|
+
const articles = (0, react_redux_1.useSelector)((state) => state.setting.articles);
|
|
28
|
+
const preSelect = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[topSubject.name].preSelect);
|
|
29
|
+
const preSelectArticle = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[topSubject.name].preSelectArticle);
|
|
30
|
+
const outOfYearRange = (0, react_redux_1.useSelector)((state) => state.quizCfg.startCfg.outOfYearRange);
|
|
31
|
+
const startCfg = (0, react_redux_1.useSelector)((state) => state.quizCfg.startCfg);
|
|
32
|
+
// Derived states
|
|
33
|
+
const selectedList = categoryList[index];
|
|
34
|
+
const selectKey = selectedList.key;
|
|
35
|
+
const subCategories = (_a = selectedList.sub) !== null && _a !== void 0 ? _a : [];
|
|
36
|
+
// この章のarticleList定義(未登録の章はunitカードのみのフォールバック)
|
|
37
|
+
const articleEntry = articleList.find((a) => a.key === selectKey);
|
|
38
|
+
const QuestionDBInfo = (0, basicHook_1.useGetQuestionQuery)();
|
|
39
|
+
const useStartQuiz = (0, quizActionHook_1.useStartQuizAction)();
|
|
40
|
+
const getLessonTitle = (index) => {
|
|
41
|
+
if (topSubject.type === "unit")
|
|
42
|
+
return `${selectedList.label} ${subCategories[index].title}`;
|
|
43
|
+
return `${selectedList.title} ${subCategories[index].title}`;
|
|
44
|
+
};
|
|
45
|
+
// 課金ロック(章単位。articleの解放状態にもそのまま適用する)
|
|
46
|
+
const isLocked = common_1.commonHook.useIsLocked(topSubject.type, selectKey);
|
|
47
|
+
// # クイズ開始前の共通処理
|
|
48
|
+
const handleSetLesson = (index) => {
|
|
49
|
+
const lesson = Object.assign(Object.assign({}, subCategories[index]), { title: getLessonTitle(index) });
|
|
50
|
+
const selected = {
|
|
51
|
+
subject: topSubject.name,
|
|
52
|
+
type: topSubject.type,
|
|
53
|
+
tagName: topSubject.tag,
|
|
54
|
+
system: topSubject.system,
|
|
55
|
+
category: selectKey,
|
|
56
|
+
lesson,
|
|
57
|
+
};
|
|
58
|
+
dispatch(stores_1.quizAction.setLesson(selected));
|
|
59
|
+
return selected;
|
|
60
|
+
};
|
|
61
|
+
// # セットアップページへ遷移
|
|
62
|
+
const handleSubCategory = (index) => {
|
|
63
|
+
if (isLocked)
|
|
64
|
+
navigation.navigate("Coin");
|
|
65
|
+
else {
|
|
66
|
+
handleSetLesson(index);
|
|
67
|
+
navigation.navigate("QuizSetup");
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// ### 長押しでクイズ開始
|
|
71
|
+
const handleLongPress = (index) => {
|
|
72
|
+
if (isLocked) {
|
|
73
|
+
navigation.navigate("Coin");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const selected = handleSetLesson(index);
|
|
77
|
+
if (!selected)
|
|
78
|
+
return;
|
|
79
|
+
const { system, query } = QuestionDBInfo;
|
|
80
|
+
const quizList = system === "JLPT"
|
|
81
|
+
? (0, createQuizFncJ_1.getBasicQuizListJ)(query, startCfg, selected)
|
|
82
|
+
: (0, createQuizFncD_1.getBasicQuizList)(query, startCfg, selected);
|
|
83
|
+
const { subject } = selected;
|
|
84
|
+
dispatch(stores_1.setAction.saveBasicPreSelect({
|
|
85
|
+
subject: topSubject.name,
|
|
86
|
+
category: selectKey,
|
|
87
|
+
lessonKey: subCategories[index].key,
|
|
88
|
+
}));
|
|
89
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
90
|
+
const isExistQuiz = useStartQuiz(subject, quizList);
|
|
91
|
+
if (!isExistQuiz)
|
|
92
|
+
return;
|
|
93
|
+
navigation.navigate("Quiz");
|
|
94
|
+
};
|
|
95
|
+
// article行タップ時の遷移(本文レンダリングは未実装の仮画面)
|
|
96
|
+
const handleArticle = (articleId, title) => {
|
|
97
|
+
if (isLocked) {
|
|
98
|
+
navigation.navigate("Coin");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
navigation.navigate("ArticleDetail", {
|
|
102
|
+
subject: topSubject.name,
|
|
103
|
+
chapterKey: selectKey,
|
|
104
|
+
articleId,
|
|
105
|
+
title,
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
// 付箋(手動)を循環させる
|
|
109
|
+
const handleToggleFlag = (articleId) => {
|
|
110
|
+
dispatch({ type: "setting/toggleArticleFlag", payload: { articleId } });
|
|
111
|
+
dispatch(stores_1.settingStorage.saveSetting());
|
|
112
|
+
};
|
|
113
|
+
// # タグを取得する関数を選ぶ
|
|
114
|
+
const getTagFunctions = {
|
|
115
|
+
unit: tagFncD_1.getUnitSubTagLevelCnts,
|
|
116
|
+
year: tagFncD_1.getYearSubTagLevelCnts,
|
|
117
|
+
};
|
|
118
|
+
const getTagFnc = getTagFunctions[topSubject.type];
|
|
119
|
+
const renderUnitCard = (key, title, i) => {
|
|
120
|
+
const { system, query } = QuestionDBInfo;
|
|
121
|
+
const subTags = system === "JLPT"
|
|
122
|
+
? (0, tagFncJ_1.getUnitSubTagLevelCntsJ)(query, selectKey, key, topSubject.tag)
|
|
123
|
+
: getTagFnc(query, selectKey, key, outOfYearRange);
|
|
124
|
+
const isPreSelect = !preSelectArticle &&
|
|
125
|
+
preSelect.category === selectKey &&
|
|
126
|
+
preSelect.lessonKey === key;
|
|
127
|
+
return (<common_1.RectangleCard key={`unit-${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)}/>);
|
|
128
|
+
};
|
|
129
|
+
// articleListに章の定義が無い場合は、従来通りunitカードのみ表示
|
|
130
|
+
if (!articleEntry) {
|
|
131
|
+
return (<react_native_1.View style={{ flex: 1 }}>
|
|
132
|
+
{subCategories.map(({ key, title }, i) => renderUnitCard(key, title, i))}
|
|
133
|
+
</react_native_1.View>);
|
|
134
|
+
}
|
|
135
|
+
return (<react_native_1.View style={{ flex: 1 }}>
|
|
136
|
+
{articleEntry.items.map((item) => {
|
|
137
|
+
var _a;
|
|
138
|
+
if (item.type === "article") {
|
|
139
|
+
const articleId = (0, articleListFnc_1.getArticleId)(item.key);
|
|
140
|
+
const articleState = articles[articleId];
|
|
141
|
+
return (<ArticleRow_1.default key={`article-${item.key}`} title={item.title} size={item.size} isRead={!!(articleState === null || articleState === void 0 ? void 0 : articleState.isRead)} flagColor={(_a = articleState === null || articleState === void 0 ? void 0 : articleState.flag) !== null && _a !== void 0 ? _a : null} borderColor={(preSelectArticle === null || preSelectArticle === void 0 ? void 0 : preSelectArticle.articleId) === articleId ? "ltRed" : undefined} onPress={() => handleArticle(articleId, item.title)} onToggleFlag={() => handleToggleFlag(articleId)}/>);
|
|
142
|
+
}
|
|
143
|
+
const i = subCategories.findIndex((s) => s.key === item.key);
|
|
144
|
+
if (i === -1)
|
|
145
|
+
return null;
|
|
146
|
+
return renderUnitCard(subCategories[i].key, subCategories[i].title, i);
|
|
147
|
+
})}
|
|
148
|
+
</react_native_1.View>);
|
|
149
|
+
};
|
|
150
|
+
const styles = react_native_1.StyleSheet.create({
|
|
151
|
+
cardSpacing: {
|
|
152
|
+
marginBottom: 20,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
exports.default = ArticleCategoryList;
|
|
@@ -0,0 +1,246 @@
|
|
|
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 react_redux_1 = require("react-redux");
|
|
29
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
30
|
+
const common_1 = require("@nakamura-123/common");
|
|
31
|
+
const articleContentFnc_1 = require("../../functions/articleContentFnc");
|
|
32
|
+
const isJudgmentBlock = (block) => (block === null || block === void 0 ? void 0 : block.type) === "incorrect" || (block === null || block === void 0 ? void 0 : block.type) === "correct";
|
|
33
|
+
const ArticleContentView = ({ content }) => {
|
|
34
|
+
let exampleCount = 0;
|
|
35
|
+
const userFsize = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fsize);
|
|
36
|
+
const userFWeight = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fWeight);
|
|
37
|
+
return (<react_native_1.View style={styles.container}>
|
|
38
|
+
<react_native_1.View style={styles.titleWrap}>
|
|
39
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xxxl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
|
|
40
|
+
{content.title}
|
|
41
|
+
</common_1.MyText>
|
|
42
|
+
</react_native_1.View>
|
|
43
|
+
<react_native_1.View style={styles.bodyWrap}>
|
|
44
|
+
{content.blocks.map((block, index) => {
|
|
45
|
+
if (block.type === "example")
|
|
46
|
+
exampleCount += 1;
|
|
47
|
+
let groupPosition;
|
|
48
|
+
if (isJudgmentBlock(block)) {
|
|
49
|
+
const hasPrev = isJudgmentBlock(content.blocks[index - 1]);
|
|
50
|
+
const hasNext = isJudgmentBlock(content.blocks[index + 1]);
|
|
51
|
+
groupPosition =
|
|
52
|
+
hasPrev && hasNext
|
|
53
|
+
? "middle"
|
|
54
|
+
: hasPrev
|
|
55
|
+
? "bottom"
|
|
56
|
+
: hasNext
|
|
57
|
+
? "top"
|
|
58
|
+
: "only";
|
|
59
|
+
}
|
|
60
|
+
return (<ArticleBlockView key={index} block={block} exampleNumber={exampleCount} groupPosition={groupPosition} userFsize={userFsize} userFWeight={userFWeight}/>);
|
|
61
|
+
})}
|
|
62
|
+
</react_native_1.View>
|
|
63
|
+
</react_native_1.View>);
|
|
64
|
+
};
|
|
65
|
+
const ArticleBlockView = ({ block, exampleNumber, groupPosition, userFsize, userFWeight, }) => {
|
|
66
|
+
const [isRevealed, setIsRevealed] = (0, react_1.useState)(false);
|
|
67
|
+
switch (block.type) {
|
|
68
|
+
case "heading":
|
|
69
|
+
if (block.style === "bar") {
|
|
70
|
+
return (<react_native_1.View style={styles.headingBarRow}>
|
|
71
|
+
<react_native_1.View style={styles.headingBar}/>
|
|
72
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("xxl", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
|
|
73
|
+
{block.text}
|
|
74
|
+
</common_1.MyText>
|
|
75
|
+
</react_native_1.View>);
|
|
76
|
+
}
|
|
77
|
+
if (block.style === "underline") {
|
|
78
|
+
return (<react_native_1.View style={styles.headingUnderline}>
|
|
79
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("lg", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="black">
|
|
80
|
+
{block.text}
|
|
81
|
+
</common_1.MyText>
|
|
82
|
+
</react_native_1.View>);
|
|
83
|
+
}
|
|
84
|
+
return (<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("lg", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} color="gray" style={styles.headingBold}>
|
|
85
|
+
{block.text}
|
|
86
|
+
</common_1.MyText>);
|
|
87
|
+
case "paragraph":
|
|
88
|
+
return (<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.paragraph}>
|
|
89
|
+
{block.text}
|
|
90
|
+
</common_1.MyText>);
|
|
91
|
+
case "example":
|
|
92
|
+
return (<react_native_1.View style={styles.exampleBox}>
|
|
93
|
+
<react_native_1.View style={styles.exampleTop}>
|
|
94
|
+
<common_1.MyText fsize="sm" weight={700} color="green">
|
|
95
|
+
{String(exampleNumber).padStart(2, "0")}
|
|
96
|
+
</common_1.MyText>
|
|
97
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.exampleText}>
|
|
98
|
+
{block.japanese}
|
|
99
|
+
</common_1.MyText>
|
|
100
|
+
</react_native_1.View>
|
|
101
|
+
{block.translation && (<react_native_1.TouchableOpacity onPress={() => setIsRevealed(!isRevealed)} style={styles.exampleBottom}>
|
|
102
|
+
{/* 非表示時もopacity:0で全幅描画し、訳文の実際の高さ分の領域を最初から確保する(アイコンの有無で幅が変わって高さがずれないよう、アイコンは重ねて表示する別レイヤーにする) */}
|
|
103
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} color="text" style={!isRevealed && styles.invisibleText}>
|
|
104
|
+
{block.translation}
|
|
105
|
+
</common_1.MyText>
|
|
106
|
+
{!isRevealed && (<react_native_1.View style={styles.exampleBottomOverlay}>
|
|
107
|
+
<common_1.Icon5 name="eye" size={14} color="ltBlack" style={styles.exampleBottomIcon}/>
|
|
108
|
+
<common_1.MyText fsize="xs" color="ltBlack">
|
|
109
|
+
タップして訳を表示
|
|
110
|
+
</common_1.MyText>
|
|
111
|
+
</react_native_1.View>)}
|
|
112
|
+
</react_native_1.TouchableOpacity>)}
|
|
113
|
+
</react_native_1.View>);
|
|
114
|
+
case "incorrect":
|
|
115
|
+
case "correct": {
|
|
116
|
+
const position = groupPosition !== null && groupPosition !== void 0 ? groupPosition : "only";
|
|
117
|
+
const isIncorrect = block.type === "incorrect";
|
|
118
|
+
return (<react_native_1.View style={[
|
|
119
|
+
styles.judgmentRow,
|
|
120
|
+
(position === "top" || position === "only") &&
|
|
121
|
+
styles.judgmentRowTopRadius,
|
|
122
|
+
(position === "bottom" || position === "only") &&
|
|
123
|
+
styles.judgmentRowBottomRadius,
|
|
124
|
+
(position === "middle" || position === "bottom") &&
|
|
125
|
+
styles.judgmentRowDivider,
|
|
126
|
+
position !== "bottom" &&
|
|
127
|
+
position !== "only" &&
|
|
128
|
+
styles.judgmentRowNoMargin,
|
|
129
|
+
]}>
|
|
130
|
+
<common_1.Icon5 name={isIncorrect ? "times" : "check"} size={14} color={isIncorrect ? "red" : "green"} style={styles.judgmentIcon}/>
|
|
131
|
+
<common_1.MyText fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} color="text" style={styles.judgmentText}>
|
|
132
|
+
{block.text}
|
|
133
|
+
</common_1.MyText>
|
|
134
|
+
</react_native_1.View>);
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const styles = react_native_1.StyleSheet.create({
|
|
141
|
+
container: {
|
|
142
|
+
// marginHorizontal: -20,
|
|
143
|
+
},
|
|
144
|
+
titleWrap: {
|
|
145
|
+
backgroundColor: lib_1.colors.beige,
|
|
146
|
+
paddingHorizontal: 10,
|
|
147
|
+
paddingTop: 40,
|
|
148
|
+
paddingBottom: 16,
|
|
149
|
+
},
|
|
150
|
+
bodyWrap: {
|
|
151
|
+
backgroundColor: lib_1.colors.bkBeige,
|
|
152
|
+
paddingHorizontal: 10,
|
|
153
|
+
paddingTop: 16,
|
|
154
|
+
paddingBottom: 20,
|
|
155
|
+
},
|
|
156
|
+
headingBarRow: {
|
|
157
|
+
flexDirection: "row",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
marginTop: 32,
|
|
160
|
+
marginBottom: 12,
|
|
161
|
+
},
|
|
162
|
+
headingBar: {
|
|
163
|
+
width: 4,
|
|
164
|
+
height: 18,
|
|
165
|
+
backgroundColor: lib_1.colors.green,
|
|
166
|
+
marginRight: 11,
|
|
167
|
+
},
|
|
168
|
+
headingUnderline: {
|
|
169
|
+
alignSelf: "flex-start",
|
|
170
|
+
marginTop: 24,
|
|
171
|
+
marginBottom: 12,
|
|
172
|
+
paddingBottom: 4,
|
|
173
|
+
borderBottomWidth: 2,
|
|
174
|
+
borderBottomColor: lib_1.colors.text,
|
|
175
|
+
},
|
|
176
|
+
headingBold: {
|
|
177
|
+
marginTop: 16,
|
|
178
|
+
marginBottom: 6,
|
|
179
|
+
},
|
|
180
|
+
paragraph: {
|
|
181
|
+
marginBottom: 10,
|
|
182
|
+
lineHeight: 22,
|
|
183
|
+
},
|
|
184
|
+
exampleBox: {
|
|
185
|
+
borderRadius: 8,
|
|
186
|
+
marginBottom: 10,
|
|
187
|
+
overflow: "hidden",
|
|
188
|
+
borderWidth: 1,
|
|
189
|
+
borderColor: lib_1.colors.beige,
|
|
190
|
+
},
|
|
191
|
+
exampleTop: {
|
|
192
|
+
padding: 12,
|
|
193
|
+
paddingTop: 3,
|
|
194
|
+
},
|
|
195
|
+
exampleText: {
|
|
196
|
+
marginTop: 4,
|
|
197
|
+
},
|
|
198
|
+
exampleBottom: {
|
|
199
|
+
backgroundColor: lib_1.colors.beige,
|
|
200
|
+
padding: 12,
|
|
201
|
+
position: "relative",
|
|
202
|
+
},
|
|
203
|
+
invisibleText: {
|
|
204
|
+
opacity: 0,
|
|
205
|
+
},
|
|
206
|
+
exampleBottomOverlay: {
|
|
207
|
+
position: "absolute",
|
|
208
|
+
top: 12,
|
|
209
|
+
left: 12,
|
|
210
|
+
right: 12,
|
|
211
|
+
flexDirection: "row",
|
|
212
|
+
alignItems: "center",
|
|
213
|
+
},
|
|
214
|
+
exampleBottomIcon: {
|
|
215
|
+
marginRight: 8,
|
|
216
|
+
},
|
|
217
|
+
judgmentRow: {
|
|
218
|
+
flexDirection: "row",
|
|
219
|
+
alignItems: "center",
|
|
220
|
+
backgroundColor: lib_1.colors.beige,
|
|
221
|
+
padding: 10,
|
|
222
|
+
marginBottom: 8,
|
|
223
|
+
},
|
|
224
|
+
judgmentRowNoMargin: {
|
|
225
|
+
marginBottom: 0,
|
|
226
|
+
},
|
|
227
|
+
judgmentRowTopRadius: {
|
|
228
|
+
borderTopLeftRadius: 8,
|
|
229
|
+
borderTopRightRadius: 8,
|
|
230
|
+
},
|
|
231
|
+
judgmentRowBottomRadius: {
|
|
232
|
+
borderBottomLeftRadius: 8,
|
|
233
|
+
borderBottomRightRadius: 8,
|
|
234
|
+
},
|
|
235
|
+
judgmentRowDivider: {
|
|
236
|
+
borderTopWidth: 1,
|
|
237
|
+
borderTopColor: lib_1.colors.ltBlack,
|
|
238
|
+
},
|
|
239
|
+
judgmentIcon: {
|
|
240
|
+
marginRight: 8,
|
|
241
|
+
},
|
|
242
|
+
judgmentText: {
|
|
243
|
+
flex: 1,
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
exports.default = ArticleContentView;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
index: number;
|
|
8
|
+
}
|
|
9
|
+
declare const ArticleContents: React.FC<Prop>;
|
|
10
|
+
export default ArticleContents;
|
|
@@ -0,0 +1,132 @@
|
|
|
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_gesture_handler_1 = require("react-native-gesture-handler");
|
|
32
|
+
const react_redux_1 = require("react-redux");
|
|
33
|
+
const common_1 = require("@nakamura-123/common");
|
|
34
|
+
const stores_1 = require("@nakamura-123/stores");
|
|
35
|
+
const Badge5s_1 = __importDefault(require("../Basic/Badge5s"));
|
|
36
|
+
const TagBadge5s_1 = __importDefault(require("../TagBadge5s"));
|
|
37
|
+
const ArticleCategoryList_1 = __importDefault(require("./ArticleCategoryList"));
|
|
38
|
+
const MiniTestCard_1 = __importDefault(require("../Basic/MiniTestCard"));
|
|
39
|
+
const BasicSetting_1 = __importDefault(require("../Basic/BasicSetting"));
|
|
40
|
+
const Guide_1 = __importDefault(require("../Guide"));
|
|
41
|
+
const SelectedExamCnt_1 = __importDefault(require("../Basic/SelectedExamCnt"));
|
|
42
|
+
const BasicProgressBar_1 = __importDefault(require("../Basic/BasicProgressBar"));
|
|
43
|
+
const ArticleContents = ({ navigation, subject, index }) => {
|
|
44
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
45
|
+
const { t } = (0, common_1.useDrillTranslation)();
|
|
46
|
+
// // Reduxから必要なデータを一括取得
|
|
47
|
+
const categoryList = (0, react_redux_1.useSelector)((state) => state.app[subject.list]);
|
|
48
|
+
const activeIndex = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[subject.name].activeIndex);
|
|
49
|
+
const guide = (0, react_redux_1.useSelector)((state) => state.setting.guide);
|
|
50
|
+
const isShowGuide = guide.basicPageNav || guide.basicPageSwipe;
|
|
51
|
+
const guideName = guide.basicPageNav ? "basicPageNav" : "basicPageSwipe";
|
|
52
|
+
// 選択されたカテゴリー情報を取得
|
|
53
|
+
const selectedList = categoryList[index];
|
|
54
|
+
// カテゴリー名を計算
|
|
55
|
+
const categoryName = `${selectedList.label} ${selectedList.title}`.trim();
|
|
56
|
+
const selectKey = selectedList.key;
|
|
57
|
+
const categoryLabel = selectedList.label + selectedList.title;
|
|
58
|
+
const initScrollY = (0, react_redux_1.useSelector)((state) => state.setting.viewSet[subject.name].scrollY);
|
|
59
|
+
const scrollViewRef = (0, react_1.useRef)(null);
|
|
60
|
+
// 移動を監視
|
|
61
|
+
const [isReady, setIsReady] = (0, react_1.useState)(false);
|
|
62
|
+
(0, react_1.useEffect)(() => {
|
|
63
|
+
if (scrollViewRef.current)
|
|
64
|
+
setIsReady(true); // 準備完了
|
|
65
|
+
}, [scrollViewRef.current]); // scrollViewRef.current の変更を監視
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (isReady)
|
|
69
|
+
(_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ y: initScrollY, animated: false });
|
|
70
|
+
}, [isReady]);
|
|
71
|
+
const handleEndScroll = (event) => {
|
|
72
|
+
const scrollY = event.nativeEvent.contentOffset.y;
|
|
73
|
+
dispatch({ type: "setting/setScrollY", payload: scrollY });
|
|
74
|
+
};
|
|
75
|
+
// 全問スタートのハンドラー関数
|
|
76
|
+
const isLocked = common_1.commonHook.useIsLocked(subject.type, selectKey);
|
|
77
|
+
const allQuizIcon = isLocked ? "lock" : "pencil-alt";
|
|
78
|
+
const handleAllQuiz = () => {
|
|
79
|
+
if (isLocked) {
|
|
80
|
+
navigation.navigate("Coin");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const ALL_NUM = 0;
|
|
84
|
+
dispatch(stores_1.quizAction.setLesson({
|
|
85
|
+
subject: subject.name,
|
|
86
|
+
type: subject.type,
|
|
87
|
+
category: selectKey,
|
|
88
|
+
tagName: subject.tag,
|
|
89
|
+
system: subject.system,
|
|
90
|
+
lesson: {
|
|
91
|
+
title: selectedList.label + selectedList.title,
|
|
92
|
+
key: ALL_NUM,
|
|
93
|
+
},
|
|
94
|
+
}));
|
|
95
|
+
navigation.navigate("QuizSetup");
|
|
96
|
+
};
|
|
97
|
+
if (activeIndex !== index)
|
|
98
|
+
return null;
|
|
99
|
+
return (<react_native_gesture_handler_1.ScrollView style={styles.scrollContainer} contentContainerStyle={styles.container} showsVerticalScrollIndicator={false} ref={scrollViewRef} onMomentumScrollEnd={handleEndScroll}>
|
|
100
|
+
<Guide_1.default name={guideName} isVisible={isShowGuide}>
|
|
101
|
+
<react_native_1.View style={styles.navBar}/>
|
|
102
|
+
</Guide_1.default>
|
|
103
|
+
<common_1.RoundRectangle title={categoryName} style={styles.categoryName}/>
|
|
104
|
+
<BasicProgressBar_1.default subject={subject} index={index}/>
|
|
105
|
+
<SelectedExamCnt_1.default type={subject.type}/>
|
|
106
|
+
<common_1.HelpMark name="basicList" marginTop={20} top={-23}/>
|
|
107
|
+
<ArticleCategoryList_1.default navigation={navigation} topSubject={subject} index={index}/>
|
|
108
|
+
<common_1.HelpMark name="miniTest" marginTop={10} top={-23}/>
|
|
109
|
+
|
|
110
|
+
<MiniTestCard_1.default navigation={navigation} subject={subject} index={index}/>
|
|
111
|
+
<common_1.HelpMark name="badge" marginTop={10} top={-18}/>
|
|
112
|
+
<Badge5s_1.default badgeType="basic" subject={subject.name} category={selectKey}/>
|
|
113
|
+
<TagBadge5s_1.default subject={subject} index={index}/>
|
|
114
|
+
<common_1.HelpMark name="quizOption.allQuiz" top={0}/>
|
|
115
|
+
<common_1.RoundRectangleIcon title={categoryLabel + t("basic.allQuiz")} icon={allQuizIcon} onPress={handleAllQuiz}/>
|
|
116
|
+
<BasicSetting_1.default navigation={navigation} subjectType={subject.type}/>
|
|
117
|
+
</react_native_gesture_handler_1.ScrollView>);
|
|
118
|
+
};
|
|
119
|
+
const styles = react_native_1.StyleSheet.create({
|
|
120
|
+
navBar: {},
|
|
121
|
+
scrollContainer: {
|
|
122
|
+
padding: 20,
|
|
123
|
+
},
|
|
124
|
+
container: {
|
|
125
|
+
paddingBottom: 100,
|
|
126
|
+
},
|
|
127
|
+
categoryName: {
|
|
128
|
+
marginTop: 10,
|
|
129
|
+
marginBottom: 10,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
exports.default = ArticleContents;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ColorKeys } from "@nakamura-123/lib";
|
|
3
|
+
import { Store } from "@nakamura-123/types";
|
|
4
|
+
export type ArticleRowSize = "sm" | "lg";
|
|
5
|
+
interface ArticleRowProps {
|
|
6
|
+
title: string;
|
|
7
|
+
size: ArticleRowSize;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
flagColor: Store.ArticleFlagColor | null;
|
|
10
|
+
borderColor?: ColorKeys;
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
onToggleFlag: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const ArticleRow: React.FC<ArticleRowProps>;
|
|
15
|
+
export default ArticleRow;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
9
|
+
const common_1 = require("@nakamura-123/common");
|
|
10
|
+
const FLAG_ICON_COLOR = {
|
|
11
|
+
none: "ltBlack",
|
|
12
|
+
yellow: "yellow",
|
|
13
|
+
};
|
|
14
|
+
const SIZE_STYLE = {
|
|
15
|
+
sm: { height: 44, marginBottom: 4 },
|
|
16
|
+
lg: { height: 52, marginTop: 16, marginBottom: 16 },
|
|
17
|
+
};
|
|
18
|
+
const ArticleRow = ({ title, size, isRead, flagColor, borderColor, onPress, onToggleFlag, }) => {
|
|
19
|
+
return (<common_1.PressAnimatedWrap onPress={onPress} style={[
|
|
20
|
+
styles.rectangle,
|
|
21
|
+
SIZE_STYLE[size],
|
|
22
|
+
borderColor && { borderColor: lib_1.colors[borderColor], borderWidth: 2 },
|
|
23
|
+
]}>
|
|
24
|
+
<react_native_1.View style={styles.leftIconWrap}>
|
|
25
|
+
<common_1.Icon5 name="file-alt" size={16} color="darkGray"/>
|
|
26
|
+
{!isRead && <react_native_1.View style={styles.unreadDot}/>}
|
|
27
|
+
</react_native_1.View>
|
|
28
|
+
<common_1.MyText fsize="sm" color="text" style={styles.title}>
|
|
29
|
+
{title}
|
|
30
|
+
</common_1.MyText>
|
|
31
|
+
<react_native_1.Pressable onPress={onToggleFlag} hitSlop={8} style={styles.flagButton}>
|
|
32
|
+
<common_1.Icon5 name="bookmark" size={18} color={FLAG_ICON_COLOR[flagColor !== null && flagColor !== void 0 ? flagColor : "none"]} solid={flagColor !== null}/>
|
|
33
|
+
</react_native_1.Pressable>
|
|
34
|
+
<common_1.Icon5 name="chevron-right" size={16} color="darkGray"/>
|
|
35
|
+
</common_1.PressAnimatedWrap>);
|
|
36
|
+
};
|
|
37
|
+
const styles = react_native_1.StyleSheet.create({
|
|
38
|
+
rectangle: {
|
|
39
|
+
width: "100%",
|
|
40
|
+
flexDirection: "row",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
paddingHorizontal: 15,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
borderRadius: 12,
|
|
45
|
+
backgroundColor: lib_1.colors.bkBeige,
|
|
46
|
+
borderColor: lib_1.colors.ltBlack,
|
|
47
|
+
},
|
|
48
|
+
leftIconWrap: {
|
|
49
|
+
marginRight: 10,
|
|
50
|
+
},
|
|
51
|
+
unreadDot: {
|
|
52
|
+
position: "absolute",
|
|
53
|
+
top: -2,
|
|
54
|
+
right: -3,
|
|
55
|
+
width: 8,
|
|
56
|
+
height: 8,
|
|
57
|
+
borderRadius: 4,
|
|
58
|
+
backgroundColor: lib_1.colors.ltRed,
|
|
59
|
+
},
|
|
60
|
+
title: {
|
|
61
|
+
flex: 1,
|
|
62
|
+
},
|
|
63
|
+
flagButton: {
|
|
64
|
+
paddingHorizontal: 10,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
exports.default = ArticleRow;
|