fix: resolve import paths and module loading errors
This commit is contained in:
@@ -5,8 +5,8 @@ import type { NativeStackNavigationProp } from "@react-navigation/native-stack";
|
||||
import type { RootStackParamList } from "@navigation/types";
|
||||
import type { RouteProp } from "@react-navigation/native";
|
||||
import { getWorkoutWithSets } from "@db/operations";
|
||||
import { useSyncWorkout } from "../hooks/useSyncWorkout";
|
||||
import { useWatchConnection } from "../hooks/useWatchConnection";
|
||||
import { useSyncWorkout } from "../../watch-connectivity/hooks/useSyncWorkout";
|
||||
import { useWatchConnection } from "../../watch-connectivity/hooks/useWatchConnection";
|
||||
import { formatDistance } from "@utils/formatDistance";
|
||||
import { STROKE_COLORS } from "@constants/strokes";
|
||||
import type { WorkoutSet } from "@types/workout";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { View, Text, Pressable } from "react-native";
|
||||
import { useSettings } from "../../providers/WatchProvider";
|
||||
import { useSettings } from "../../../providers/WatchProvider";
|
||||
|
||||
export function SettingsScreen() {
|
||||
const { poolLength, setPoolLength } = useSettings();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import WatchConnectivity from "../../modules/watch-connectivity";
|
||||
import WatchConnectivity from "../../../modules/watch-connectivity";
|
||||
import type { WorkoutSet } from "@types/workout";
|
||||
|
||||
type SyncResult = { status: string } | { error: string };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import WatchConnectivity from "../../modules/watch-connectivity";
|
||||
import WatchConnectivity from "../../../modules/watch-connectivity";
|
||||
|
||||
type WatchConnectionStatus = "connected" | "disconnected" | "pending";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import WatchConnectivity from "../../modules/watch-connectivity";
|
||||
import WatchConnectivity from "../../../modules/watch-connectivity";
|
||||
|
||||
export function useWatchReachability() {
|
||||
const [isReachable, setIsReachable] = useState(false);
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import ExpoModulesCore
|
||||
|
||||
public class WatchConnectivityModule: Module {
|
||||
public func definition() -> Definition {
|
||||
Name("WatchConnectivity")
|
||||
|
||||
AsyncFunction("isSupported") { () -> Bool in
|
||||
return WCSession.isSupported()
|
||||
}
|
||||
|
||||
AsyncFunction("isPaired") { () -> Bool in
|
||||
return WCSession.default.isPaired
|
||||
}
|
||||
|
||||
AsyncFunction("isWatchAppInstalled") { () -> Bool in
|
||||
return WCSession.default.isWatchAppInstalled
|
||||
}
|
||||
|
||||
AsyncFunction("isReachable") { () -> Bool in
|
||||
return WCSession.default.isReachable
|
||||
}
|
||||
|
||||
AsyncFunction("sendWorkoutPlan") { (plan: [String: Any], promise: Promise) in
|
||||
var message = plan
|
||||
message["type"] = "workoutPlan"
|
||||
|
||||
if WCSession.default.isReachable {
|
||||
WCSession.default.sendMessage(message, replyHandler: { reply in
|
||||
promise.resolve(reply)
|
||||
}, errorHandler: { error in
|
||||
promise.reject(error)
|
||||
})
|
||||
} else {
|
||||
WCSession.default.transferUserInfo(message)
|
||||
promise.resolve(["status": "queued"])
|
||||
}
|
||||
}
|
||||
|
||||
AsyncFunction("sendWorkoutCompletion") { (data: [String: Any], promise: Promise) in
|
||||
var message = data
|
||||
message["type"] = "workoutCompleted"
|
||||
|
||||
if WCSession.default.isReachable {
|
||||
WCSession.default.sendMessage(message, replyHandler: { reply in
|
||||
promise.resolve(reply)
|
||||
}, errorHandler: { error in
|
||||
promise.reject(error)
|
||||
})
|
||||
} else {
|
||||
WCSession.default.transferUserInfo(message)
|
||||
promise.resolve(["status": "queued"])
|
||||
}
|
||||
}
|
||||
|
||||
AsyncFunction("getApplicationContext") { () -> [String: Any]? in
|
||||
return WCSession.default.receivedApplicationContext as? [String: Any]
|
||||
}
|
||||
|
||||
AsyncFunction("updateApplicationContext") { (context: [String: Any]) in
|
||||
try? WCSession.default.updateApplicationContext(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,16 @@
|
||||
import { requireNativeModule } from "expo-modules-core";
|
||||
import { requireOptionalNativeModule } from "expo-modules-core";
|
||||
|
||||
export default requireNativeModule("WatchConnectivity");
|
||||
let WatchConnectivity: any;
|
||||
|
||||
WatchConnectivity = requireOptionalNativeModule("WatchConnectivity") ?? {
|
||||
isSupported: async () => false,
|
||||
isPaired: async () => false,
|
||||
isWatchAppInstalled: async () => false,
|
||||
isReachable: async () => false,
|
||||
sendWorkoutPlan: async () => ({ error: "WatchConnectivity native module not available" }),
|
||||
sendWorkoutCompletion: async () => ({ error: "WatchConnectivity native module not available" }),
|
||||
getApplicationContext: async () => null,
|
||||
updateApplicationContext: async () => {},
|
||||
};
|
||||
|
||||
export default WatchConnectivity;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
|
||||
import { MMKV } from "react-native-mmkv";
|
||||
import { createMMKV } from "react-native-mmkv";
|
||||
|
||||
const storage = new MMKV();
|
||||
const storage = createMMKV();
|
||||
|
||||
type SettingsContextType = {
|
||||
poolLength: number;
|
||||
|
||||
Reference in New Issue
Block a user