Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed May 11, 2023
1 parent 144c96e commit 4aac712
Show file tree
Hide file tree
Showing 40 changed files with 955 additions and 828 deletions.
4 changes: 3 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
include: package:very_good_analysis/analysis_options.yaml

linter:
# The lint rules applied to this project can be customized in the
Expand All @@ -22,6 +22,8 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
public_member_api_docs: false
lines_longer_than_80_chars: false
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

Expand Down
38 changes: 19 additions & 19 deletions lib/features/create/create_custom/create_custom_screen.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:path/path.dart' as p;
import 'package:provider/provider.dart';
import 'package:retro/features/create/create_custom/create_custom_viewmodel.dart';
import 'package:retro/features/create/create_finish/create_finish_viewmodel.dart';
import 'package:retro/ui/components/custom_scaffold.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:path/path.dart' as p;

class CreateCustomScreen extends StatefulWidget {
const CreateCustomScreen({super.key});
Expand All @@ -24,13 +24,13 @@ class _CreateCustomScreenState extends State<CreateCustomScreen> {

@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final TextTheme textTheme = theme.textTheme;
final CreateCustomViewModel viewModel =
final theme = Theme.of(context);
final textTheme = theme.textTheme;
final viewModel =
Provider.of<CreateCustomViewModel>(context);
final CreateFinishViewModel finishViewModel =
final finishViewModel =
Provider.of<CreateFinishViewModel>(context);
final AppLocalizations i18n = AppLocalizations.of(context)!;
final i18n = AppLocalizations.of(context)!;

return CustomScaffold(
title: i18n.createCustomScreen_title,
Expand All @@ -47,24 +47,24 @@ class _CreateCustomScreenState extends State<CreateCustomScreen> {
Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
padding: const EdgeInsets.symmetric(vertical: 12),
child: OutlinedButton(
onPressed: viewModel.onSelectFiles,
style: ElevatedButton.styleFrom(
minimumSize: const Size(200, 50)),
minimumSize: const Size(200, 50),),
child:
Text(i18n.createCustomScreen_selectButton)),
Text(i18n.createCustomScreen_selectButton),),
),
Text(viewModel.path),
],
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
padding: const EdgeInsets.only(bottom: 4),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'${i18n.createCustomScreen_fileToInsert}${viewModel.files.length}',
style: textTheme.subtitle1,
style: textTheme.titleMedium,
),
),
),
Expand All @@ -74,24 +74,24 @@ class _CreateCustomScreenState extends State<CreateCustomScreen> {
itemBuilder: (context, index) {
return Text(p.relative(
viewModel.files[index].path,
from: viewModel.path));
})),
from: viewModel.path,),);
},),),
ElevatedButton(
onPressed: viewModel.files.isNotEmpty &&
viewModel.path.isNotEmpty
? () {
finishViewModel.onAddCustomStageEntries(
viewModel.files, viewModel.path);
viewModel.files, viewModel.path,);
viewModel.reset();
Navigator.of(context).popUntil(
ModalRoute.withName("/create_selection"));
ModalRoute.withName('/create_selection'),);
}
: null,
style: ElevatedButton.styleFrom(
minimumSize: Size(
MediaQuery.of(context).size.width * 0.5, 50)),
child: Text(i18n.createCustomScreen_stageFiles)),
MediaQuery.of(context).size.width * 0.5, 50,),),
child: Text(i18n.createCustomScreen_stageFiles),),
],
))));
),),),);
}
}
14 changes: 7 additions & 7 deletions lib/features/create/create_custom/create_custom_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import 'package:flutter/material.dart';

class CreateCustomViewModel extends ChangeNotifier {
List<File> files = [];
String path = "";
String path = '';

reset() {
files = [];
path = "";
path = '';
}

onSelectedFiles(List<File> files) {
Expand All @@ -23,14 +23,14 @@ class CreateCustomViewModel extends ChangeNotifier {
}

onSelectFiles() async {
String? selectedBaseDirectoryPath =
final selectedBaseDirectoryPath =
await FilePicker.platform.getDirectoryPath();
onSelectedDirectory(selectedBaseDirectoryPath ?? "");
onSelectedDirectory(selectedBaseDirectoryPath ?? '');
if (selectedBaseDirectoryPath != null) {
var directory = Directory(selectedBaseDirectoryPath);
var dirList =
final directory = Directory(selectedBaseDirectoryPath);
final dirList =
directory.list(recursive: true).where((fsEntry) => fsEntry is File);
List<File> selectedFileList = [];
final selectedFileList = <File>[];
await for (final FileSystemEntity fsEntry in dirList) {
if (fsEntry is File) {
selectedFileList.add(fsEntry);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:retro/features/create/create_custom_sequences/create_custom_sequences_viewmodel.dart';
import 'package:retro/features/create/create_finish/create_finish_viewmodel.dart';
import 'package:retro/ui/components/custom_scaffold.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class CreateCustomSequencesScreen extends StatefulWidget {
const CreateCustomSequencesScreen({super.key});
Expand All @@ -16,12 +16,12 @@ class CreateCustomSequencesScreen extends StatefulWidget {
class _CreateCustomSequencesScreenState extends State<CreateCustomSequencesScreen> {
@override
Widget build(BuildContext context) {
final CreateCustomSequencesViewModel viewModel = Provider.of<CreateCustomSequencesViewModel>(context);
final CreateFinishViewModel finishViewModel = Provider.of<CreateFinishViewModel>(context);
final AppLocalizations i18n = AppLocalizations.of(context)!;
final viewModel = Provider.of<CreateCustomSequencesViewModel>(context);
final finishViewModel = Provider.of<CreateFinishViewModel>(context);
final i18n = AppLocalizations.of(context)!;

String nameWithoutExtension(String path, String basePath) {
return path.split("$basePath/").last.split('.').first;
return path.split('$basePath/').last.split('.').first;
}

return CustomScaffold(
Expand All @@ -43,14 +43,14 @@ class _CreateCustomSequencesScreenState extends State<CreateCustomSequencesScree
border: const OutlineInputBorder(),
labelText: viewModel.selectedFolderPath ?? i18n.createCustomSequences_SequencesFolderPath,
),
)),
),),
const SizedBox(width: 12),
ElevatedButton(
onPressed: viewModel.onSelectFolder,
style: ElevatedButton.styleFrom(
minimumSize: const Size(100, 50)),
child: Text(i18n.createCustomSequences_selectButton))
]),
minimumSize: const Size(100, 50),),
child: Text(i18n.createCustomSequences_selectButton),)
],),
if (viewModel.isProcessing || viewModel.sequenceMetaPairs.isNotEmpty)
Expanded(
child: viewModel.isProcessing
Expand All @@ -62,22 +62,22 @@ class _CreateCustomSequencesScreenState extends State<CreateCustomSequencesScree
prototypeItem: const SizedBox(width: 0, height: 20),
itemBuilder: (context, index) {
return Text(nameWithoutExtension(viewModel.sequenceMetaPairs[index].item1.path, viewModel.selectedFolderPath!));
}))),
},),),),
if (!viewModel.isProcessing && viewModel.sequenceMetaPairs.isEmpty)
const Spacer(),
ElevatedButton(
onPressed: viewModel.sequenceMetaPairs.isNotEmpty ? () {
finishViewModel.onAddCustomSequenceEntry(viewModel.sequenceMetaPairs, 'custom/music');
viewModel.reset();
Navigator.of(context).popUntil(ModalRoute.withName("/create_selection"));
Navigator.of(context).popUntil(ModalRoute.withName('/create_selection'));
} : null,
style: ElevatedButton.styleFrom(minimumSize: Size(
MediaQuery.of(context).size.width * 0.5, 50)
MediaQuery.of(context).size.width * 0.5, 50,),
),
child: Text(i18n.createCustomSequences_stageFiles)
child: Text(i18n.createCustomSequences_stageFiles),
)
])
))
],),
),),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
import 'package:retro/utils/log.dart';
import 'package:tuple/tuple.dart';
import 'package:path/path.dart' as p;

typedef SequenceMetaPair = Tuple2<File, File>;

Expand All @@ -20,7 +20,7 @@ class CreateCustomSequencesViewModel extends ChangeNotifier {
}

onSelectFolder() async {
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
final selectedDirectory = await FilePicker.platform.getDirectoryPath();

if (selectedDirectory != null) {
selectedFolderPath = selectedDirectory;
Expand All @@ -35,14 +35,14 @@ class CreateCustomSequencesViewModel extends ChangeNotifier {
}

List<SequenceMetaPair> listSequenceMetaPairs(String folderPath) {
List<FileSystemEntity> files = Directory(folderPath).listSync(recursive: true);
List<FileSystemEntity> sequenceFiles = files.where((file) => file.path.endsWith('.seq')).toList();

List<Tuple2<File, File>> sequenceMetaPairs = [];
for (FileSystemEntity sequenceFile in sequenceFiles) {
String sequenceFileName = sequenceFile.path.split(Platform.pathSeparator).last;
String sequenceFileNameWithoutExtension = p.basenameWithoutExtension(sequenceFileName);
File metaFile = File(p.join(sequenceFile.parent.path, '$sequenceFileNameWithoutExtension.meta'));
final files = Directory(folderPath).listSync(recursive: true);
final sequenceFiles = files.where((file) => file.path.endsWith('.seq')).toList();

final sequenceMetaPairs = <Tuple2<File, File>>[];
for (final sequenceFile in sequenceFiles) {
final sequenceFileName = sequenceFile.path.split(Platform.pathSeparator).last;
final sequenceFileNameWithoutExtension = p.basenameWithoutExtension(sequenceFileName);
final metaFile = File(p.join(sequenceFile.parent.path, '$sequenceFileNameWithoutExtension.meta'));
if(!metaFile.existsSync()) {
log('Meta file not found for sequence file: $sequenceFileName! Skipping.', level: LogLevel.error);
continue;
Expand Down
Loading

0 comments on commit 4aac712

Please sign in to comment.