Skip to content

Commit

Permalink
Rework info pages
Browse files Browse the repository at this point in the history
Signed-off-by: Peppe289 <gsperanza204@protonmail.com>
  • Loading branch information
Peppe289 committed Aug 6, 2024
1 parent 2da1ca4 commit 3eadfaa
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 50 deletions.
45 changes: 0 additions & 45 deletions lib/gui/AdvancedPage.dart

This file was deleted.

64 changes: 64 additions & 0 deletions lib/gui/hwInfoPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:system_info2/system_info2.dart';

class BuildHWInfoPage extends StatefulWidget {
const BuildHWInfoPage({super.key});

@override
// ignore: library_private_types_in_public_api
_BuildHWInfoPage createState() => _BuildHWInfoPage();
}

class _BuildHWInfoPage extends State<BuildHWInfoPage> {
static String _physicalMemory = "loading...";
static String _virtualMemory = "loading...";
static String _cpuVendor = "loading...";
static String _archName = "loading...";

@override
void initState() {
super.initState();
_physicalMemory =
(SysInfo.getTotalPhysicalMemory() / 1000000).truncate().toString();
_virtualMemory =
(SysInfo.getTotalVirtualMemory() / 1000000).truncate().toString();
_cpuVendor = SysInfo.cores.first.vendor;
_archName = SysInfo.cores.first.name;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
buildRow('Physical Memory Size:', '$_physicalMemory MB'),
buildRow('Virtual Memory Size:', '$_virtualMemory MB'),
buildRow('CPU Vendor:', _cpuVendor),
buildRow('Architecture Name:', _archName),
],
),
),
);
}

Widget buildRow(String leftText, String rightParam) {
return Padding(
padding: const EdgeInsets.fromLTRB(50.0, 20.0, 50.0, 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
leftText,
style: const TextStyle(color: Colors.white),
),
Text(
rightParam,
style: const TextStyle(color: Colors.white),
),
],
),
);
}
}
105 changes: 105 additions & 0 deletions lib/gui/sInfoPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'package:client_information/client_information.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:system_info2/system_info2.dart';

class BuildSoftwareInfoPage extends StatefulWidget {
const BuildSoftwareInfoPage({super.key});

@override
// ignore: library_private_types_in_public_api
_BuildSoftwareInfoPage createState() => _BuildSoftwareInfoPage();
}

class _BuildSoftwareInfoPage extends State<BuildSoftwareInfoPage> {
static String _deviceID = "loading...";
static String _deviceModel = "loading...";
static String _manufacturer = "loading...";
static String _androidVersion = "loading...";
static String _tags = "loading...";
static String _boardName = "loading...";
static String _display = "loading...";
static String _buildType = "loading...";
static String _kernelVersion = "loading...";
static String _appVersion = "loading...";
static String _appName = "loading...";

Future<void> retrieveAppInfo() async {
ClientInformation clientInfo = await ClientInformation.fetch();
setState(() {
_appVersion = clientInfo.softwareVersion;
_appName = clientInfo.softwareName;
});
}

Future<void> retrieveDevicesInfo() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
setState(() {
_deviceID = androidInfo.id;
_deviceModel = androidInfo.model;
_manufacturer = androidInfo.manufacturer;
_androidVersion = androidInfo.version.release;
_tags = androidInfo.tags;
_boardName = androidInfo.board;
_display = androidInfo.display;
_buildType = androidInfo.type;
_kernelVersion = SysInfo.kernelVersion;
});

if (kDebugMode) {
print("load information from devices with ID: $_deviceID");
}
}

@override
void initState() {
super.initState();
retrieveDevicesInfo();
retrieveAppInfo();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
buildRow("Android Version ID:", _deviceID),
buildRow("Device Model:", _deviceModel),
buildRow("Device Manufacturer:", _manufacturer),
buildRow("Android Version", _androidVersion),
buildRow("Tags:", _tags),
buildRow("BoardName:", _boardName),
buildRow("Display:", _display),
buildRow("Build Type:", _buildType),
buildRow("Kernel Version:", _kernelVersion),
buildRow("App version:", _appVersion),
buildRow("App Name:", _appName),
],
),
),
);
}

Widget buildRow(String leftText, String rightParam) {
return Padding(
padding: const EdgeInsets.fromLTRB(50.0, 20.0, 50.0, 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
leftText,
style: const TextStyle(color: Colors.white),
),
Text(
rightParam,
style: const TextStyle(color: Colors.white),
),
],
),
);
}
}
17 changes: 12 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'gui/SideDrawer.dart';
import 'gui/AdvancedPage.dart';
import 'gui/hwInfoPage.dart';
import 'gui/HomePage.dart';
import 'gui/sInfoPage.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';

void main() {
Expand Down Expand Up @@ -40,7 +41,8 @@ class _MyHomePageState extends State<MyHomePage> {
_currentPage = 0;
_pages = [
const BuildHomePage(),
const BuildSecondPage(),
const BuildHWInfoPage(),
const BuildSoftwareInfoPage(),
];
}

Expand Down Expand Up @@ -80,9 +82,14 @@ class _MyHomePageState extends State<MyHomePage> {
selectedColor: Colors.orange,
),
SalomonBottomBarItem(
icon: const Icon(Icons.admin_panel_settings),
title: const Text('Advanced'),
selectedColor: Colors.orange,
icon: const Icon(Icons.dataset_sharp),
title: const Text('Architecture'),
selectedColor: Colors.blue,
),
SalomonBottomBarItem(
icon: const Icon(Icons.device_unknown),
title: const Text('Software'),
selectedColor: Colors.green,
),
],
),
Expand Down
48 changes: 48 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
client_information:
dependency: "direct main"
description:
name: client_information
sha256: "3af34866e7756824044ebb1b15c5df9d0228b1271efb1684599914853c75cc01"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -177,6 +185,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.6"
device_info_plus:
dependency: "direct main"
description:
name: device_info_plus
sha256: "93429694c9253d2871b3af80cf11b3cbb5c65660d402ed7bf69854ce4a089f82"
url: "https://pub.dev"
source: hosted
version: "10.1.1"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba"
url: "https://pub.dev"
source: hosted
version: "7.0.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -549,6 +573,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -701,6 +733,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
uuid:
dependency: transitive
description:
name: uuid
sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90"
url: "https://pub.dev"
source: hosted
version: "4.4.2"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -757,6 +797,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.2.0"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
yaml:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ dependencies:
json_annotation: ^4.9.0
package_info: ^2.0.2
package_info_plus: ^4.2.0
device_info_plus: ^10.1.1
client_information: ^2.1.4

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3eadfaa

Please sign in to comment.