@nakamura-123/pages 0.1.49 → 0.1.51

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.
@@ -1,6 +1,7 @@
1
- import RNIap, { ProductPurchase } from "react-native-iap";
1
+ import RNIap, { ProductPurchase, Purchase } from "expo-iap";
2
2
  import { Storage } from "@nakamura-123/types";
3
3
  export declare const initializeIAP: (paymentItems: string[] | undefined, setProducts: (products: RNIap.Product[]) => void, setLoading: (loading: boolean) => void) => Promise<void>;
4
4
  export declare const handlePurchase: (productId: string, dispatch: (action: any) => void) => Promise<ProductPurchase | null>;
5
5
  export declare const restorePurchases: (dispatch: (action: any) => void, isAlert?: boolean) => Promise<Storage.Receipt[] | null>;
6
6
  export declare const updateAllFreeState: (receipt: Storage.Receipt | null) => (dispatch: any, getState: any) => void;
7
+ export declare const getAndroidPurchaseState: (purchase: Purchase) => "paid" | "canceled" | "waiting";
@@ -36,9 +36,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.updateAllFreeState = exports.restorePurchases = exports.handlePurchase = exports.initializeIAP = void 0;
39
+ exports.getAndroidPurchaseState = exports.updateAllFreeState = exports.restorePurchases = exports.handlePurchase = exports.initializeIAP = void 0;
40
40
  var react_native_1 = require("react-native");
41
- var react_native_iap_1 = require("react-native-iap");
41
+ var expo_iap_1 = require("expo-iap");
42
42
  var stores_1 = require("@nakamura-123/stores");
43
43
  var ReceiptFnc_1 = require("./ReceiptFnc");
44
44
  // const { pushCoinLog, pushCoinError, pushCoinWarn } = errorAction;
@@ -49,14 +49,14 @@ var initializeIAP = function (paymentItems, setProducts, setLoading) { return __
49
49
  switch (_a.label) {
50
50
  case 0:
51
51
  _a.trys.push([0, 5, 6, 7]);
52
- return [4 /*yield*/, (0, react_native_iap_1.initConnection)()];
52
+ return [4 /*yield*/, (0, expo_iap_1.initConnection)()];
53
53
  case 1:
54
54
  result = _a.sent();
55
55
  console.log("IAP Connection Initialized: ", result);
56
56
  itemSkus = paymentItems || [];
57
57
  console.log("Item SKUs: ", itemSkus);
58
58
  if (!(itemSkus.length > 0)) return [3 /*break*/, 3];
59
- return [4 /*yield*/, (0, react_native_iap_1.getProducts)({ skus: itemSkus })];
59
+ return [4 /*yield*/, (0, expo_iap_1.requestProducts)({ skus: itemSkus })];
60
60
  case 2:
61
61
  productList = _a.sent();
62
62
  console.log("Product List: ", productList);
@@ -80,16 +80,15 @@ var initializeIAP = function (paymentItems, setProducts, setLoading) { return __
80
80
  exports.initializeIAP = initializeIAP;
81
81
  // 11. 購入処理
82
82
  var handlePurchase = function (productId, dispatch) { return __awaiter(void 0, void 0, void 0, function () {
83
- var params, purchase, receipt, isValid, err_2;
83
+ var purchase, receipt, isValid, err_2;
84
84
  return __generator(this, function (_a) {
85
85
  switch (_a.label) {
86
86
  case 0:
87
- params = react_native_1.Platform.OS === "ios" ? { sku: productId } : { skus: [productId] };
88
- _a.label = 1;
87
+ _a.trys.push([0, 5, , 6]);
88
+ return [4 /*yield*/, (0, expo_iap_1.requestPurchase)({
89
+ request: { ios: { sku: productId }, android: { skus: [productId] } },
90
+ })];
89
91
  case 1:
90
- _a.trys.push([1, 6, , 7]);
91
- return [4 /*yield*/, (0, react_native_iap_1.requestPurchase)(params)];
92
- case 2:
93
92
  purchase = _a.sent();
94
93
  // dispatch(pushCoinLog({ title: "Purchase", log: purchase }));
95
94
  if (Array.isArray(purchase))
@@ -113,16 +112,17 @@ var handlePurchase = function (productId, dispatch) { return __awaiter(void 0, v
113
112
  // );
114
113
  throw new Error("購入検証に失敗しました");
115
114
  }
116
- if (!(react_native_1.Platform.OS === "android" && purchase.purchaseStateAndroid === 2)) return [3 /*break*/, 3];
115
+ if (!(react_native_1.Platform.OS === "android" &&
116
+ (0, exports.getAndroidPurchaseState)(purchase) === "waiting")) return [3 /*break*/, 2];
117
117
  alert("手続きが完了しました。支払いが完了したら、このページにある「以前購入した方はこちらから復元」をタップしてください。");
118
- return [3 /*break*/, 5];
119
- case 3: return [4 /*yield*/, (0, react_native_iap_1.finishTransaction)({ purchase: purchase, isConsumable: false })];
120
- case 4:
118
+ return [3 /*break*/, 4];
119
+ case 2: return [4 /*yield*/, (0, expo_iap_1.finishTransaction)({ purchase: purchase, isConsumable: false })];
120
+ case 3:
121
121
  _a.sent();
122
122
  alert("購入が完了しました!");
123
- _a.label = 5;
124
- case 5: return [2 /*return*/, purchase]; // 成功時に購入データを返す
125
- case 6:
123
+ _a.label = 4;
124
+ case 4: return [2 /*return*/, purchase]; // 成功時に購入データを返す
125
+ case 5:
126
126
  err_2 = _a.sent();
127
127
  // エラー処理を整理
128
128
  // dispatch(
@@ -130,7 +130,7 @@ var handlePurchase = function (productId, dispatch) { return __awaiter(void 0, v
130
130
  // );
131
131
  alert("購入に失敗しました。\nしばらく時間を置いた後、もう一度実行してみてください。もしそれでも購入できない場合は「よくある質問」をご確認いただくか、必要に応じて「お問い合わせフォーム」からご連絡ください。");
132
132
  return [2 /*return*/, null]; // 失敗時はnullを返す
133
- case 7: return [2 /*return*/];
133
+ case 6: return [2 /*return*/];
134
134
  }
135
135
  });
136
136
  }); };
@@ -143,9 +143,10 @@ var restorePurchases = function (dispatch, isAlert) { return __awaiter(void 0, v
143
143
  case 0:
144
144
  _a.trys.push([0, 8, , 9]);
145
145
  console.log("restorePurchases");
146
- return [4 /*yield*/, (0, react_native_iap_1.getAvailablePurchases)()];
146
+ return [4 /*yield*/, (0, expo_iap_1.getAvailablePurchases)()];
147
147
  case 1:
148
148
  purchases = _a.sent();
149
+ // const purchases: Purchase[] = await getAvailablePurchases();
149
150
  console.log("purchases", purchases);
150
151
  receipts = [];
151
152
  _i = 0, purchases_1 = purchases;
@@ -158,8 +159,8 @@ var restorePurchases = function (dispatch, isAlert) { return __awaiter(void 0, v
158
159
  dispatch((0, exports.updateAllFreeState)(receipt));
159
160
  receipts.push(receipt);
160
161
  }
161
- if (!checkNeedFinish(purchase)) return [3 /*break*/, 4];
162
- return [4 /*yield*/, (0, react_native_iap_1.finishTransaction)({ purchase: purchase, isConsumable: false })];
162
+ if (!checkIsAcknowledgedAndroid(purchase)) return [3 /*break*/, 4];
163
+ return [4 /*yield*/, (0, expo_iap_1.finishTransaction)({ purchase: purchase, isConsumable: false })];
163
164
  case 3:
164
165
  _a.sent();
165
166
  _a.label = 4;
@@ -211,7 +212,27 @@ var updateAllFreeState = function (receipt) { return function (dispatch, getStat
211
212
  }
212
213
  }; };
213
214
  exports.updateAllFreeState = updateAllFreeState;
214
- // 92. androidの後払いアイテムの承認をするか否か
215
- var checkNeedFinish = function (purchase) {
216
- return purchase.purchaseStateAndroid === 1 && !purchase.isAcknowledgedAndroid;
215
+ // 93. purchaseStateAndroidの判定(0: 支払済み, 1: キャンセル, 2: 支払い待ち)
216
+ var getAndroidPurchaseState = function (purchase) {
217
+ if (purchase.platform === "ios") {
218
+ return "paid";
219
+ }
220
+ switch (purchase.purchaseStateAndroid) {
221
+ case 0:
222
+ return "paid";
223
+ case 1:
224
+ return "canceled";
225
+ case 2:
226
+ return "waiting";
227
+ default:
228
+ return "paid";
229
+ }
230
+ };
231
+ exports.getAndroidPurchaseState = getAndroidPurchaseState;
232
+ // 94. Androidの後払いアイテムの承認をするか否か
233
+ var checkIsAcknowledgedAndroid = function (purchase) {
234
+ if (purchase.platform === "ios")
235
+ return true; // iOSでは常に承認済み
236
+ return ((0, exports.getAndroidPurchaseState)(purchase) === "paid" &&
237
+ !purchase.isAcknowledgedAndroid);
217
238
  };
@@ -1,15 +1,15 @@
1
1
  import React from "react";
2
- import RNIap from "react-native-iap";
2
+ import { type Product } from "expo-iap";
3
3
  import { Nav } from "@nakamura-123/types";
4
4
  import { Comment } from "./AppReviews";
5
5
  interface Props {
6
6
  navigation: Nav.NavigationProp<"Coin">;
7
7
  comments: Comment[];
8
- products: RNIap.Product[];
8
+ products: Product[];
9
9
  onPurchase: (productId: string) => void;
10
10
  onRestore: () => void;
11
11
  loading: boolean;
12
12
  isAllfreePaid: boolean;
13
13
  }
14
- declare const CoinPage: React.FC<Props>;
15
- export default CoinPage;
14
+ declare const CoinPageComponent: React.FC<Props>;
15
+ export default CoinPageComponent;
@@ -12,7 +12,7 @@ var Recommend_1 = __importDefault(require("./Recommend"));
12
12
  var AppReviews_1 = __importDefault(require("./AppReviews"));
13
13
  var WaitingPayBanner_1 = __importDefault(require("./WaitingPayBanner"));
14
14
  var react_i18next_1 = require("react-i18next");
15
- var CoinPage = function (_a) {
15
+ var CoinPageComponent = function (_a) {
16
16
  var navigation = _a.navigation, comments = _a.comments, products = _a.products, onPurchase = _a.onPurchase, onRestore = _a.onRestore, loading = _a.loading, isAllfreePaid = _a.isAllfreePaid;
17
17
  var t = (0, react_i18next_1.useTranslation)().t;
18
18
  var isAndroid = react_native_1.Platform.OS === "android";
@@ -25,12 +25,10 @@ var CoinPage = function (_a) {
25
25
  <WaitingPayBanner_1.default currentPage="coin"/>
26
26
 
27
27
  {products.map(function (product, index) {
28
- var name = isAndroid ? product.name : product.title;
29
- var price = product.localizedPrice;
28
+ var name = isAndroid ? product.displayName : product.title;
29
+ var price = product.displayPrice;
30
30
  var title = "".concat(name, " ").concat(price);
31
- return (<common_1.RectangleCard key={index} title={title} note={product.description} left={<common_1.IconInCircle name="gift"/>} color={isAllfreePaid ? "ltBlack" : "blue"} onPress={function () {
32
- return isAllfreePaid ? null : onPurchase(product.productId);
33
- }}/>);
31
+ return (<common_1.RectangleCard key={index} title={title} note={product.description} left={<common_1.IconInCircle name="gift"/>} color={isAllfreePaid ? "ltBlack" : "blue"} onPress={function () { return (isAllfreePaid ? null : onPurchase(product.id)); }}/>);
34
32
  })}
35
33
  <react_native_1.View style={styles.txtContainer}>
36
34
  <common_1.MyText fsize="sm" color="gray">
@@ -71,4 +69,4 @@ var styles = react_native_1.StyleSheet.create({
71
69
  alignItems: "center",
72
70
  },
73
71
  });
74
- exports.default = CoinPage;
72
+ exports.default = CoinPageComponent;
@@ -1,6 +1,6 @@
1
- import { ProductPurchase } from "react-native-iap";
1
+ import { type Purchase } from "expo-iap";
2
2
  import { Storage } from "@nakamura-123/types";
3
3
  type Receipt = Storage.Receipt;
4
- export declare const unifyReceipt: (receipt: ProductPurchase) => Receipt | null;
4
+ export declare const unifyReceipt: (receipt: Purchase) => Receipt | null;
5
5
  export declare const validatePurchaseClientSide: (receipt: string | undefined, platform: "ios" | "android") => boolean;
6
6
  export {};
@@ -1,17 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePurchaseClientSide = exports.unifyReceipt = void 0;
4
- var react_native_1 = require("react-native");
5
4
  // 01. レシートの形式を統一
6
5
  var unifyReceipt = function (receipt) {
7
- var os = react_native_1.Platform.OS;
8
- return {
9
- transactionId: receipt.transactionId || "",
10
- productId: receipt.productId,
11
- transactionDate: Number(receipt.transactionDate),
12
- receipt: os === "ios" ? receipt.transactionReceipt : receipt.purchaseToken,
13
- isPaid: os === "ios" || receipt.purchaseStateAndroid === 1, // iOSでは即時完了、AndroidはpurchaseStateが1が支払済み、2が未払い
14
- };
6
+ if (receipt.platform === "android")
7
+ return {
8
+ transactionId: receipt.transactionId || "",
9
+ productId: receipt.productId,
10
+ transactionDate: Number(receipt.transactionDate),
11
+ receipt: receipt.purchaseToken || "",
12
+ isPaid: receipt.purchaseStateAndroid === 0,
13
+ };
14
+ else
15
+ return {
16
+ transactionId: receipt.transactionId || "",
17
+ productId: receipt.productId,
18
+ transactionDate: Number(receipt.transactionDate),
19
+ receipt: receipt.transactionReceipt || "",
20
+ isPaid: true, // iOSでは即時完了
21
+ };
15
22
  };
16
23
  exports.unifyReceipt = unifyReceipt;
17
24
  // 02. レシートの検証
@@ -65,7 +65,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
65
65
  var react_1 = __importStar(require("react"));
66
66
  var react_redux_1 = require("react-redux");
67
67
  var stores_1 = require("@nakamura-123/stores");
68
- var react_native_iap_1 = require("react-native-iap");
68
+ // import RNIap, { endConnection } from "react-native-iap";
69
+ var expo_iap_1 = require("expo-iap");
69
70
  var CoinPageComponent_1 = __importDefault(require("../component/Coin/CoinPageComponent"));
70
71
  var CoinFnc_1 = require("../component/Coin/CoinFnc");
71
72
  var ReceiptFnc_1 = require("../component/Coin/ReceiptFnc");
@@ -84,7 +85,7 @@ var CoinPage = function (_a) {
84
85
  (0, CoinFnc_1.initializeIAP)(items, setProducts, setLoading);
85
86
  // アンマウント時に接続を終了
86
87
  return function () {
87
- (0, react_native_iap_1.endConnection)();
88
+ (0, expo_iap_1.endConnection)();
88
89
  };
89
90
  }, []);
90
91
  // 02.購入時の処理の実行
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
- declare const InfomationPage: React.FC;
3
- export default InfomationPage;
2
+ declare const InformationPage: React.FC;
3
+ export default InformationPage;
@@ -33,19 +33,19 @@ var emptyCardInfo = {
33
33
  color: "blue",
34
34
  description: "",
35
35
  };
36
- var InfomationPage = function () {
37
- var adCardInfos = (0, react_redux_1.useSelector)(function (state) { return state.setting.info.adCard; });
36
+ var InformationPage = function () {
37
+ var adCardInfos = (0, react_redux_1.useSelector)(function (state) { var _a, _b, _c; return (_c = (_b = (_a = state.setting) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.adCard) !== null && _c !== void 0 ? _c : []; });
38
38
  var _a = (0, react_1.useState)(emptyCardInfo), cardInfo = _a[0], setCardInfo = _a[1];
39
39
  var _b = (0, react_1.useState)(false), isVisible = _b[0], setIsVisible = _b[1];
40
40
  // descriptionは10文字だけを表示
41
- var handrePress = function (info) {
41
+ var handlePress = function (info) {
42
42
  setCardInfo(info);
43
43
  setIsVisible(true);
44
44
  };
45
45
  return (<react_native_1.ScrollView>
46
46
  <react_native_1.View style={styles.container}>
47
47
  <common_1.InformationCard info={cardInfo} isVisible={isVisible} onClose={function () { return setIsVisible(false); }}/>
48
- {adCardInfos.map(function (info) { return (<common_1.RectangleCard key={info.title} title={info.title} note={formattedDescription(info.description)} left={<common_1.IconInCircle name={info.icon} size={25}/>} onPress={function () { return handrePress(info); }} color={info.color} outerStyle={{ marginBottom: 20 }}/>); })}
48
+ {adCardInfos.map(function (info) { return (<common_1.RectangleCard key={info.title} title={info.title} note={formattedDescription(info.description)} left={<common_1.IconInCircle name={info.icon} size={25}/>} onPress={function () { return handlePress(info); }} color={info.color} outerStyle={{ marginBottom: 20 }}/>); })}
49
49
  </react_native_1.View>
50
50
  </react_native_1.ScrollView>);
51
51
  };
@@ -70,4 +70,4 @@ var styles = react_native_1.StyleSheet.create({
70
70
  color: "#333",
71
71
  },
72
72
  });
73
- exports.default = InfomationPage;
73
+ exports.default = InformationPage;
@@ -132,7 +132,7 @@ var ReportPage = function (_a) {
132
132
  placeholder={t("report.first.placeholder")} // プレースホルダー
133
133
  />
134
134
  {type === REPORT_TYPES[1] && (<common_1.MyText>{t("report.msg.noDisplayed")} </common_1.MyText>)}
135
- {type !== REPORT_TYPES[1] && type !== null && (<>
135
+ {type !== REPORT_TYPES[1] && type !== null && (<react_native_1.View style={{ paddingBottom: 300 }}>
136
136
  <react_native_1.View style={{ marginTop: 10 }}>
137
137
  {type === REPORT_TYPES[2] && (<>
138
138
  <common_1.RoundRectangleIcon title="よくある質問はこちら" icon="question" onPress={function () { return react_native_1.Linking.openURL("https://drill-notes.com/faq"); }} style={{ backgroundColor: lib_1.colors.blue }}/>
@@ -154,7 +154,7 @@ var ReportPage = function (_a) {
154
154
  <common_1.MiniIconBtn onPress={function () { return navigation.goBack(); }} icon="arrow-left" title={t("report.btn.back")} color="blue"/>
155
155
  <common_1.MiniIconBtn onPress={function () { return handleSend(); }} icon="envelope" title={t("report.btn.send")} color="red"/>
156
156
  </react_native_1.View>
157
- </>)}
157
+ </react_native_1.View>)}
158
158
  </react_native_1.ScrollView>);
159
159
  };
160
160
  var styles = react_native_1.StyleSheet.create({
@@ -15,6 +15,7 @@ var BlankAnswer_1 = __importDefault(require("./BlankAnswer"));
15
15
  var BlankBtn_1 = __importDefault(require("./BlankBtn"));
16
16
  var InputNav_1 = __importDefault(require("./InputNav"));
17
17
  var MultiGuide_1 = __importDefault(require("./MultiGuide"));
18
+ var NormalMultiGuide_1 = __importDefault(require("./NormalMultiGuide"));
18
19
  var isDQInStoreNormal = types_1.qGard.isDQInStoreNormal;
19
20
  var Answer = function (_a) {
20
21
  var question = (0, quizHook_1.useQuestionDataD)();
@@ -23,7 +24,10 @@ var Answer = function (_a) {
23
24
  var mode = (0, quizHook_2.useGetMode)();
24
25
  return (<react_native_1.View style={styles.container}>
25
26
  {/* 1.ノーマルモード */}
26
- {types_1.qGard.isDQInStoreNormal(question) && (<NormalChoice_1.default question={question}/>)}
27
+ {types_1.qGard.isDQInStoreNormal(question) && (<>
28
+ <NormalMultiGuide_1.default question={question}/>
29
+ <NormalChoice_1.default question={question}/>
30
+ </>)}
27
31
  {/* 2.Multiモード */}
28
32
  {types_1.qGard.isDQInStoreMulti(question) && mode === "quiz" && (<>
29
33
  <MultiGuide_1.default />
@@ -8,7 +8,7 @@ var react_native_1 = require("react-native");
8
8
  var react_redux_1 = require("react-redux");
9
9
  var lib_1 = require("@nakamura-123/lib");
10
10
  var MyTextqqyy_1 = __importDefault(require("../common/MyTextqqyy"));
11
- var INIT_MSG = "空欄をタップすると\n答えが表示されます答えが表示されます";
11
+ var INIT_MSG = "空欄をタップすると\n答えが表示されます。";
12
12
  var BlankAnswer = function (_a) {
13
13
  var question = _a.question;
14
14
  var blankAns = question.blankAns;
@@ -0,0 +1,7 @@
1
+ import { Store } from "@nakamura-123/types";
2
+ import React from "react";
3
+ interface Props {
4
+ question: Store.DQInStoreNormal;
5
+ }
6
+ declare const NormalMultiGuide: React.FC<Props>;
7
+ export default NormalMultiGuide;
@@ -0,0 +1,31 @@
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
+ var common_1 = require("@nakamura-123/common");
7
+ var lib_1 = require("@nakamura-123/lib");
8
+ var react_1 = __importDefault(require("react"));
9
+ var react_native_1 = require("react-native");
10
+ var quizHook_1 = require("../../hooks/quizHook");
11
+ var NormalMultiGuide = function (_a) {
12
+ var question = _a.question;
13
+ var viewHeight = 20;
14
+ var mode = (0, quizHook_1.useGetMode)();
15
+ var shouldShow = mode === "quiz" && (question === null || question === void 0 ? void 0 : question.ans.length) > 1;
16
+ var number = question === null || question === void 0 ? void 0 : question.ans.length;
17
+ return (<common_1.CollopseView height={viewHeight} visible={shouldShow} style={styles.container}>
18
+ <common_1.MyText fsize="sm" color="red">
19
+ 答えを{number}つ選んでください
20
+ </common_1.MyText>
21
+ </common_1.CollopseView>);
22
+ };
23
+ var styles = react_native_1.StyleSheet.create({
24
+ container: {
25
+ justifyContent: "center",
26
+ alignItems: "center",
27
+ backgroundColor: lib_1.colors.bkBeige,
28
+ marginBottom: 5,
29
+ },
30
+ });
31
+ exports.default = NormalMultiGuide;
@@ -59,6 +59,8 @@ var checkMultiState = function (multiState, index) {
59
59
  var checkMultiStateResult = function (multiSel, selectedIndexes, index) {
60
60
  if (!selectedIndexes || selectedIndexes.length === 0)
61
61
  return "inCorrect";
62
+ if (multiSel.length > selectedIndexes.length)
63
+ return "inCorrect";
62
64
  var selectedIndex = selectedIndexes[index];
63
65
  var isCorrect = multiSel[index][selectedIndex].isCorrect;
64
66
  if (isCorrect)