質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,306 +94,272 @@
|
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
97
|
-
t
|
101
|
+
export const InputScreen: VFC<Props> = ({ navigation, route }) => {
|
98
|
-
|
102
|
+
|
99
|
-
|
103
|
+
//略
|
100
|
-
|
104
|
+
|
101
|
-
c
|
105
|
+
const [items, setItems] = useState<SQLite.SQLResultSet>();
|
102
|
-
|
106
|
+
|
103
|
-
|
107
|
+
let db: any;
|
108
|
+
|
109
|
+
|
110
|
+
|
104
|
-
|
111
|
+
useEffect(() => {
|
112
|
+
|
113
|
+
initializeDatabase();
|
114
|
+
|
115
|
+
}, [])
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
const initializeDatabase = () => {
|
120
|
+
|
121
|
+
// DBの作成先
|
122
|
+
|
123
|
+
console.log(FileSystem.documentDirectory + "SQLite/");
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
// DBのオープン
|
128
|
+
|
129
|
+
db = SQLite.openDatabase("DB.db");
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
db.transaction((tx: any) => {
|
134
|
+
|
135
|
+
tx.executeSql(
|
136
|
+
|
137
|
+
"create table if not exists costHistory (id integer primary key autoincrement, cost integer not null, category string not null, memo string, date date not null);",
|
138
|
+
|
139
|
+
null,
|
140
|
+
|
141
|
+
() => { // 成功時のコールバック
|
142
|
+
|
143
|
+
console.log("initialize success");
|
144
|
+
|
145
|
+
},
|
146
|
+
|
147
|
+
() => { // 失敗時のコールバック
|
148
|
+
|
149
|
+
console.log("initialize fail");
|
150
|
+
|
151
|
+
return true; // ロールバックする場合はtrueを返す
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
);
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
const errorDB = () => {
|
164
|
+
|
165
|
+
console.log('DB open failed.');
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
const showDatePicker = () => {
|
174
|
+
|
175
|
+
setDatePickerVisibility(true);
|
176
|
+
|
177
|
+
};
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
const hideDatePicker = () => {
|
182
|
+
|
183
|
+
setDatePickerVisibility(false);
|
184
|
+
|
185
|
+
};
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
const handleConfirm = (date: Date) => {
|
190
|
+
|
105
|
-
|
191
|
+
setDate(date);
|
192
|
+
|
193
|
+
hideDatePicker();
|
194
|
+
|
195
|
+
};
|
196
|
+
|
197
|
+
const onPress = (account_name: string) => {
|
198
|
+
|
199
|
+
navigation.navigate("Account", { account_name });
|
200
|
+
|
201
|
+
};
|
202
|
+
|
203
|
+
const onClickStore = () => {
|
204
|
+
|
205
|
+
db.transaction((tx: any) => {
|
206
|
+
|
207
|
+
tx.executeSql(
|
208
|
+
|
209
|
+
"insert into costHistory (cost, category, memo, date) values (?, ?, ?, ?);",
|
210
|
+
|
211
|
+
[cost, category, memo, date],
|
212
|
+
|
213
|
+
() => {
|
214
|
+
|
215
|
+
console.log("insert success");
|
216
|
+
|
217
|
+
}, // 成功時のコールバック関数
|
218
|
+
|
219
|
+
() => {
|
220
|
+
|
221
|
+
console.log("insert fail");
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
return true; // ロールバックする場合はtrueを返す
|
226
|
+
|
227
|
+
} // 失敗時のコールバック関数
|
228
|
+
|
229
|
+
);
|
230
|
+
|
231
|
+
tx.executeSql(
|
232
|
+
|
233
|
+
"select * from costHistory;",
|
234
|
+
|
235
|
+
[],
|
236
|
+
|
237
|
+
(_, resultSet: any) => {
|
238
|
+
|
239
|
+
setItems(resultSet);
|
240
|
+
|
241
|
+
console.log("select success");
|
242
|
+
|
243
|
+
for (let i = 0; i < resultSet.rows.length; i++) {
|
244
|
+
|
245
|
+
const id = resultSet.rows.item(i).id;
|
246
|
+
|
247
|
+
const name = resultSet.rows.item(i).name;
|
248
|
+
|
249
|
+
console.log(resultSet?.rows);
|
250
|
+
|
251
|
+
console.log(`${id}:${name}`);
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
},
|
256
|
+
|
257
|
+
() => {
|
258
|
+
|
259
|
+
console.log("select fail");
|
260
|
+
|
261
|
+
return false;
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
)
|
266
|
+
|
267
|
+
});
|
268
|
+
|
269
|
+
};
|
270
|
+
|
271
|
+
return (
|
272
|
+
|
273
|
+
// 略
|
274
|
+
|
275
|
+
);
|
106
276
|
|
107
277
|
};
|
108
278
|
|
109
279
|
|
110
280
|
|
111
|
-
const
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
expo
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
in
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
con
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
t
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
});
|
281
|
+
const styles = StyleSheet.create({
|
282
|
+
|
283
|
+
// 略
|
284
|
+
|
285
|
+
});
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
```
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
### 試したこと
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
app.jsonにsdkVersionの追加
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
```
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
"expo": {
|
306
|
+
|
307
|
+
"name": "app",
|
308
|
+
|
309
|
+
"slug": "app",
|
310
|
+
|
311
|
+
"sdkVersion": "41.0.0",
|
312
|
+
|
313
|
+
"version": "1.0.0",
|
314
|
+
|
315
|
+
"orientation": "portrait",
|
316
|
+
|
317
|
+
"icon": "./assets/icon.png",
|
318
|
+
|
319
|
+
"splash": {
|
320
|
+
|
321
|
+
"image": "./assets/splash.png",
|
322
|
+
|
323
|
+
"resizeMode": "contain",
|
324
|
+
|
325
|
+
"backgroundColor": "#ffffff"
|
326
|
+
|
327
|
+
},
|
328
|
+
|
329
|
+
"updates": {
|
330
|
+
|
331
|
+
"fallbackToCacheTimeout": 0
|
332
|
+
|
333
|
+
},
|
334
|
+
|
335
|
+
"assetBundlePatterns": ["**/*"],
|
336
|
+
|
337
|
+
"ios": {
|
338
|
+
|
339
|
+
"supportsTablet": true
|
340
|
+
|
341
|
+
},
|
342
|
+
|
343
|
+
"android": {
|
344
|
+
|
345
|
+
"adaptiveIcon": {
|
346
|
+
|
347
|
+
"foregroundImage": "./assets/adaptive-icon.png",
|
348
|
+
|
349
|
+
"backgroundColor": "#FFFFFF"
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
},
|
354
|
+
|
355
|
+
"web": {
|
356
|
+
|
357
|
+
"favicon": "./assets/favicon.png"
|
358
|
+
|
359
|
+
}
|
192
360
|
|
193
361
|
}
|
194
362
|
|
195
|
-
|
196
|
-
|
197
|
-
const errorDB = () => {
|
198
|
-
|
199
|
-
console.log('DB open failed.');
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
const showDatePicker = () => {
|
208
|
-
|
209
|
-
setDatePickerVisibility(true);
|
210
|
-
|
211
|
-
};
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
const hideDatePicker = () => {
|
216
|
-
|
217
|
-
setDatePickerVisibility(false);
|
218
|
-
|
219
|
-
};
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
const handleConfirm = (date: Date) => {
|
224
|
-
|
225
|
-
setDate(date);
|
226
|
-
|
227
|
-
hideDatePicker();
|
228
|
-
|
229
|
-
};
|
230
|
-
|
231
|
-
const onPress = (account_name: string) => {
|
232
|
-
|
233
|
-
navigation.navigate("Account", { account_name });
|
234
|
-
|
235
|
-
};
|
236
|
-
|
237
|
-
const onClickStore = () => {
|
238
|
-
|
239
|
-
db.transaction((tx: any) => {
|
240
|
-
|
241
|
-
tx.executeSql(
|
242
|
-
|
243
|
-
"insert into costHistory (cost, category, memo, date) values (?, ?, ?, ?);",
|
244
|
-
|
245
|
-
[cost, category, memo, date],
|
246
|
-
|
247
|
-
() => {
|
248
|
-
|
249
|
-
console.log("insert success");
|
250
|
-
|
251
|
-
}, // 成功時のコールバック関数
|
252
|
-
|
253
|
-
() => {
|
254
|
-
|
255
|
-
console.log("insert fail");
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
return true; // ロールバックする場合はtrueを返す
|
260
|
-
|
261
|
-
} // 失敗時のコールバック関数
|
262
|
-
|
263
|
-
);
|
264
|
-
|
265
|
-
tx.executeSql(
|
266
|
-
|
267
|
-
"select * from costHistory;",
|
268
|
-
|
269
|
-
[],
|
270
|
-
|
271
|
-
(_, resultSet: any) => {
|
272
|
-
|
273
|
-
setItems(resultSet);
|
274
|
-
|
275
|
-
console.log("select success");
|
276
|
-
|
277
|
-
for (let i = 0; i < resultSet.rows.length; i++) {
|
278
|
-
|
279
|
-
const id = resultSet.rows.item(i).id;
|
280
|
-
|
281
|
-
const name = resultSet.rows.item(i).name;
|
282
|
-
|
283
|
-
console.log(resultSet?.rows);
|
284
|
-
|
285
|
-
console.log(`${id}:${name}`);
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
},
|
290
|
-
|
291
|
-
() => {
|
292
|
-
|
293
|
-
console.log("select fail");
|
294
|
-
|
295
|
-
return false;
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
)
|
300
|
-
|
301
|
-
});
|
302
|
-
|
303
|
-
};
|
304
|
-
|
305
|
-
return (
|
306
|
-
|
307
|
-
// 略
|
308
|
-
|
309
|
-
);
|
310
|
-
|
311
|
-
};
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
const styles = StyleSheet.create({
|
316
|
-
|
317
|
-
// 略
|
318
|
-
|
319
|
-
});
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
```
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
### 試したこと
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
app.jsonにsdkVersionの追加
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
```
|
336
|
-
|
337
|
-
{
|
338
|
-
|
339
|
-
"expo": {
|
340
|
-
|
341
|
-
"name": "app",
|
342
|
-
|
343
|
-
"slug": "app",
|
344
|
-
|
345
|
-
"sdkVersion": "41.0.0",
|
346
|
-
|
347
|
-
"version": "1.0.0",
|
348
|
-
|
349
|
-
"orientation": "portrait",
|
350
|
-
|
351
|
-
"icon": "./assets/icon.png",
|
352
|
-
|
353
|
-
"splash": {
|
354
|
-
|
355
|
-
"image": "./assets/splash.png",
|
356
|
-
|
357
|
-
"resizeMode": "contain",
|
358
|
-
|
359
|
-
"backgroundColor": "#ffffff"
|
360
|
-
|
361
|
-
},
|
362
|
-
|
363
|
-
"updates": {
|
364
|
-
|
365
|
-
"fallbackToCacheTimeout": 0
|
366
|
-
|
367
|
-
},
|
368
|
-
|
369
|
-
"assetBundlePatterns": ["**/*"],
|
370
|
-
|
371
|
-
"ios": {
|
372
|
-
|
373
|
-
"supportsTablet": true
|
374
|
-
|
375
|
-
},
|
376
|
-
|
377
|
-
"android": {
|
378
|
-
|
379
|
-
"adaptiveIcon": {
|
380
|
-
|
381
|
-
"foregroundImage": "./assets/adaptive-icon.png",
|
382
|
-
|
383
|
-
"backgroundColor": "#FFFFFF"
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
},
|
388
|
-
|
389
|
-
"web": {
|
390
|
-
|
391
|
-
"favicon": "./assets/favicon.png"
|
392
|
-
|
393
|
-
}
|
394
|
-
|
395
|
-
}
|
396
|
-
|
397
363
|
}
|
398
364
|
|
399
365
|
|