Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main and feature/changelog branches #87

Merged
merged 15 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add battery_plus package for power delivery warning
WilliamKarolDiCioccio committed Aug 22, 2024
commit 1d02fd81c6cce67d3320181c46f6d759b230d73f
2 changes: 2 additions & 0 deletions app/assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"@@locale": "en",
"deviceUnpluggedSnackBar": "Device unplugged. Power delivery reduced.",
"devicePluggedInSnackBar": "Device plugged in. Power delivery increased.",
"abortModelRemovalSnackBar": "Abort model removal",
"abortSessionRemovalSnackBar": "Abort session removal",
"aboutPageContributorsTitle": "Contributors",
30 changes: 30 additions & 0 deletions app/lib/frontend/screens/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:battery_plus/battery_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

@@ -47,6 +48,7 @@ class _DashboardScreenState extends State<DashboardScreen> {

WidgetsBinding.instance.addPostFrameCallback((_) async {
_checkForUpdates();
_registerBatteryCallback();
});
}

@@ -57,6 +59,34 @@ class _DashboardScreenState extends State<DashboardScreen> {
super.dispose();
}

void _registerBatteryCallback() {
final battery = Battery();

battery.onBatteryStateChanged.listen((BatteryState state) {
switch (state) {
case BatteryState.discharging:
SnackBarHelpers.showSnackBar(
AppLocalizations.of(context).snackBarWarningTitle,
AppLocalizations.of(context).deviceUnpluggedSnackBar,
SnackbarContentType.warning,
);
logger.i('Battery charging');
break;
case BatteryState.charging:
SnackBarHelpers.showSnackBar(
AppLocalizations.of(context).snackBarSuccessTitle,
AppLocalizations.of(context).devicePluggedInSnackBar,
SnackbarContentType.success,
);
logger.i('Battery discharging');
break;
default:
logger.i('Battery state: $state');
break;
}
});
}

void _checkForUpdates() {
UpdateHelper.isAppUpdateAvailable().then(
(updateAvailable) {
2 changes: 2 additions & 0 deletions app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import Foundation

import app_links
import audioplayers_darwin
import battery_plus
import bitsdojo_window_macos
import device_info_plus
import irondash_engine_context
@@ -23,6 +24,7 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
24 changes: 24 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
@@ -121,6 +121,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
battery_plus:
dependency: "direct main"
description:
name: battery_plus
sha256: ccc1322fee1153a0f89e663e0eac2f64d659da506454cf24dcad75eb08ae138b
url: "https://pub.dev"
source: hosted
version: "6.0.2"
battery_plus_platform_interface:
dependency: transitive
description:
name: battery_plus_platform_interface
sha256: e8342c0f32de4b1dfd0223114b6785e48e579bfc398da9471c9179b907fa4910
url: "https://pub.dev"
source: hosted
version: "2.0.1"
bitsdojo_window:
dependency: "direct main"
description:
@@ -361,6 +377,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
dbus:
dependency: transitive
description:
name: dbus
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
url: "https://pub.dev"
source: hosted
version: "0.7.10"
device_info_plus:
dependency: transitive
description:
1 change: 1 addition & 0 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ dependencies:
language_code: ^0.5.3+2
system_info2: ^4.0.0
gpu_info: ^0.0.3
battery_plus: ^6.0.2

# Environment Variables
envied: ^0.5.4+1
3 changes: 3 additions & 0 deletions app/windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@

#include <app_links/app_links_plugin_c_api.h>
#include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <battery_plus/battery_plus_windows_plugin.h>
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <gpu_info/gpu_info_plugin_c_api.h>
#include <irondash_engine_context/irondash_engine_context_plugin_c_api.h>
@@ -23,6 +24,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
BatteryPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BatteryPlusWindowsPlugin"));
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
GpuInfoPluginCApiRegisterWithRegistrar(
1 change: 1 addition & 0 deletions app/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
app_links
audioplayers_windows
battery_plus
bitsdojo_window_windows
gpu_info
irondash_engine_context