Skip to content

Commit dd8f66a

Browse files
committed
Merge branch 'develop'
2 parents 876bf91 + b2a170c commit dd8f66a

23 files changed

+155
-47
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ yarn-error.*
3737
# API config file
3838
./WaterMirror/src/config.json
3939
WaterMirror/src/config.json
40+
41+
# config files
42+
./src/config.json

WaterMirror/App.js App.js

File renamed without changes.

WaterMirror/.gitignore

-5
This file was deleted.

WaterMirror/src/config.json

-4
This file was deleted.

WaterMirror/app.json app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "WaterMirror",
44
"slug": "WaterMirror",
5-
"version": "1.0.7",
5+
"version": "1.1.2",
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",
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.

WaterMirror/i18n/en.json i18n/en.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"app": {
33
"name": "WaterMirror",
4-
"subtitle": "Smart Water Quality Analysis and Assessment System",
5-
"version": "Version: WaterMirror-{{platform}}-v1.1.1"
4+
"subtitle": "Intelligent Water Quality Analysis and Improvement Assessment System",
5+
"version": "Version: WaterMirror-{{platform}}-v1.1.2"
66
},
77
"nav": {
88
"home": "Home",
File renamed without changes.

WaterMirror/i18n/ja.json i18n/ja.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"app": {
33
"name": "WaterMirror",
4-
"subtitle": "スマート水質分析評価システム",
5-
"version": "バージョン:WaterMirror-{{platform}}-v1.1.1"
4+
"subtitle": "インテリジェント水質分析と改善評価システム",
5+
"version": "バージョン:WaterMirror-{{platform}}-v1.1.2"
66
},
77
"nav": {
88
"home": "ホーム",

WaterMirror/i18n/zh-CN.json i18n/zh-CN.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"app": {
33
"name": "WaterMirror",
4-
"subtitle": "智能化水质分析与评估系统",
5-
"version": "版本:WaterMirror-{{platform}}-v1.1.1"
4+
"subtitle": "智能水质分析与改善评估系统",
5+
"version": "版本:WaterMirror-{{platform}}-v1.1.2"
66
},
77
"nav": {
88
"home": "首页",

WaterMirror/i18n/zh-TW.json i18n/zh-TW.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"app": {
33
"name": "WaterMirror",
4-
"subtitle": "智慧化水質分析與評估系統",
5-
"version": "版本:WaterMirror-{{platform}}-v1.1.1"
4+
"subtitle": "智慧水質分析與改善評估系統",
5+
"version": "版本:WaterMirror-{{platform}}-v1.1.2"
66
},
77
"nav": {
88
"home": "首頁",

WaterMirror/package-lock.json package-lock.json

+83
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WaterMirror/package.json package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@expo/ngrok": "^4.1.3",
13+
"@expo/react-native-action-sheet": "^4.1.0",
1314
"@react-native-async-storage/async-storage": "^1.24.0",
1415
"@react-native-picker/picker": "2.7.5",
1516
"@react-navigation/native": "^6.1.17",

WaterMirror/src/Calc.js src/Calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const useServerConnection = (apiUrl) => {
3535
const [status, setStatus] = useState(t('calc.connection.connecting'));
3636

3737
useEffect(() => {
38-
const checkTimeout = 5000;
38+
const checkTimeout = 3000;
3939
const intervalId = setInterval(() => checkConnection(), checkTimeout);
4040
return () => clearInterval(intervalId);
4141
}, []);

WaterMirror/src/Home.js src/Home.js

+54-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
2-
import { Alert, Image, Linking, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
2+
import { Alert, Image, Linking, Platform, StyleSheet, Text, TouchableOpacity, View, ActionSheet } from 'react-native';
33
import { useNavigation } from '@react-navigation/native';
44
import AsyncStorage from '@react-native-async-storage/async-storage';
55
import { useTranslation } from 'react-i18next';
66
import { useLanguage } from '../contexts/LanguageContext';
7+
import { ActionSheetProvider, useActionSheet } from '@expo/react-native-action-sheet';
78

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

3133
const handleLanguageSwitch = () => {
32-
Alert.alert(
33-
t('language.select'),
34-
'',
35-
[
36-
{
37-
text: '正體中文',
38-
onPress: () => changeLanguage('zh-TW')
39-
},
40-
{
41-
text: '简体中文',
42-
onPress: () => changeLanguage('zh-CN')
43-
},
44-
{
45-
text: 'English',
46-
onPress: () => changeLanguage('en')
47-
},
48-
{
49-
text: '日本語',
50-
onPress: () => changeLanguage('ja')
51-
},
52-
{
53-
text: t('buttons.cancel'),
54-
style: 'cancel'
34+
const options = [
35+
{
36+
text: '正體中文',
37+
onPress: () => changeLanguage('zh-TW')
38+
},
39+
{
40+
text: '简体中文',
41+
onPress: () => changeLanguage('zh-CN')
42+
},
43+
{
44+
text: 'English',
45+
onPress: () => changeLanguage('en')
46+
},
47+
{
48+
text: '日本語',
49+
onPress: () => changeLanguage('ja')
50+
},
51+
{
52+
text: t('buttons.cancel'),
53+
style: 'cancel'
54+
}
55+
];
56+
57+
// 使用 ActionSheet 顯示選單
58+
const buttonTitles = options.map(option => option.text);
59+
showActionSheetWithOptions(
60+
{
61+
options: buttonTitles,
62+
cancelButtonIndex: options.length - 1,
63+
title: t('language.select')
64+
},
65+
buttonIndex => {
66+
if (buttonIndex !== options.length - 1) {
67+
options[buttonIndex].onPress();
5568
}
56-
]
69+
}
5770
);
5871
};
5972

@@ -97,8 +110,12 @@ const BtnSection = ({ navigation }) => {
97110
Alert.alert(t('alerts.notice'), t('alerts.pleaseInputData'));
98111
return;
99112
}
100-
} else if (route.startsWith('http')) {
101-
Linking.openURL(route);
113+
} else if (route.startsWith('http') || route.startsWith('mailto:')) {
114+
try {
115+
await Linking.openURL(route);
116+
} catch {
117+
// 不執行任何操作以隱藏錯誤訊息
118+
}
102119
} else {
103120
navigation.navigate(route);
104121
}
@@ -164,7 +181,7 @@ const openGitHub = () => {
164181
};
165182

166183
// 畫面視窗
167-
export default function HomeScreen() {
184+
export function HomeScreen() {
168185
const navigation = useNavigation();
169186
return (
170187
<View style={styles.container}>
@@ -268,3 +285,12 @@ const bottomStyles = StyleSheet.create({
268285
height: 50,
269286
},
270287
});
288+
289+
// 確保在應用的根組件中包裹 ActionSheetProvider
290+
export default function App() {
291+
return (
292+
<ActionSheetProvider>
293+
<HomeScreen />
294+
</ActionSheetProvider>
295+
);
296+
}
File renamed without changes.

src/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"api_url": "http://34.80.131.233", //例如:http://0.0.0.0
3+
"port": "8000" // 例如:8000
4+
}

0 commit comments

Comments
 (0)