Skip to content

Commit

Permalink
20240418 update
Browse files Browse the repository at this point in the history
  • Loading branch information
neko0xff committed Apr 18, 2024
1 parent 6b45dfa commit 0b3983c
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 81 deletions.
1 change: 1 addition & 0 deletions src/demo/viewapp_master/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
// ignore: unnecessary_import
import 'package:flutter/services.dart';
import 'package:pwa_install/pwa_install.dart';
import 'package:viewapp_master/pages/out/about.dart';
Expand Down
3 changes: 3 additions & 0 deletions src/demo/viewapp_master/lib/pages/btn/ctr/switchCtr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ControlPage extends StatelessWidget {
Text("開關控制",
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Text("請等候30秒的時間等待指令生效(依現場的網路而定)",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Text("Switch01",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Expand Down
2 changes: 1 addition & 1 deletion src/demo/viewapp_master/lib/pages/chart/bar_sensor01.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, non_constant_identifier_names, prefer_interpolation_to_compose_strings, avoid_print, camel_case_types, must_be_immutable, file_names
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, non_constant_identifier_names, prefer_interpolation_to_compose_strings, avoid_print, camel_case_types, must_be_immutable, file_names, depend_on_referenced_packages
import 'dart:convert';

import 'package:fl_chart/fl_chart.dart';
Expand Down
2 changes: 1 addition & 1 deletion src/demo/viewapp_master/lib/pages/table/usermode.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, non_constant_identifier_names, prefer_interpolation_to_compose_strings, avoid_print, camel_case_types
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, library_private_types_in_public_api, non_constant_identifier_names, prefer_interpolation_to_compose_strings, avoid_print, camel_case_types, depend_on_referenced_packages
import 'dart:convert';

import 'package:flutter/material.dart';
Expand Down
36 changes: 30 additions & 6 deletions src/demo/viewapp_master/lib/pages/widget/switch01ctr.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore_for_file: library_private_types_in_public_api, non_constant_identifier_names, avoid_print
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:viewapp_master/modules/PreferencesUtil.dart';
Expand Down Expand Up @@ -27,14 +29,36 @@ class _Switch01ctrState extends State<Switch01ctr> {
}

void _getSwitchStatus() async {
bool? fan1Status = await PreferencesUtil.getBool("fan1ctr");
bool? fan2Status = await PreferencesUtil.getBool("fan2ctr");
setState(() {
_switchSelectedFan1 = fan1Status ?? false;
_switchSelectedFan2 = fan2Status ?? false;
});
final String? serverSource = await PreferencesUtil.getString("serverSource");
final Uri url = Uri.parse('http://$serverSource/read/statusNow/$setboards/viewALL');

try {
final response = await http.get(url);
if (response.statusCode == 200) {
final List<dynamic> data = json.decode(response.body);
data.forEach((switchData) {
final String name = switchData['name'];
final bool status = switchData['status'] == 1;
if (name == 'fan1') {
setState(() {
_switchSelectedFan1 = status;
});
} else if (name == 'fan2') {
setState(() {
_switchSelectedFan2 = status;
});
}
});
} else {
throw Exception('Failed to load switch status');
}
} catch (e) {
print('Error: $e');
}
}



void _connectToServer() async {
/*連線部分*/
final String? serverSource =
Expand Down
72 changes: 36 additions & 36 deletions src/demo/viewapp_master/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.4.2"
version: "2.5.0"
async:
dependency: transitive
description:
Expand All @@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: barcode
sha256: "91b143666f7bb13636f716b6d4e412e372ab15ff7969799af8c9e30a382e9385"
sha256: "1fe4a55344505850517ce72d4a3a7b9ccf51b0dc1631ee7e552f6eacc4947f96"
url: "https://pub.dev"
source: hosted
version: "2.2.6"
version: "2.2.7"
bazel_worker:
dependency: transitive
description:
Expand Down Expand Up @@ -117,10 +117,10 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21"
sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22"
url: "https://pub.dev"
source: hosted
version: "2.4.8"
version: "2.4.9"
build_runner_core:
dependency: transitive
description:
Expand Down Expand Up @@ -149,10 +149,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e
sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb
url: "https://pub.dev"
source: hosted
version: "8.9.1"
version: "8.9.2"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -229,10 +229,10 @@ packages:
dependency: "direct overridden"
description:
name: cupertino_icons
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev"
source: hosted
version: "1.0.6"
version: "1.0.8"
dart_style:
dependency: transitive
description:
Expand Down Expand Up @@ -340,10 +340,10 @@ packages:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
url: "https://pub.dev"
source: hosted
version: "3.2.0"
version: "4.0.0"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -524,18 +524,18 @@ packages:
dependency: "direct overridden"
description:
name: path_provider
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.3"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.2.4"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -612,10 +612,10 @@ packages:
dependency: transitive
description:
name: pointycastle
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333"
url: "https://pub.dev"
source: hosted
version: "3.7.4"
version: "3.8.0"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -700,18 +700,18 @@ packages:
dependency: "direct overridden"
description:
name: shared_preferences
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.2.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06"
sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
shared_preferences_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -929,18 +929,18 @@ packages:
dependency: "direct overridden"
description:
name: url_launcher
sha256: "0ecc004c62fd3ed36a2ffcbe0dd9700aee63bd7532d0b642a488b1ec310f492e"
sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e"
url: "https://pub.dev"
source: hosted
version: "6.2.5"
version: "6.2.6"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: d4ed0711849dd8e33eb2dd69c25db0d0d3fdc37e0a62e629fe32f57a22db2745
sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775"
url: "https://pub.dev"
source: hosted
version: "6.3.0"
version: "6.3.1"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -977,10 +977,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "3692a459204a33e04bc94f5fb91158faf4f2c8903281ddd82915adecdb1a901d"
sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a"
url: "https://pub.dev"
source: hosted
version: "2.3.0"
version: "2.3.1"
url_launcher_windows:
dependency: transitive
description:
Expand All @@ -993,10 +993,10 @@ packages:
dependency: transitive
description:
name: uuid
sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8
sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
url: "https://pub.dev"
source: hosted
version: "4.3.3"
version: "4.4.0"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -1033,26 +1033,26 @@ packages:
dependency: transitive
description:
name: web_socket_channel
sha256: "1d8e795e2a8b3730c41b8a98a2dff2e0fb57ae6f0764a1c46ec5915387d257b2"
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
url: "https://pub.dev"
source: hosted
version: "2.4.4"
version: "2.4.5"
win32:
dependency: transitive
description:
name: win32
sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
sha256: "0a989dc7ca2bb51eac91e8fd00851297cfffd641aa7538b165c62637ca0eaa4a"
url: "https://pub.dev"
source: hosted
version: "5.3.0"
version: "5.4.0"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a"
sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.1.3"
xdg_directories:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions src/demo/viewapp_master/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ flutter:
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
fonts:
- family: NotoSerifHK
fonts:
- asset: fonts/NotoSerifHK-Medium.ttf

flutter_icons:
android: "launcher_icon"
Expand Down
3 changes: 3 additions & 0 deletions src/demo/viewapp_user/lib/pages/btn/ctr/switchCtr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ControlPage extends StatelessWidget {
Text("開關控制",
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Text("請等候30秒的時間等待指令生效(依現場的網路而定)",
style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Text("Switch01",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
SizedBox(height: 10.0),
Expand Down
2 changes: 1 addition & 1 deletion src/demo/viewapp_user/lib/pages/table/switch01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class _SwitchTable1State extends State<SwitchTable1> {
style: const TextStyle(fontSize: 25)),
),
DataCell(
Text('${data[index]["status"]}',
Text(data[index]["status"] == 0 ? "關" : "開",
style: const TextStyle(fontSize: 25)),
),
],
Expand Down
34 changes: 28 additions & 6 deletions src/demo/viewapp_user/lib/pages/widget/switch01ctr.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore_for_file: library_private_types_in_public_api, non_constant_identifier_names, avoid_print
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:viewapp_user/modules/PreferencesUtil.dart';
Expand Down Expand Up @@ -27,12 +29,32 @@ class _Switch01ctrState extends State<Switch01ctr> {
}

void _getSwitchStatus() async {
bool? fan1Status = await PreferencesUtil.getBool("fan1ctr");
bool? fan2Status = await PreferencesUtil.getBool("fan2ctr");
setState(() {
_switchSelectedFan1 = fan1Status ?? false;
_switchSelectedFan2 = fan2Status ?? false;
});
final String? serverSource = await PreferencesUtil.getString("serverSource");
final Uri url = Uri.parse('http://$serverSource/read/statusNow/$setboards/viewALL');

try {
final response = await http.get(url);
if (response.statusCode == 200) {
final List<dynamic> data = json.decode(response.body);
data.forEach((switchData) {
final String name = switchData['name'];
final bool status = switchData['status'] == 1;
if (name == 'fan1') {
setState(() {
_switchSelectedFan1 = status;
});
} else if (name == 'fan2') {
setState(() {
_switchSelectedFan2 = status;
});
}
});
} else {
throw Exception('Failed to load switch status');
}
} catch (e) {
print('Error: $e');
}
}

void _connectToServer() async {
Expand Down
Loading

0 comments on commit 0b3983c

Please sign in to comment.