Skip to content

Commit

Permalink
Merge pull request #8 from Flutterando/5-feature-mass-import-artwork
Browse files Browse the repository at this point in the history
feat: Create Cover Settings
  • Loading branch information
jacobaraujo7 committed Jan 25, 2024
2 parents d00cb9b + f9aba30 commit 6a9b75e
Show file tree
Hide file tree
Showing 23 changed files with 550 additions and 76 deletions.
10 changes: 10 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,15 @@
<meta-data
android:name="flutterEmbedding"
android:value="2"/>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
4 changes: 4 additions & 0 deletions android/app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="."/>
</paths>
3 changes: 3 additions & 0 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "Channels",
"change_title": "Change title",
"change_cover": "Change Cover",
"cover": "Cover",
"import_covers": "Import covers",
"import_covers_description": "Choose a folder that contains\ngame covers.\nThe cover name must be the same as the game.",
"resync": "Resync",
"replace_player": "Replace player",
"remove": "Remove",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "Canales",
"change_title": "Cambiar título",
"change_cover": "Cambiar Portada",
"cover": "Portada",
"import_covers": "Importar Portadas",
"import_covers_description": "Elige una carpeta que contenga\nportadas de juegos.\nEl nombre de la portada debe ser el mismo que el del juego.",
"resync": "Re-sincronizar",
"replace_player": "Reemplazar jugador",
"remove": "Eliminar",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "チャンネル",
"change_title": "タイトルを変更する",
"change_cover": "カバーを変更する",
"cover": "カバー",
"import_covers": "カバーをインポートする",
"import_covers_description": "ゲームのカバーをインポートするには、ゲームのフォルダに「cover.png」または「cover.jpg」ファイルを追加します。",
"resync": "再同期",
"replace_player": "プレイヤーを交換する",
"remove": "削除する",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "Canais",
"change_title": "Mudar título",
"change_cover": "Mudar Capa",
"cover": "Capa",
"import_covers": "Importar Capas",
"import_covers_description": "Escolha um pasta que contenha\nas capas dos jogos.\nO nome da capa deve ser o mesmo do jogo.",
"resync": "Ressincronizar",
"replace_player": "Substituir player",
"remove": "Remover",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "Каналы",
"change_title": "Изменить название",
"change_cover": "Изменить обложку",
"cover": "Обложка",
"import_covers": "Импортировать обложки",
"import_covers_description": "Выберите папку, содержащую\nобложки игр.\nНазвание обложки должно совпадать с названием игры.",
"resync": "Пересинхронизация",
"replace_player": "Заменить игрока",
"remove": "Удалить",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "频道",
"change_title": "更改标题",
"change_cover": "更改封面",
"cover": "封面",
"import_covers": "导入封面",
"import_covers_description": "您可以导入封面,以便在游戏列表中显示。如果您不导入封面,将使用默认封面。",
"resync": "重新同步",
"replace_player": "替换玩家",
"remove": "移除",
Expand Down
3 changes: 3 additions & 0 deletions assets/i18n/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"channels": "頻道",
"change_title": "更改標題",
"change_cover": "更改封面",
"cover": "封面",
"import_covers": "導入封面",
"import_covers_description": "您可以導入一個包含遊戲封面的資料夾,Yuno 將會為您的遊戲自動分配封面。",
"resync": "重新同步",
"replace_player": "替換玩家",
"remove": "移除",
Expand Down
6 changes: 6 additions & 0 deletions lib/app/(public)/config/config_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../interactor/atoms/config_atom.dart';
import '../../interactor/atoms/gamepad_atom.dart';
import '../../interactor/services/gamepad_service.dart';
import 'widgets/about_widget.dart';
import 'widgets/cover_settings_widget.dart';
import 'widgets/feedback_widget.dart';
import 'widgets/platform_widget.dart';
import 'widgets/preferences_widget.dart';
Expand Down Expand Up @@ -84,6 +85,10 @@ class _ConfigPageState extends State<ConfigPage> {
icon: const Icon(Icons.settings),
label: Text('preferences'.i18n()),
),
NavigationRailDestination(
icon: const Icon(Icons.image),
label: Text('cover'.i18n()),
),
NavigationRailDestination(
icon: const Icon(Icons.chat_outlined),
label: Text('feedback'.i18n()),
Expand Down Expand Up @@ -114,6 +119,7 @@ class _ConfigPageState extends State<ConfigPage> {
children: [
PlatformWidget(transitionAnimation: widget.transitionAnimation),
const PreferencesWidget(),
const CoverSettingsWidget(),
FeedbackWidget(),
AboutWidget(),
],
Expand Down
32 changes: 25 additions & 7 deletions lib/app/(public)/config/edit_platform_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:localization/localization.dart';
Expand All @@ -9,6 +8,7 @@ import 'package:yuno/app/interactor/atoms/platform_atom.dart';
import 'package:yuno/app/interactor/models/embeds/game.dart';

import '../../core/widgets/animated_title_app_bart.dart';
import '../../interactor/actions/config_action.dart';
import '../../interactor/actions/platform_action.dart';
import '../../interactor/models/embeds/game_category.dart';
import '../../interactor/models/embeds/player.dart';
Expand Down Expand Up @@ -178,7 +178,7 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
initialValue: beautifyPath(platform.folder),
readOnly: true,
onTap: () async {
final selectedDirectory = await getDirectoryPath();
final selectedDirectory = await getDirectory();

if (selectedDirectory != null) {
setState(() {
Expand All @@ -189,6 +189,29 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
}
},
),
const Gap(17),
if (platform.category.id != 'android')
TextFormField(
key: Key(beautifyPath('${platform.folderCover ?? platform.folder}_cover')),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'import_covers'.i18n(),
suffixIcon: const Icon(Icons.folder),
),
initialValue: beautifyPath(platform.folderCover ?? platform.folder),
readOnly: true,
onTap: () async {
final selectedDirectory = await getDirectory();

if (selectedDirectory != null) {
setState(() {
platform = platform.copyWith(
folderCover: selectedDirectory,
);
});
}
},
),
const Gap(50),
],
),
Expand Down Expand Up @@ -246,9 +269,4 @@ class _EditPlatformPageState extends State<EditPlatformPage> {
),
);
}

String beautifyPath(String dir) {
final path = convertContentUriToFilePath(dir);
return path.replaceAll('/storage/emulated/0', '');
}
}
76 changes: 76 additions & 0 deletions lib/app/(public)/config/widgets/cover_settings_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'dart:ffi';

import 'package:asp/asp.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:localization/localization.dart';

import '../../../interactor/actions/config_action.dart';
import '../../../interactor/actions/platform_action.dart';
import '../../../interactor/atoms/config_atom.dart';

class CoverSettingsWidget extends StatelessWidget {
const CoverSettingsWidget({super.key});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return RxBuilder(
builder: (context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'cover'.i18n(),
style: theme.textTheme.titleMedium,
),
const Gap(12),
SwitchListTile(
value: gameConfigState.value.enableIGDB,
onChanged: (v) {
saveConfig(gameConfigState.value.copyWith(enableIGDB: v));
},
title: const Text('IGDB'),
),
const Gap(18),
Text(
'import_covers'.i18n(),
style: theme.textTheme.titleMedium,
),
const Gap(12),
Padding(
padding: const EdgeInsets.only(right: 20),
child: TextFormField(
key: Key(beautifyPath(gameConfigState.value.coverFolder ?? '')),
decoration: InputDecoration(
border: const OutlineInputBorder(),
labelText: 'folder'.i18n(),
suffixIcon: const Icon(Icons.folder),
),
initialValue:
beautifyPath(gameConfigState.value.coverFolder ?? ''),
readOnly: true,
onTap: () async {
final selectedDirectory = await getDirectory();

if (selectedDirectory != null) {
saveConfig(
gameConfigState.value.copyWith(
coverFolder: selectedDirectory,
),
);
}
},
),
),
const Gap(12),
Text(
'import_covers_description'.i18n(),
style: theme.textTheme.titleSmall,
),
],
);
},
);
}
}
2 changes: 2 additions & 0 deletions lib/app/data/repositories/isar/adapters/platform_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class PlatformAdapter {
data.lastUpdate = DateTime.now();
data.playerPackageId = model.player?.app.package;
data.playerExtra = model.player?.extra;
data.folderCover = model.folderCover;
return data;
}

Expand Down Expand Up @@ -58,6 +59,7 @@ abstract class PlatformAdapter {
extra: model.playerExtra,
),
games: model.games.map((e) => gameFromData(e)).toList(),
folderCover: model.folderCover,
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/app/data/repositories/isar/db/platform_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class PlatformData {
late String category;
String? playerPackageId;
String? playerExtra;
String? folderCover;
late String folder;
late DateTime lastUpdate;
List<GameData> games = [];
Expand Down

0 comments on commit 6a9b75e

Please sign in to comment.