Merge commit '1f9c3064bf16c57119af415804c7f3bf495927ff' into develop
This commit is contained in:
commit
5d5cf23773
29
app.json
29
app.json
@ -3,9 +3,24 @@
|
|||||||
"name": "JR四国運行状況",
|
"name": "JR四国運行状況",
|
||||||
"slug": "jrshikoku",
|
"slug": "jrshikoku",
|
||||||
"privacy": "public",
|
"privacy": "public",
|
||||||
"platforms": [
|
"platforms": ["ios", "android"],
|
||||||
"ios",
|
"plugins": [
|
||||||
"android"
|
[
|
||||||
|
"react-native-android-widget",
|
||||||
|
{
|
||||||
|
"widgets": [
|
||||||
|
{
|
||||||
|
"name": "JR_shikoku_train_info",
|
||||||
|
"label": "My Hello Widget",
|
||||||
|
"minWidth": "320dp",
|
||||||
|
"minHeight": "120dp",
|
||||||
|
"description": "This is my first widget",
|
||||||
|
"previewImage": "./assets/icon.png",
|
||||||
|
"updatePeriodMillis": 1800000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
],
|
],
|
||||||
"version": "4.6",
|
"version": "4.6",
|
||||||
"orientation": "default",
|
"orientation": "default",
|
||||||
@ -19,9 +34,7 @@
|
|||||||
"fallbackToCacheTimeout": 0,
|
"fallbackToCacheTimeout": 0,
|
||||||
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||||
},
|
},
|
||||||
"assetBundlePatterns": [
|
"assetBundlePatterns": ["**/*"],
|
||||||
"**/*"
|
|
||||||
],
|
|
||||||
"ios": {
|
"ios": {
|
||||||
"buildNumber": "31",
|
"buildNumber": "31",
|
||||||
"supportsTablet": true,
|
"supportsTablet": true,
|
||||||
@ -33,9 +46,7 @@
|
|||||||
"android": {
|
"android": {
|
||||||
"package": "jrshikokuinfo.xprocess.hrkn",
|
"package": "jrshikokuinfo.xprocess.hrkn",
|
||||||
"versionCode": 20,
|
"versionCode": 20,
|
||||||
"permissions": [
|
"permissions": ["ACCESS_FINE_LOCATION"],
|
||||||
"ACCESS_FINE_LOCATION"
|
|
||||||
],
|
|
||||||
"googleServicesFile": "./google-services.json",
|
"googleServicesFile": "./google-services.json",
|
||||||
"config": {
|
"config": {
|
||||||
"googleMaps": {
|
"googleMaps": {
|
||||||
|
88
components/AndroidWidget/HelloWidget.jsx
Normal file
88
components/AndroidWidget/HelloWidget.jsx
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { FlexWidget, TextWidget } from "react-native-android-widget";
|
||||||
|
|
||||||
|
export function HelloWidget({ time, delayString }) {
|
||||||
|
return (
|
||||||
|
<FlexWidget
|
||||||
|
style={{
|
||||||
|
height: "match_parent",
|
||||||
|
width: "match_parent",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
borderRadius: 16,
|
||||||
|
}}
|
||||||
|
clickAction="WIDGET_CLICK"
|
||||||
|
>
|
||||||
|
<FlexWidget
|
||||||
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: "#0099CC",
|
||||||
|
width: "match_parent",
|
||||||
|
flexDirection: "row",
|
||||||
|
padding: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextWidget
|
||||||
|
text={"列車遅延速報EX"}
|
||||||
|
style={{
|
||||||
|
fontSize: 30,
|
||||||
|
fontWeight: "bold",
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<FlexWidget style={{ flex: 1 }} />
|
||||||
|
<TextWidget
|
||||||
|
text={time}
|
||||||
|
style={{
|
||||||
|
fontSize: 32,
|
||||||
|
fontFamily: "Inter",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</FlexWidget>
|
||||||
|
<FlexWidget
|
||||||
|
style={{ flex: 1, backgroundColor: "#fff", width: "match_parent" }}
|
||||||
|
>
|
||||||
|
{delayString ? (
|
||||||
|
delayString.map((d) => {
|
||||||
|
let data = d.split(" ");
|
||||||
|
return (
|
||||||
|
<FlexWidget
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
width: "match_parent",
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
}}
|
||||||
|
key={data[1]}
|
||||||
|
>
|
||||||
|
<TextWidget
|
||||||
|
style={{ flex: 15, fontSize: 20, color: "#000000" }}
|
||||||
|
text={data[0].replace("\n", "")}
|
||||||
|
/>
|
||||||
|
<TextWidget
|
||||||
|
style={{ flex: 5, fontSize: 20, color: "#000000" }}
|
||||||
|
text={data[1]}
|
||||||
|
/>
|
||||||
|
<TextWidget
|
||||||
|
style={{ flex: 6, fontSize: 20, color: "#000000" }}
|
||||||
|
text={data[3]}
|
||||||
|
/>
|
||||||
|
</FlexWidget>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<TextWidget
|
||||||
|
style={{
|
||||||
|
color: "#000000",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
現在、5分以上の遅れはありません。
|
||||||
|
</TextWidget>
|
||||||
|
)}
|
||||||
|
</FlexWidget>
|
||||||
|
</FlexWidget>
|
||||||
|
);
|
||||||
|
}
|
25
components/AndroidWidget/HelloWidgetPreviewScreen.jsx
Normal file
25
components/AndroidWidget/HelloWidgetPreviewScreen.jsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
import { StyleSheet, View } from "react-native";
|
||||||
|
import { WidgetPreview } from "react-native-android-widget";
|
||||||
|
|
||||||
|
import { HelloWidget } from "./HelloWidget";
|
||||||
|
|
||||||
|
export function HelloWidgetPreviewScreen() {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<WidgetPreview
|
||||||
|
renderWidget={() => <HelloWidget />}
|
||||||
|
width={320}
|
||||||
|
height={200}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
});
|
55
components/AndroidWidget/widget-task-handler.jsx
Normal file
55
components/AndroidWidget/widget-task-handler.jsx
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { HelloWidget } from "./HelloWidget";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { ToastAndroid } from "react-native";
|
||||||
|
|
||||||
|
const nameToWidget = {
|
||||||
|
// Hello will be the **name** with which we will reference our widget.
|
||||||
|
JR_shikoku_train_info: HelloWidget,
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function widgetTaskHandler(props) {
|
||||||
|
const widgetInfo = props.widgetInfo;
|
||||||
|
const Widget = nameToWidget[widgetInfo.widgetName];
|
||||||
|
const time = dayjs().format("HH:mm");
|
||||||
|
ToastAndroid.show(
|
||||||
|
`Widget Action: ${props.widgetAction} ${time}`,
|
||||||
|
ToastAndroid.SHORT
|
||||||
|
);
|
||||||
|
const delayString = await fetch(
|
||||||
|
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||||
|
)
|
||||||
|
.then((response) => response.text())
|
||||||
|
.then((data) => {
|
||||||
|
if (data !== "") {
|
||||||
|
return data.split("^");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
ToastAndroid.show(`${delayString}`, ToastAndroid.SHORT);
|
||||||
|
switch (props.widgetAction) {
|
||||||
|
case "WIDGET_ADDED":
|
||||||
|
case "WIDGET_UPDATE":
|
||||||
|
// Not needed for now
|
||||||
|
case "WIDGET_CLICK":
|
||||||
|
// Not needed for now
|
||||||
|
case "WIDGET_RESIZED":
|
||||||
|
// Not needed for now
|
||||||
|
props.renderWidget(<Widget time={time} delayString={delayString} />);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "WIDGET_DELETED":
|
||||||
|
// Not needed for now
|
||||||
|
break;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
11
index.js
Normal file
11
index.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { registerRootComponent } from "expo";
|
||||||
|
import { registerWidgetTaskHandler } from "react-native-android-widget";
|
||||||
|
|
||||||
|
import App from "./App";
|
||||||
|
import { widgetTaskHandler } from "./components/AndroidWidget/widget-task-handler";
|
||||||
|
|
||||||
|
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
|
||||||
|
// It also ensures that whether you load the app in Expo Go or in a native build,
|
||||||
|
// the environment is set up appropriately
|
||||||
|
registerRootComponent(App);
|
||||||
|
registerWidgetTaskHandler(widgetTaskHandler);
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"main": "node_modules/expo/AppEntry.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "expo start",
|
"start": "expo start",
|
||||||
"android": "expo start --android",
|
"android": "expo start --android",
|
||||||
@ -31,6 +31,7 @@
|
|||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-native": "0.72.6",
|
"react-native": "0.72.6",
|
||||||
"react-native-actions-sheet": "0.8.21",
|
"react-native-actions-sheet": "0.8.21",
|
||||||
|
"react-native-android-widget": "^0.11.2",
|
||||||
"react-native-auto-height-image": "^3.2.4",
|
"react-native-auto-height-image": "^3.2.4",
|
||||||
"react-native-elements": "^3.4.2",
|
"react-native-elements": "^3.4.2",
|
||||||
"react-native-gesture-handler": "~2.12.0",
|
"react-native-gesture-handler": "~2.12.0",
|
||||||
|
@ -8684,6 +8684,11 @@ react-native-actions-sheet@0.8.21:
|
|||||||
resolved "https://registry.yarnpkg.com/react-native-actions-sheet/-/react-native-actions-sheet-0.8.21.tgz#d9175e7d5d862217f990b2ccc8a216fb4fc35b06"
|
resolved "https://registry.yarnpkg.com/react-native-actions-sheet/-/react-native-actions-sheet-0.8.21.tgz#d9175e7d5d862217f990b2ccc8a216fb4fc35b06"
|
||||||
integrity sha512-WUtrGbPSlY8YuVSxKVJ36f3PrVMGMOQ5Cp5dtpurc71Uih4LEGGhEEk8yme/QOquiGsu77be0sZT4CrSUOSXag==
|
integrity sha512-WUtrGbPSlY8YuVSxKVJ36f3PrVMGMOQ5Cp5dtpurc71Uih4LEGGhEEk8yme/QOquiGsu77be0sZT4CrSUOSXag==
|
||||||
|
|
||||||
|
react-native-android-widget@^0.11.2:
|
||||||
|
version "0.11.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-native-android-widget/-/react-native-android-widget-0.11.2.tgz#541cc4931f6cf362b533d0e079a740ee595cd88e"
|
||||||
|
integrity sha512-Ro4inoMaXFtcMX/9p+O+e/Cm0ckg6tkbIB/PFdF+xX90+B/2sWjXDL9qgGRAsFN7Auj38hMqTl8bWBlImFCC2A==
|
||||||
|
|
||||||
react-native-auto-height-image@^3.2.4:
|
react-native-auto-height-image@^3.2.4:
|
||||||
version "3.2.4"
|
version "3.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/react-native-auto-height-image/-/react-native-auto-height-image-3.2.4.tgz#c7a95d4d9701055c680c8dc02076def1107f9522"
|
resolved "https://registry.yarnpkg.com/react-native-auto-height-image/-/react-native-auto-height-image-3.2.4.tgz#c7a95d4d9701055c680c8dc02076def1107f9522"
|
||||||
|
Loading…
Reference in New Issue
Block a user