Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
KageRyo committed Nov 5, 2024
2 parents 876bf91 + b2a170c commit dd8f66a
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ yarn-error.*
# API config file
./WaterMirror/src/config.json
WaterMirror/src/config.json

# config files
./src/config.json
File renamed without changes.
5 changes: 0 additions & 5 deletions WaterMirror/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions WaterMirror/src/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion WaterMirror/app.json → app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "WaterMirror",
"slug": "WaterMirror",
"version": "1.0.7",
"version": "1.1.2",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions WaterMirror/i18n/en.json → i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": {
"name": "WaterMirror",
"subtitle": "Smart Water Quality Analysis and Assessment System",
"version": "Version: WaterMirror-{{platform}}-v1.1.1"
"subtitle": "Intelligent Water Quality Analysis and Improvement Assessment System",
"version": "Version: WaterMirror-{{platform}}-v1.1.2"
},
"nav": {
"home": "Home",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions WaterMirror/i18n/ja.json → i18n/ja.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": {
"name": "WaterMirror",
"subtitle": "スマート水質分析評価システム",
"version": "バージョン:WaterMirror-{{platform}}-v1.1.1"
"subtitle": "インテリジェント水質分析と改善評価システム",
"version": "バージョン:WaterMirror-{{platform}}-v1.1.2"
},
"nav": {
"home": "ホーム",
Expand Down
4 changes: 2 additions & 2 deletions WaterMirror/i18n/zh-CN.json → i18n/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": {
"name": "WaterMirror",
"subtitle": "智能化水质分析与评估系统",
"version": "版本:WaterMirror-{{platform}}-v1.1.1"
"subtitle": "智能水质分析与改善评估系统",
"version": "版本:WaterMirror-{{platform}}-v1.1.2"
},
"nav": {
"home": "首页",
Expand Down
4 changes: 2 additions & 2 deletions WaterMirror/i18n/zh-TW.json → i18n/zh-TW.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": {
"name": "WaterMirror",
"subtitle": "智慧化水質分析與評估系統",
"version": "版本:WaterMirror-{{platform}}-v1.1.1"
"subtitle": "智慧水質分析與改善評估系統",
"version": "版本:WaterMirror-{{platform}}-v1.1.2"
},
"nav": {
"home": "首頁",
Expand Down
83 changes: 83 additions & 0 deletions WaterMirror/package-lock.json → package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions WaterMirror/package.json → package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@expo/ngrok": "^4.1.3",
"@expo/react-native-action-sheet": "^4.1.0",
"@react-native-async-storage/async-storage": "^1.24.0",
"@react-native-picker/picker": "2.7.5",
"@react-navigation/native": "^6.1.17",
Expand Down
2 changes: 1 addition & 1 deletion WaterMirror/src/Calc.js → src/Calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useServerConnection = (apiUrl) => {
const [status, setStatus] = useState(t('calc.connection.connecting'));

useEffect(() => {
const checkTimeout = 5000;
const checkTimeout = 3000;
const intervalId = setInterval(() => checkConnection(), checkTimeout);
return () => clearInterval(intervalId);
}, []);
Expand Down
82 changes: 54 additions & 28 deletions WaterMirror/src/Home.js → src/Home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { Alert, Image, Linking, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { Alert, Image, Linking, Platform, StyleSheet, Text, TouchableOpacity, View, ActionSheet } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useTranslation } from 'react-i18next';
import { useLanguage } from '../contexts/LanguageContext';
import { ActionSheetProvider, useActionSheet } from '@expo/react-native-action-sheet';

import GitHubMark from '../assets/github-mark.png';
const githubUrl = 'https://github.com/KageRyo/WaterMirror';
Expand All @@ -27,33 +28,45 @@ const TopSection = () => {
const BtnSection = ({ navigation }) => {
const { t } = useTranslation();
const { currentLanguage, changeLanguage } = useLanguage();
const { showActionSheetWithOptions } = useActionSheet();

const handleLanguageSwitch = () => {
Alert.alert(
t('language.select'),
'',
[
{
text: '正體中文',
onPress: () => changeLanguage('zh-TW')
},
{
text: '简体中文',
onPress: () => changeLanguage('zh-CN')
},
{
text: 'English',
onPress: () => changeLanguage('en')
},
{
text: '日本語',
onPress: () => changeLanguage('ja')
},
{
text: t('buttons.cancel'),
style: 'cancel'
const options = [
{
text: '正體中文',
onPress: () => changeLanguage('zh-TW')
},
{
text: '简体中文',
onPress: () => changeLanguage('zh-CN')
},
{
text: 'English',
onPress: () => changeLanguage('en')
},
{
text: '日本語',
onPress: () => changeLanguage('ja')
},
{
text: t('buttons.cancel'),
style: 'cancel'
}
];

// 使用 ActionSheet 顯示選單
const buttonTitles = options.map(option => option.text);
showActionSheetWithOptions(
{
options: buttonTitles,
cancelButtonIndex: options.length - 1,
title: t('language.select')
},
buttonIndex => {
if (buttonIndex !== options.length - 1) {
options[buttonIndex].onPress();
}
]
}
);
};

Expand Down Expand Up @@ -97,8 +110,12 @@ const BtnSection = ({ navigation }) => {
Alert.alert(t('alerts.notice'), t('alerts.pleaseInputData'));
return;
}
} else if (route.startsWith('http')) {
Linking.openURL(route);
} else if (route.startsWith('http') || route.startsWith('mailto:')) {
try {
await Linking.openURL(route);
} catch {
// 不執行任何操作以隱藏錯誤訊息
}
} else {
navigation.navigate(route);
}
Expand Down Expand Up @@ -164,7 +181,7 @@ const openGitHub = () => {
};

// 畫面視窗
export default function HomeScreen() {
export function HomeScreen() {
const navigation = useNavigation();
return (
<View style={styles.container}>
Expand Down Expand Up @@ -268,3 +285,12 @@ const bottomStyles = StyleSheet.create({
height: 50,
},
});

// 確保在應用的根組件中包裹 ActionSheetProvider
export default function App() {
return (
<ActionSheetProvider>
<HomeScreen />
</ActionSheetProvider>
);
}
File renamed without changes.
4 changes: 4 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"api_url": "http://34.80.131.233", //例如:http://0.0.0.0
"port": "8000" // 例如:8000
}

0 comments on commit dd8f66a

Please sign in to comment.