Skip to content

Commit 97bc787

Browse files
committed
refactor(project): Project wide refactor.
Handled leftover todos and warnings.
1 parent c6eb294 commit 97bc787

23 files changed

+61
-84
lines changed

lib/blocs/audio_player/audio_player_bloc.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,14 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
6868
});
6969
on<Pause>((event, emit) {
7070
_playing = false;
71-
emit(Paused(_baseControl));
72-
// TODO: Implement this.
71+
return emit(Paused(_baseControl));
7372
});
7473
on<Reset>((event, emit) {
7574
reset(emit);
7675
});
7776
on<ChangeBPM>((event, emit) {
7877
_bpm = event.newBPM;
79-
emit(ChangedBPM(_bpm));
78+
return emit(ChangedBPM(_bpm));
8079
});
8180
}
8281

@@ -97,7 +96,6 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
9796
emit(Idle());
9897
}
9998

100-
// TODO: Load the first chord before the rest.
10199
Future<void> _play({
102100
required Emitter<AudioPlayerState> emit,
103101
bool arpeggio = false,
@@ -123,7 +121,6 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
123121
Duration duration =
124122
Duration(milliseconds: (prog.durations[_cC] * mult).toInt());
125123
if (prog[_cC] != null) {
126-
print(prog[_cC]);
127124
if (arpeggio) {
128125
_playChordArpeggio(
129126
chord: prog[_cC]!,
@@ -150,7 +147,6 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
150147
try {
151148
_players[i].open(Media.asset(pitchFileName(pitches[i])));
152149
} catch (e) {
153-
print('Faild to play ${pitches[i]} from $chord');
154150
rethrow;
155151
}
156152
}
@@ -170,7 +166,6 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
170166
_players[i].play();
171167
await Future.delayed(noteLength);
172168
} catch (e) {
173-
print('Faild to play ${pitches[i]} from $chord');
174169
rethrow;
175170
}
176171
}
@@ -214,15 +209,13 @@ class AudioPlayerBloc extends Bloc<AudioPlayerEvent, AudioPlayerState> {
214209
if (previous != null) {
215210
int closest = fixedClosest(previous, cPitches[i]);
216211
note = calcNote(note, previous[closest].midiNumber);
217-
// TODO: Find a better way other then removing...
218212
previous.removeAt(closest);
219213
} else {
220214
note = calcNote(note, maxMelody - 12);
221215
}
222216
pitches.add(Pitch.fromMidiNumber(note));
223217
}
224218
}
225-
print(pitches);
226219
return pitches;
227220
}
228221

lib/blocs/bank/bank_bloc.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class BankBloc extends Bloc<BankEvent, BankState> {
2222

2323
List<String> get titles => _titles;
2424

25-
// TODO: Some events here don't emit any state, decide if that's ok...
2625
BankBloc() : super(const BankInitial()) {
2726
// --- Initial Load Event ---
2827
on<LoadInitialBank>((event, emit) async {
@@ -115,15 +114,11 @@ class BankBloc extends Bloc<BankEvent, BankState> {
115114
await jsonFile.create(recursive: true);
116115
await jsonFile.writeAsString(jsonEncode(ProgressionBank.toJson()));
117116
} catch (e) {
118-
// TODO: Handle case...
119117
rethrow;
120118
}
121119
}
122120
}
123121

124-
/* TODO: Maybe instead of always re-creating the file, remove only what's
125-
necessary. */
126-
127122
/// Overrides the current data if present. If not re-creates the json file.
128123
Future<void> _saveBankData() async {
129124
final String json = jsonEncode(ProgressionBank.toJson());

lib/blocs/progression_handler_bloc.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ class ProgressionHandlerBloc
315315
fromDur < currentlyViewedProgression.length &&
316316
toChord < currentlyViewedProgression.length;
317317

318-
// TODO: Optimize this.
319318
void _calculateRangePositions() {
320319
List<int> results = Utilities.calculateRangePositions(
321320
progression: currentlyViewedProgression,
@@ -361,7 +360,6 @@ class ProgressionHandlerBloc
361360

362361
Progression<T> _parseInputs<T>(
363362
List<String> inputs, T Function(String input) parse) {
364-
// TODO: Make a delete measure method instead...
365363
if (inputs.length == 1 && inputs[0].isEmpty) {
366364
return Progression.empty();
367365
}

lib/blocs/substitution_handler/substitution_handler_bloc.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,8 @@ class SubstitutionHandlerBloc
139139
}
140140
}
141141

142-
// TODO: Decide whether you want to show chords...
143-
Progression getOriginalSubstitution(PitchScale? scale, int index) {
144-
return _substitutions![index].originalSubstitution;
145-
if (scale == null || type == ProgressionType.romanNumerals) {
146-
} else {
147-
return getOriginalSubChords(scale, index);
148-
}
149-
}
142+
Progression getOriginalSubstitution(PitchScale? scale, int index) =>
143+
_substitutions![index].originalSubstitution;
150144

151145
ChordProgression getChordProgression(PitchScale scale, int index) {
152146
assert(index >= 0 && index < _chordProgressions!.length);
@@ -164,7 +158,6 @@ class SubstitutionHandlerBloc
164158
_substitutions![index].originalSubstitution;
165159
SubstitutionMatch match = _substitutions![index].match;
166160
if (match.type == SubstitutionMatchType.tonicization) {
167-
// TODO: Optimize.
168161
originalSub = originalSub.tonicizedFor(
169162
_substitutions![index].substitutedBase[match.baseIndex]!);
170163
}

lib/screens/library_screen/library_screen.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:thoery_test/state/progression_bank.dart';
55
import 'package:weizmann_theory_app_test/constants.dart';
66
import 'package:weizmann_theory_app_test/screens/library_screen/widgets/library_entry.dart';
77
import 'package:weizmann_theory_app_test/screens/progression_screen/progression_screen.dart';
8-
import 'package:weizmann_theory_app_test/widgets/TButton.dart';
8+
import 'package:weizmann_theory_app_test/widgets/custom_button.dart';
99
import 'package:window_manager/window_manager.dart';
1010

1111
import '../../blocs/bank/bank_bloc.dart';
@@ -135,7 +135,7 @@ class _LibraryScreenState extends State<LibraryScreen> with WindowListener {
135135
children: [
136136
Padding(
137137
padding: const EdgeInsets.symmetric(horizontal: 6.0),
138-
child: TButton(
138+
child: CustomButton(
139139
label: 'Create New',
140140
iconData: Icons.add,
141141
tight: true,
@@ -155,8 +155,6 @@ class _LibraryScreenState extends State<LibraryScreen> with WindowListener {
155155
submitButtonName: 'Create',
156156
onCancelled: (text) => Navigator.pop(context),
157157
onSubmitted: (text) {
158-
/* TODO: Choose what characters are illegal in a title
159-
and block them here. */
160158
if (text.isEmpty ||
161159
RegExp(r'^\s*$').hasMatch(text)) {
162160
return "Entry titles can't be empty.";
@@ -179,7 +177,7 @@ class _LibraryScreenState extends State<LibraryScreen> with WindowListener {
179177
),
180178
Padding(
181179
padding: const EdgeInsets.symmetric(horizontal: 6.0),
182-
child: TButton(
180+
child: CustomButton(
183181
label: 'Revert All',
184182
iconData: Icons.restart_alt_rounded,
185183
tight: true,

lib/screens/library_screen/widgets/library_entry.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:weizmann_theory_app_test/constants.dart';
3-
import 'package:weizmann_theory_app_test/widgets/TButton.dart';
3+
import 'package:weizmann_theory_app_test/widgets/custom_button.dart';
44

55
class LibraryEntry extends StatelessWidget {
66
const LibraryEntry({
@@ -53,14 +53,14 @@ class LibraryEntry extends StatelessWidget {
5353
const SizedBox(width: 4),
5454
Row(
5555
children: [
56-
TButton(
56+
CustomButton(
5757
label: 'Delete',
5858
iconData: Icons.delete,
5959
tight: true,
6060
onPressed: onDelete,
6161
),
6262
const SizedBox(width: 10),
63-
TButton(
63+
CustomButton(
6464
label: 'Open',
6565
iconData: Icons.edit,
6666
tight: true,

lib/screens/progression_screen/progression_screen.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:thoery_test/modals/scale_degree_chord.dart';
77
import 'package:thoery_test/state/progression_bank_entry.dart';
88
import 'package:tonic/tonic.dart';
99
import 'package:weizmann_theory_app_test/blocs/bank/bank_bloc.dart';
10-
import 'package:weizmann_theory_app_test/screens/progression_screen/widgets/BankProgressionButton.dart';
10+
import 'package:weizmann_theory_app_test/screens/progression_screen/widgets/bank_progression_button.dart';
1111
import 'package:weizmann_theory_app_test/screens/progression_screen/widgets/bpm_input.dart';
1212
import 'package:weizmann_theory_app_test/screens/progression_screen/widgets/progression_title.dart';
1313
import 'package:weizmann_theory_app_test/screens/progression_screen/widgets/reharmonize_bar.dart';
@@ -19,8 +19,8 @@ import '../../blocs/progression_handler_bloc.dart';
1919
import '../../blocs/substitution_handler/substitution_handler_bloc.dart'
2020
hide TypeChanged;
2121
import '../../modals/progression_type.dart';
22-
import '../../widgets/TButton.dart';
23-
import '../../widgets/t_icon_button.dart';
22+
import '../../widgets/custom_button.dart';
23+
import '../../widgets/custom_icon_button.dart';
2424
import 'widgets/progression/selectable_progression_view.dart';
2525
import 'widgets/scale_chooser.dart';
2626
import 'widgets/view_type_selector.dart';
@@ -100,7 +100,7 @@ class ProgressionScreenUI extends StatelessWidget {
100100
children: [
101101
Row(
102102
children: [
103-
TButton(
103+
CustomButton(
104104
label: 'Back',
105105
tight: true,
106106
size: 12,
@@ -111,7 +111,7 @@ class ProgressionScreenUI extends StatelessWidget {
111111
BlocBuilder<BankBloc, BankState>(
112112
builder: (context, state) {
113113
final bool loading = state is BankLoading;
114-
return TButton(
114+
return CustomButton(
115115
label: loading ? 'Saving...' : 'Save',
116116
tight: true,
117117
size: 12,
@@ -148,7 +148,6 @@ class ProgressionScreenUI extends StatelessWidget {
148148
BlocBuilder<AudioPlayerBloc, AudioPlayerState>(
149149
builder: (context, state) {
150150
return IgnorePointer(
151-
// TODO: Find a better place for this.
152151
ignoring:
153152
BlocProvider.of<ProgressionHandlerBloc>(
154153
context,
@@ -182,7 +181,6 @@ class ProgressionScreenUI extends StatelessWidget {
182181
ProgressionHandlerBloc>(
183182
context)
184183
.chordMeasures;
185-
print(chords);
186184
bloc.add(Play(
187185
measures: chords,
188186
basePlaying: true,
@@ -292,7 +290,7 @@ class ProgressionScreenUI extends StatelessWidget {
292290
context,
293291
listen: true)
294292
.showingWindow),
295-
TButton(
293+
CustomButton(
296294
label: 'Surprise Me',
297295
iconData: Icons.lightbulb,
298296
onPressed:

lib/screens/progression_screen/widgets/BankProgressionButton.dart renamed to lib/screens/progression_screen/widgets/bank_progression_button.dart

File renamed without changes.

lib/screens/progression_screen/widgets/bpm_input.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class _BPMInputState extends State<BPMInput> {
5050
}
5151
},
5252
child: IgnorePointer(
53-
// TODO: Improve the way this is written...
5453
ignoring:
5554
BlocProvider.of<AudioPlayerBloc>(context, listen: true).playing,
5655
child: Listener(

lib/screens/progression_screen/widgets/progression/measure_view.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:thoery_test/modals/progression.dart';
44
import 'package:weizmann_theory_app_test/constants.dart';
55

66
import '../../../../utilities.dart';
7-
import '../../../../widgets/TButton.dart';
7+
import '../../../../widgets/custom_button.dart';
88
import 'progression_value_view.dart';
99

1010
class Measure extends StatelessWidget {
@@ -225,7 +225,7 @@ class MeasureView<T> extends StatelessWidget {
225225
alignment: Alignment.bottomRight,
226226
child: Padding(
227227
padding: const EdgeInsets.only(right: 3, bottom: 3),
228-
child: TButton(
228+
child: CustomButton(
229229
label: 'Edit',
230230
iconData: Icons.edit_rounded,
231231
onPressed: editable ? onEdit : () {},
@@ -354,7 +354,7 @@ class _EditedMeasureState<T> extends State<EditedMeasure<T>> {
354354
alignment: Alignment.bottomRight,
355355
child: Padding(
356356
padding: const EdgeInsets.only(right: 3, bottom: 3),
357-
child: TButton(
357+
child: CustomButton(
358358
label: 'Done',
359359
iconData: Icons.check_rounded,
360360
onPressed: _submit,

0 commit comments

Comments
 (0)