From 1f9c3064bf16c57119af415804c7f3bf495927ff Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Thu, 7 Mar 2024 12:56:19 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=82=B8=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=81=AE=E6=A0=B8=E3=81=A8=E3=81=AA=E3=82=8B=E4=BB=95?= =?UTF-8?q?=E7=B5=84=E3=81=BF=E3=81=8C=E5=AE=8C=E6=88=90=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=81=A7=E4=B8=80=E6=97=A6=E3=81=93=E3=82=8C=E3=81=A7?= =?UTF-8?q?=E4=BB=95=E7=B5=84=E3=81=BF=E3=81=A8=E3=81=97=E3=81=A6=E3=81=AF?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AndroidWidget/HelloWidget.jsx | 76 +++++++++++++++++-- .../AndroidWidget/widget-task-handler.jsx | 38 +++++++--- 2 files changed, 97 insertions(+), 17 deletions(-) diff --git a/components/AndroidWidget/HelloWidget.jsx b/components/AndroidWidget/HelloWidget.jsx index af64fe1..12741ad 100644 --- a/components/AndroidWidget/HelloWidget.jsx +++ b/components/AndroidWidget/HelloWidget.jsx @@ -1,7 +1,7 @@ import React from "react"; import { FlexWidget, TextWidget } from "react-native-android-widget"; -export function HelloWidget() { +export function HelloWidget({ time, delayString }) { return ( - + > + + + + + + {delayString ? ( + delayString.map((d) => { + let data = d.split(" "); + return ( + + + + + + ); + }) + ) : ( + + 現在、5分以上の遅れはありません。 + + )} + ); } diff --git a/components/AndroidWidget/widget-task-handler.jsx b/components/AndroidWidget/widget-task-handler.jsx index e4c371a..f644228 100644 --- a/components/AndroidWidget/widget-task-handler.jsx +++ b/components/AndroidWidget/widget-task-handler.jsx @@ -1,34 +1,52 @@ 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. - Hello: HelloWidget, + 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": - props.renderWidget(); - break; - case "WIDGET_UPDATE": - // Not needed for now - break; - + // Not needed for now + case "WIDGET_CLICK": + // Not needed for now case "WIDGET_RESIZED": // Not needed for now + props.renderWidget(); + + break; + + break; + break; case "WIDGET_DELETED": // Not needed for now break; - case "WIDGET_CLICK": - // Not needed for now break; default: