Skip to content

Commit

Permalink
💾 Feat(TestPage): Added waker related buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Feb 19, 2024
1 parent 494aa13 commit d57ebca
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 26 deletions.
13 changes: 9 additions & 4 deletions kitx_mobile/lib/instances.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:kitx_mobile/data/app_info.dart';
import 'package:kitx_mobile/data/local_device_info.dart';
import 'package:kitx_mobile/data/local_network_info.dart';
Expand Down Expand Up @@ -51,17 +53,20 @@ class Instances {
/// Instance for [DeviceService] class
var devicesService = DeviceService();

/// Is in debug mode
var isDebugMode = kDebugMode.obs;

/// Init [Instances] class
Future<void> initAsync() async {
appInfo = (await appInfo.init()).updateTheme(useMaterial3: appInfo.material3Enabled);
deviceInfo = await LocalDeviceInfo.get();
networkInfo = await LocalNetworkInfo.get();

connectivity.onConnectivityChanged.listen(
(result) async => {
instances.deviceInfo = await LocalDeviceInfo.get(),
instances.networkInfo = await LocalNetworkInfo.get(),
restartDevicesServer(),
(result) async {
instances.deviceInfo = await LocalDeviceInfo.get();
instances.networkInfo = await LocalNetworkInfo.get();
restartDevicesServer();
},
);

Expand Down
6 changes: 3 additions & 3 deletions kitx_mobile/lib/pages/controls/device_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class _DeviceCard extends State<DeviceCard> with TickerProviderStateMixin {
var result = info.device.deviceName;

if (info.device.deviceName == instances.deviceInfo.deviceName) {
result += ' ${'DevicePage_LocalDevice'.tr}';
result += ' ${'DevicesPage_LocalDevice'.tr}';
}
if (info.isMainDevice) result += ' ${'DevicePage_MainDevice'.tr}';
if (info.isMainDevice) result += ' ${'DevicesPage_MainDevice'.tr}';

return result;
}
Expand Down Expand Up @@ -147,7 +147,7 @@ class _DeviceCard extends State<DeviceCard> with TickerProviderStateMixin {
padding: EdgeInsets.only(bottom: width == null ? 20 : 8),
child: badges.Badge(
badgeContent: Text(
'DevicePage_PluginsCountText'.tr.replaceAll('%count%', (info.pluginsCount).toString()),
'DevicesPage_PluginsCountText'.tr.replaceAll('%count%', (info.pluginsCount).toString()),
style: const TextStyle(color: Colors.white),
),
position: badges.BadgePosition.topEnd(top: 70, end: 15),
Expand Down
2 changes: 1 addition & 1 deletion kitx_mobile/lib/pages/controls/home_page_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HomePageDrawer extends StatelessWidget {
title: Text('Drawer_Devices'.tr),
onTap: () {
Get.back();
Get.to(() => const DevicePage());
Get.to(() => const DevicesPage());
}.delay(milliseconds: pageOpenDelay).execute,
),
ListTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import 'package:kitx_shared_dart/kitx_shared_dart.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';

/// Device Page
class DevicePage extends StatefulWidget {
class DevicesPage extends StatefulWidget {
/// Constructor
const DevicePage({Key? key}) : super(key: key);
const DevicesPage({Key? key}) : super(key: key);

@override
State<DevicePage> createState() => _DevicePage();
State<DevicesPage> createState() => _DevicesPage();
}

class _DevicePage extends State<DevicePage> {
class _DevicesPage extends State<DevicesPage> {
var _scrollController = ScrollController();
var _paneController = PanelController();

Expand Down Expand Up @@ -48,7 +48,7 @@ class _DevicePage extends State<DevicePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('DevicePage_Title'.tr),
title: Text('DevicesPage_Title'.tr),
actions: [
OrientationBuilder(
builder: (context, _) => MediaQuery.of(context).orientation == Orientation.landscape
Expand Down
2 changes: 1 addition & 1 deletion kitx_mobile/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class HomePage extends StatelessWidget {
),
trailing: const Icon(Icons.keyboard_arrow_right),
shape: tileRadius,
onTap: () => (() => Get.to(() => const DevicePage())).delay(milliseconds: pageOpenDelay).execute(),
onTap: () => (() => Get.to(() => const DevicesPage())).delay(milliseconds: pageOpenDelay).execute(),
onLongPress: () {
showMenu(
context: context,
Expand Down
6 changes: 3 additions & 3 deletions kitx_mobile/lib/pages/pages.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:get/get.dart';
import 'package:kitx_mobile/pages/about_page.dart';
import 'package:kitx_mobile/pages/account_page.dart';
import 'package:kitx_mobile/pages/device_page.dart';
import 'package:kitx_mobile/pages/devices_page.dart';
import 'package:kitx_mobile/pages/home_page.dart';
import 'package:kitx_mobile/pages/settings_page.dart';
import 'package:kitx_mobile/pages/test_page.dart';

export 'about_page.dart';
export 'account_page.dart';
export 'device_page.dart';
export 'devices_page.dart';
export 'home_page.dart';
export 'settings_page.dart';
export 'test_page.dart';

/// Get Pages
List<GetPage<dynamic>> getPages() => [
GetPage(name: '/', page: () => const HomePage()),
GetPage(name: '/DevicePage/', page: () => const DevicePage()),
GetPage(name: '/DevicesPage/', page: () => const DevicesPage()),
GetPage(name: '/AccountPage/', page: () => const AccountPage()),
GetPage(name: '/TestPage/', page: () => const TestPage()),
GetPage(name: '/SettingsPage/', page: () => const SettingsPage()),
Expand Down
21 changes: 20 additions & 1 deletion kitx_mobile/lib/pages/test_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'package:kitx_mobile/pages/test_pages/device_info_test.dart';
import 'package:kitx_mobile/pages/test_pages/device_sensors.dart';
import 'package:kitx_mobile/pages/test_pages/network_info_test.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

/// [TestPage] Class
class TestPage extends StatefulWidget {
Expand All @@ -30,6 +30,25 @@ class _TestPageState extends State<TestPage> with SingleTickerProviderStateMixin
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverAppBar(
title: Text('TestPage_Title'.tr),
actions: [
PopupMenuButton(
tooltip: '',
padding: EdgeInsets.all(0),
icon: const Icon(Icons.handyman),
position: PopupMenuPosition.under,
itemBuilder: (context) => [
PopupMenuItem(
child: const Text('Enable awaker'),
onTap: () => WakelockPlus.enable(),
),
PopupMenuItem(
child: const Text('Disable awaker'),
onTap: () => WakelockPlus.disable(),
),
],
),
const SizedBox(width: 10),
],
pinned: true,
snap: true,
floating: true,
Expand Down
16 changes: 8 additions & 8 deletions kitx_mobile/lib/utils/translation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Translation extends Translations {
'Option_ShutdownDevicesServer': '关闭设备网络服务器',
'IndexPage_Title': 'KitX',
'HomePage_DevicesCount': '设备在线',
'DevicePage_Title': '设备管理',
'DevicePage_PluginsCountText': '%count% 插件在线',
'DevicePage_LocalDevice': '(本机)',
'DevicePage_MainDevice': '(主控)',
'DevicesPage_Title': '设备管理',
'DevicesPage_PluginsCountText': '%count% 插件在线',
'DevicesPage_LocalDevice': '(本机)',
'DevicesPage_MainDevice': '(主控)',
'DeviceChatPage_Title': '聊天',
'AccountPage_Title': '账户',
'TestPage_Title': '测试',
Expand Down Expand Up @@ -82,10 +82,10 @@ class Translation extends Translations {
'Option_ShutdownDevicesServer': 'Shutdown Devices Server',
'IndexPage_Title': 'KitX',
'HomePage_DevicesCount': 'Devices found.',
'DevicePage_Title': 'Devices',
'DevicePage_PluginsCountText': '%count% Plugins Online',
'DevicePage_LocalDevice': '(Local)',
'DevicePage_MainDevice': '(Master)',
'DevicesPage_Title': 'Devices',
'DevicesPage_PluginsCountText': '%count% Plugins Online',
'DevicesPage_LocalDevice': '(Local)',
'DevicesPage_MainDevice': '(Master)',
'DeviceChatPage_Title': 'Chat',
'AccountPage_Title': 'Account',
'TestPage_Title': 'Test',
Expand Down
1 change: 1 addition & 0 deletions kitx_mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
# sms_receiver: ^0.4.1 # 短信接收
url_launcher: ^6.2.4 # 打开链接
vibration: ^1.8.4 # 手机震动
wakelock_plus: ^1.1.4

dev_dependencies:
flutter_gen: ^5.4.0 # 生成工具
Expand Down

0 comments on commit d57ebca

Please sign in to comment.