Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from LuanRoger/manage_section
Manage section
- Loading branch information
Showing
62 changed files
with
2,834 additions
and
1,723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build outputs. | ||
build/ | ||
|
||
# Omit committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock | ||
|
||
#Editors | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:sys_info_getter/sys_info_getter.dart'; | ||
|
||
void main() async { | ||
TerminalHelper terminalHelper = TerminalHelper(PowershellProvider()); | ||
SystemInformations informations = await terminalHelper.update(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class CmdConts { | ||
static const String GET_VOLUME = | ||
"Get-Volume | select DriveLetter, OperationalStatus, Size, SizeRemaining | fl"; | ||
} |
37 changes: 37 additions & 0 deletions
37
internals/sys_info_getter/lib/src/controllers/terminal_helper.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:sys_info_getter/src/cmd_consts.dart'; | ||
import 'package:sys_info_getter/src/models/disk_info.dart'; | ||
import 'package:sys_info_getter/src/models/system_informations.dart'; | ||
import 'package:sys_info_getter/src/services/models/providers/terminal_provider.dart'; | ||
import 'package:sys_info_getter/src/services/models/terminal_interface.dart'; | ||
import 'package:sys_info_getter/src/utils/info_formater.dart'; | ||
|
||
class TerminalHelper { | ||
late final TerminalInterface _provider; | ||
|
||
TerminalHelper(TerminalProvider terminalProvider) { | ||
_provider = terminalProvider.interface; | ||
} | ||
|
||
Future<SystemInformations> update() async { | ||
List<DiskInfo>? diskInfo = await _getDiskInfo(); | ||
|
||
return SystemInformations(diskInfo: diskInfo); | ||
} | ||
|
||
Future<List<DiskInfo>?> _getDiskInfo() async { | ||
List<DiskInfo> diskInfos = List.empty(growable: true); | ||
|
||
String output = await _provider.executeCommand(CmdConts.GET_VOLUME); | ||
if (output.isEmpty) return null; | ||
|
||
List<Map<String, String>> formatedInfos = | ||
InfoFormater.formatStringToInfoMap(output); | ||
|
||
for (Map<String, String> info in formatedInfos) { | ||
if (info["DriveLetter"]!.isEmpty) continue; | ||
diskInfos.add(DiskInfo.fromMap(info)); | ||
} | ||
|
||
return diskInfos; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
enum GetError { | ||
GET_DISK_INFO_ERROR | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class DiskInfo { | ||
final String driveLetter; | ||
final String operationalStatus; | ||
final double size; | ||
final double sizeRemaining; | ||
|
||
DiskInfo( | ||
{required this.driveLetter, | ||
required this.operationalStatus, | ||
required this.size, | ||
required this.sizeRemaining}); | ||
|
||
factory DiskInfo.fromMap(Map<String, String> map) => DiskInfo( | ||
driveLetter: map["DriveLetter"]!, | ||
operationalStatus: map["OperationalStatus"]!, | ||
size: double.parse(map["Size"]!), | ||
sizeRemaining: double.parse(map["SizeRemaining"]!)); | ||
} |
16 changes: 16 additions & 0 deletions
16
internals/sys_info_getter/lib/src/models/system_informations.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:sys_info_getter/src/enums/get_error.dart'; | ||
import 'package:sys_info_getter/src/models/disk_info.dart'; | ||
|
||
class SystemInformations { | ||
final List<DiskInfo>? diskInfo; | ||
|
||
late List<GetError> _errors; | ||
List<GetError> get errors => List.from(_errors); | ||
|
||
SystemInformations({this.diskInfo}) { | ||
_errors = List.empty(growable: true); | ||
if (diskInfo == null) { | ||
_errors.add(GetError.GET_DISK_INFO_ERROR); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
internals/sys_info_getter/lib/src/services/models/providers/powershell_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:sys_info_getter/src/services/models/providers/terminal_provider.dart'; | ||
import 'package:sys_info_getter/src/services/models/terminal_interface.dart'; | ||
import 'package:sys_info_getter/src/services/powershell_service.dart'; | ||
|
||
class PowershellProvider implements TerminalProvider { | ||
@override | ||
TerminalInterface get interface => PowershellService(); | ||
} |
7 changes: 7 additions & 0 deletions
7
internals/sys_info_getter/lib/src/services/models/providers/terminal_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:sys_info_getter/src/services/models/terminal_interface.dart'; | ||
|
||
abstract class TerminalProvider { | ||
final TerminalInterface interface; | ||
|
||
TerminalProvider(this.interface); | ||
} |
3 changes: 3 additions & 0 deletions
3
internals/sys_info_getter/lib/src/services/models/terminal_interface.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
abstract class TerminalInterface { | ||
Future<String> executeCommand(String command); | ||
} |
12 changes: 12 additions & 0 deletions
12
internals/sys_info_getter/lib/src/services/powershell_service.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:sys_info_getter/src/services/models/terminal_interface.dart'; | ||
|
||
class PowershellService implements TerminalInterface { | ||
@override | ||
Future<String> executeCommand(String command) async { | ||
final powershell = | ||
await Process.run("Powershell.exe", [command], runInShell: true); | ||
return powershell.exitCode == 0 ? powershell.stdout : ""; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
internals/sys_info_getter/lib/src/utils/info_formater.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class InfoFormater { | ||
static List<Map<String, String>> formatStringToInfoMap(String rawInfo, | ||
{String separator = ":"}) { | ||
List<Map<String, String>> infos = List.empty(growable: true); | ||
List<String> diskInfos = rawInfo.trim().split("\n"); | ||
|
||
Map<String, String> buffer = {}; | ||
for (String lineInfo in diskInfos) { | ||
if (lineInfo.trim().isEmpty) { | ||
infos.add(Map.from(buffer)); | ||
buffer.clear(); | ||
continue; | ||
} | ||
|
||
List<String> keyValue = lineInfo.split(separator); | ||
String key = keyValue[0].trim(); | ||
String value = keyValue[1].trim(); | ||
buffer[key] = value; | ||
} | ||
infos.add(buffer); | ||
|
||
return infos; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
library sys_info_getter; | ||
|
||
export 'src/controllers/terminal_helper.dart'; | ||
|
||
export 'src/enums/get_error.dart'; | ||
|
||
export 'src/models/disk_info.dart'; | ||
export 'src/models/system_informations.dart'; | ||
|
||
export 'src/services/models/providers/powershell_provider.dart'; | ||
export 'src/services/models/providers/terminal_provider.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: sys_info_getter | ||
description: A starting point for Dart libraries or applications. | ||
version: 1.0.0 | ||
|
||
environment: | ||
sdk: '>=2.18.1 <3.0.0' | ||
|
||
# dependencies: | ||
# path: ^1.8.0 | ||
|
||
dev_dependencies: | ||
lints: ^2.0.0 | ||
test: ^1.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:sys_info_getter/sys_info_getter.dart'; | ||
|
||
class SystemInfoGetter { | ||
final TerminalHelper _terminalHelper = TerminalHelper(PowershellProvider()); | ||
|
||
Future<SystemInformations> _updateInfos() async => | ||
await _terminalHelper.update(); | ||
|
||
Future<List<DiskInfo>?> getDisksInfos() async => | ||
(await _updateInfos()).diskInfo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:xbox_launcher/shared/enums/tile_size.dart'; | ||
|
||
class ProfilePreviewElementsPreferences { | ||
TileSize myLibraryTileSize; | ||
|
||
ProfilePreviewElementsPreferences({this.myLibraryTileSize = TileSize.MEDIUM}); | ||
factory ProfilePreviewElementsPreferences.fromJson( | ||
Map<String, dynamic> json) => | ||
ProfilePreviewElementsPreferences( | ||
myLibraryTileSize: TileSize.values[json["myLibraryTileSize"]]); | ||
|
||
Map<String, dynamic> toJson() => | ||
{"myLibraryTileSize": myLibraryTileSize.index}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.