Skip to content

Commit

Permalink
fix scoring not working (#187)
Browse files Browse the repository at this point in the history
Co-authored-by: lotus <[email protected]>
  • Loading branch information
lotusprey and lotus authored Jan 12, 2025
1 parent 7b9d017 commit 8b19a54
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
26 changes: 19 additions & 7 deletions lib/feature/edit/score_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:otraku/feature/media/media_models.dart';
import 'package:otraku/util/theming.dart';

/// Score picker.
class ScoreField extends StatelessWidget {
class ScoreField extends StatefulWidget {
const ScoreField({
required this.value,
required this.scoreFormat,
Expand All @@ -14,6 +14,13 @@ class ScoreField extends StatelessWidget {
final ScoreFormat? scoreFormat;
final void Function(double) onChanged;

@override
State<ScoreField> createState() => _ScoreFieldState();
}

class _ScoreFieldState extends State<ScoreField> {
late var _value = widget.value;

@override
Widget build(BuildContext context) {
return Padding(
Expand All @@ -23,17 +30,22 @@ class ScoreField extends StatelessWidget {
labelText: 'Score',
border: OutlineInputBorder(),
),
child: switch (scoreFormat ?? ScoreFormat.point10) {
ScoreFormat.point3 => _SmileyScorePicker(value, onChanged),
ScoreFormat.point5 => _StarScorePicker(value, onChanged),
ScoreFormat.point10 => _TenScorePicker(value, onChanged),
child: switch (widget.scoreFormat ?? ScoreFormat.point10) {
ScoreFormat.point3 => _SmileyScorePicker(_value, _onChanged),
ScoreFormat.point5 => _StarScorePicker(_value, _onChanged),
ScoreFormat.point10 => _TenScorePicker(_value, _onChanged),
ScoreFormat.point10Decimal =>
_TenDecimalScorePicker(value, onChanged),
ScoreFormat.point100 => _HundredScorePicker(value, onChanged),
_TenDecimalScorePicker(_value, _onChanged),
ScoreFormat.point100 => _HundredScorePicker(_value, _onChanged),
},
),
);
}

void _onChanged(double value) {
setState(() => _value = value);
widget.onChanged(value);
}
}

class _SmileyScorePicker extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/feature/viewer/persistence_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:otraku/feature/home/home_model.dart';
import 'package:otraku/feature/media/media_models.dart';
import 'package:otraku/util/theming.dart';

const appVersion = '1.6.3';
const appVersion = '1.6.4';

class Persistence {
const Persistence({
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: An unofficial AniList app.

publish_to: 'none'

version: 1.6.3+81
version: 1.6.4+82

environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit 8b19a54

Please sign in to comment.