Skip to content

Commit

Permalink
Fix: Android Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Jan 24, 2024
1 parent 99cd3fd commit 863fb9d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
65 changes: 37 additions & 28 deletions lib/app/(public)/config/edit_platform_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class EditPlatformPage extends StatefulWidget {

class _EditPlatformPageState extends State<EditPlatformPage> {
late PlatformModel platform;
late PlatformModel oldPlatform;

@override
void initState() {
super.initState();
platform = (Routefly.query.arguments as PlatformModel?)?.copyWith() ??
PlatformModel.defaultInstance();
oldPlatform = platform.copyWith();
}

@override
Expand Down Expand Up @@ -128,12 +130,12 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
if (isChecked == true) {
games.add(
Game(
name: app.name,
description: '',
image: '',
isSynced: true,
overradedPlayer: Player(app: app),
path: ''),
name: app.name,
description: '',
image: '',
overradedPlayer: Player(app: app),
path: app.package,
),
);
} else {
games.removeWhere((e) =>
Expand Down Expand Up @@ -165,27 +167,28 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
},
),
const Gap(17),
TextFormField(
key: Key(beautifyPath(platform.folder)),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'folder'.i18n(),
suffixIcon: const Icon(Icons.folder),
),
initialValue: beautifyPath(platform.folder),
readOnly: true,
onTap: () async {
final selectedDirectory = await getDirectoryPath();
if (platform.category.id != 'android')
TextFormField(
key: Key(beautifyPath(platform.folder)),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'folder'.i18n(),
suffixIcon: const Icon(Icons.folder),
),
initialValue: beautifyPath(platform.folder),
readOnly: true,
onTap: () async {
final selectedDirectory = await getDirectoryPath();

if (selectedDirectory != null) {
setState(() {
platform = platform.copyWith(
folder: selectedDirectory,
);
});
}
},
),
if (selectedDirectory != null) {
setState(() {
platform = platform.copyWith(
folder: selectedDirectory,
);
});
}
},
),
const Gap(50),
],
),
Expand Down Expand Up @@ -220,16 +223,22 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
return;
}

if (oldPlatform.category.id == platform.category.id &&
platform.category.id == 'android') {
final games = syncGames(oldPlatform.games, platform.games);
platform = platform.copyWith(games: games);
}

Routefly.pop(context);

if (isEditing) {
updatePlatform(platform);
await updatePlatform(platform);
} else {
await createPlatform(platform);
platform = platformsState.value
.firstWhere((e) => e.category == platform.category);
await syncPlatform(platform);
}
await syncPlatform(platform);
},
child: const Icon(Icons.save),
),
Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation

import battery_plus
import file_selector_macos
import isar_flutter_libs
import package_info_plus
Expand All @@ -15,6 +16,7 @@ import url_launcher_macos
import wakelock_plus

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

#include "generated_plugin_registrant.h"

#include <battery_plus/battery_plus_windows_plugin.h>
#include <file_selector_windows/file_selector_windows.h>
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
BatteryPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BatteryPlusWindowsPlugin"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
IsarFlutterLibsPluginRegisterWithRegistrar(
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
battery_plus
file_selector_windows
isar_flutter_libs
permission_handler_windows
Expand Down

0 comments on commit 863fb9d

Please sign in to comment.