From a21593dc2cebf72ca7f3eeff14b54de16e900fd6 Mon Sep 17 00:00:00 2001 From: Jack Misner Date: Sun, 30 Nov 2025 11:53:15 +0000 Subject: [PATCH 1/2] Add offline awareness to AI button and update offline FG calculation --- android/app/build.gradle | 4 ++-- android/app/src/main/res/values/strings.xml | 2 +- app.json | 6 +++--- package-lock.json | 4 ++-- package.json | 2 +- src/components/recipes/AIAnalysisButton.tsx | 14 ++++++++++---- src/services/brewing/OfflineMetricsCalculator.ts | 5 +++-- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4f82bcbf..6fb253cd 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -92,8 +92,8 @@ android { applicationId 'com.brewtracker.android' minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 190 - versionName "3.2.5" + versionCode 191 + versionName "3.2.6" buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "\"${findProperty('reactNativeReleaseLevel') ?: 'stable'}\"" } diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 15ad49bb..a7bd023e 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ BrewTracker automatic - 3.2.5 + 3.2.6 contain false \ No newline at end of file diff --git a/app.json b/app.json index efc68f05..9d3b4108 100644 --- a/app.json +++ b/app.json @@ -3,7 +3,7 @@ "name": "BrewTracker", "slug": "brewtracker-android", "orientation": "portrait", - "version": "3.2.5", + "version": "3.2.6", "icon": "./assets/images/BrewTrackerAndroidLogo.png", "scheme": "brewtracker", "userInterfaceStyle": "automatic", @@ -16,7 +16,7 @@ }, "edgeToEdgeEnabled": true, "package": "com.brewtracker.android", - "versionCode": 190, + "versionCode": 191, "permissions": [ "CAMERA", "VIBRATE", @@ -58,7 +58,7 @@ } }, "owner": "jackmisner", - "runtimeVersion": "3.2.5", + "runtimeVersion": "3.2.6", "updates": { "url": "https://u.expo.dev/edf222a8-b532-4d12-9b69-4e7fbb1d41c2" } diff --git a/package-lock.json b/package-lock.json index b19a2d81..db462527 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "brewtracker", - "version": "3.2.5", + "version": "3.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "brewtracker", - "version": "3.2.5", + "version": "3.2.6", "license": "GPL-3.0-or-later", "dependencies": { "@expo/metro-runtime": "~6.1.2", diff --git a/package.json b/package.json index 536c73af..5802bc6c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "brewtracker", "main": "expo-router/entry", - "version": "3.2.5", + "version": "3.2.6", "license": "GPL-3.0-or-later", "scripts": { "start": "expo start", diff --git a/src/components/recipes/AIAnalysisButton.tsx b/src/components/recipes/AIAnalysisButton.tsx index bbf972f7..f9bfd8d9 100644 --- a/src/components/recipes/AIAnalysisButton.tsx +++ b/src/components/recipes/AIAnalysisButton.tsx @@ -21,13 +21,14 @@ * ``` */ -import React from "react"; +import { useContext } from "react"; import { TouchableOpacity, Text, ActivityIndicator, View } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { useTheme } from "@contexts/ThemeContext"; import { createAIStyles } from "@styles/ai/aiStyles"; import { TEST_IDS } from "@src/constants/testIDs"; +import NetworkContext from "@/src/contexts/NetworkContext"; interface AIAnalysisButtonProps { /** @@ -75,9 +76,14 @@ export function AIAnalysisButton({ }: AIAnalysisButtonProps) { const theme = useTheme(); const styles = createAIStyles(theme); - - const isDisabled = disabled || loading; - const displayLabel = loading ? loadingLabel : label; + const useNetwork = useContext(NetworkContext); + const isOffline = useNetwork?.isOffline ?? true; + const isDisabled = disabled || isOffline || loading; + const displayLabel = loading + ? loadingLabel + : isOffline + ? "Go Online to Analyse with AI" + : label; return ( 0 ? totalAttenuation / attenuationCount : 75; // Default 75% attenuation + attenuationCount > 0 ? totalAttenuation / attenuationCount : 0; // Calculate FG: FG = OG - ((OG - 1) * attenuation/100) const gravityPoints = (og - 1) * 1000; From 257b8a159c3bb322413c0e555eff03406528cf02 Mon Sep 17 00:00:00 2001 From: Jack Misner Date: Sun, 30 Nov 2025 12:03:16 +0000 Subject: [PATCH 2/2] - Use useNetwork hook directly instead of manually calling useContext - Add offline awareness to AIAnalysisIconButton --- src/components/recipes/AIAnalysisButton.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/recipes/AIAnalysisButton.tsx b/src/components/recipes/AIAnalysisButton.tsx index f9bfd8d9..4aa68bc0 100644 --- a/src/components/recipes/AIAnalysisButton.tsx +++ b/src/components/recipes/AIAnalysisButton.tsx @@ -21,14 +21,13 @@ * ``` */ -import { useContext } from "react"; import { TouchableOpacity, Text, ActivityIndicator, View } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { useTheme } from "@contexts/ThemeContext"; import { createAIStyles } from "@styles/ai/aiStyles"; import { TEST_IDS } from "@src/constants/testIDs"; -import NetworkContext from "@/src/contexts/NetworkContext"; +import { useNetwork } from "@/src/contexts/NetworkContext"; interface AIAnalysisButtonProps { /** @@ -76,8 +75,7 @@ export function AIAnalysisButton({ }: AIAnalysisButtonProps) { const theme = useTheme(); const styles = createAIStyles(theme); - const useNetwork = useContext(NetworkContext); - const isOffline = useNetwork?.isOffline ?? true; + const { isOffline } = useNetwork(); const isDisabled = disabled || isOffline || loading; const displayLabel = loading ? loadingLabel @@ -131,7 +129,8 @@ export function AIAnalysisIconButton({ }: Pick) { const theme = useTheme(); const styles = createAIStyles(theme); - const isDisabled = disabled || loading; + const { isOffline } = useNetwork(); + const isDisabled = disabled || isOffline || loading; return (