Skip to content

Commit

Permalink
🎇 Style: Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Sep 9, 2024
1 parent bcc11f4 commit 50e19a6
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 88 deletions.
4 changes: 2 additions & 2 deletions kitx_mobile/lib/pages/controls/devices_status_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:get/get.dart';
import 'package:kitx_mobile/instances.dart';
import 'package:kitx_mobile/services/public/service_status.dart';

/// Device Status Icon
/// Devices Status Icon
class DevicesStatusIcon extends StatelessWidget {
/// Constructor for Device Status Icon
/// Constructor for Devices Status Icon
const DevicesStatusIcon({super.key});

@override
Expand Down
10 changes: 7 additions & 3 deletions kitx_mobile/lib/pages/controls/devices_status_label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'package:kitx_mobile/instances.dart';
import 'package:kitx_mobile/services/public/service_status.dart';
import 'package:kitx_mobile/utils/handlers/vibration_handler.dart';

/// Device Status Label
/// Devices Status Label
class DevicesStatusLabel extends StatelessWidget {
/// Constructor for Device Status Label
/// Constructor for Devices Status Label
const DevicesStatusLabel({required this.inHomePage, super.key});

/// If in home page
Expand All @@ -19,7 +19,11 @@ class DevicesStatusLabel extends StatelessWidget {
switch (instances.devicesDiscoveryService.serviceStatus.value) {
case ServiceStatus.running:
return Text(
'${instances.devicesService.length.obs} ${'HomePage_DevicesCount'.tr}',
'HomePage_DevicesCount'.trParams(
{
'count': instances.devicesService.length.obs.string,
},
),
style: textStyle,
);
case ServiceStatus.starting:
Expand Down
69 changes: 69 additions & 0 deletions kitx_mobile/lib/pages/controls/plugins_status_label.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kitx_mobile/instances.dart';
import 'package:kitx_mobile/services/public/service_status.dart';
import 'package:kitx_mobile/utils/handlers/vibration_handler.dart';

/// Plugins Status Label
class PluginsStatusLabel extends StatelessWidget {
/// Constructor for Plugins Status Label
const PluginsStatusLabel({required this.inHomePage, super.key});

/// If in home page
final bool inHomePage;

@override
Widget build(BuildContext context) {
return Obx(() {
var textStyle = Theme.of(context).textTheme.bodyMedium;
switch (instances.pluginsService.serviceStatus.value) {
case ServiceStatus.running:
return Text(
[
'HomePage_PluginsCount'.trParams(
{
'count': instances.pluginsService.length.obs.string,
},
),
'HomePage_EnabledPluginsCount'.trParams(
{
'count': instances.pluginsService.enabledLength.obs.string,
},
),
].join(' || '),
style: textStyle,
);
case ServiceStatus.starting:
return Text('Public_Launching'.tr, style: textStyle);
case ServiceStatus.stopping:
return Text('Public_Stopping'.tr, style: textStyle);
case ServiceStatus.error:
return Row(
children: [
Padding(
padding: EdgeInsets.only(top: inHomePage ? 10 : 0),
child: ElevatedButton.icon(
onPressed: () {
VibrationHandler.tryVibrate();

Get.defaultDialog(
title: 'Public_Error'.tr,
titlePadding: EdgeInsets.only(top: 20),
middleText: instances.pluginsService.serviceException.toString(),
textConfirm: 'Public_Close'.tr,
contentPadding: EdgeInsets.only(top: 10, bottom: 20),
onConfirm: () => Get.back.tryVibrate().call(),
);
},
icon: const Icon(Icons.error, color: Colors.redAccent),
label: Text("Public_View_Error".tr),
),
),
],
);
default:
return Text('Public_Closed'.tr, style: textStyle);
}
});
}
}
3 changes: 2 additions & 1 deletion kitx_mobile/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:kitx_mobile/instances.dart';
import 'package:kitx_mobile/pages/controls/devices_status_label.dart';
import 'package:kitx_mobile/pages/controls/home_page_drawer.dart';
import 'package:kitx_mobile/pages/controls/plugins_status_label.dart';
import 'package:kitx_mobile/pages/pages.dart';
import 'package:kitx_mobile/pages/plugins_page.dart';
import 'package:kitx_mobile/utils/config.dart';
Expand Down Expand Up @@ -178,7 +179,7 @@ class HomePage extends StatelessWidget implements ConstantPage {
child: ListTile(
leading: const Icon(Icons.layers),
title: Text('Drawer_Plugins'.tr),
subtitle: isLandscape ? const Text('developing ...') : null,
subtitle: PluginsStatusLabel(inHomePage: true),
trailing: const Icon(Icons.keyboard_arrow_right),
shape: tileRadius,
onTap: () => (() => Get.toNamed(PluginsPage.getRoute())).tryVibrate().delay(milliseconds: config.delayOpenPageInHomePage.value ? pageOpenDelay : 0).execute(),
Expand Down
6 changes: 6 additions & 0 deletions kitx_mobile/lib/services/plugins_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class PluginsService implements Service {
/// Timers
late Map<String, Timer> timers = {};

/// Get plugins list length
int get length => InternalPluginsManager.instance().length;

/// Get enabled plugins list length
int get enabledLength => InternalPluginsManager.instance().enabledLength;

@override
Future<PluginsService> init() async {
serviceStatus.value = ServiceStatus.starting;
Expand Down
4 changes: 3 additions & 1 deletion kitx_mobile/lib/utils/translation/en_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const Map<String, String> en_us = {
'Option_RestartPluginsService': '重启插件服务',
'Option_ShutdownPluginsService': '关闭插件服务',
'IndexPage_Title': 'KitX',
'HomePage_DevicesCount': 'Devices found.',
'HomePage_DevicesCount': '@count Devices found.',
'HomePage_PluginsCount': '@count Installed',
'HomePage_EnabledPluginsCount': '@count Enabled',
'DevicesPage_Title': 'Devices',
'DevicesPage_PluginsCountText': '@count Plugins Online',
'DevicesPage_LocalDevice': '(Local)',
Expand Down
4 changes: 3 additions & 1 deletion kitx_mobile/lib/utils/translation/zh_cn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const Map<String, String> zh_cn = {
'Option_RestartPluginsService': '重启插件服务',
'Option_ShutdownPluginsService': '关闭插件服务',
'IndexPage_Title': 'KitX',
'HomePage_DevicesCount': '设备在线',
'HomePage_DevicesCount': '@count 设备在线',
'HomePage_PluginsCount': '@count 已安装',
'HomePage_EnabledPluginsCount': '@count 已启用',
'DevicesPage_Title': '设备管理',
'DevicesPage_PluginsCountText': '@count 插件在线',
'DevicesPage_LocalDevice': '(本机)',
Expand Down
Loading

0 comments on commit 50e19a6

Please sign in to comment.