-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
299 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,5 @@ app.*.map.json | |
/android/app/release | ||
|
||
# Ignore test coverage data | ||
coverage | ||
coverage/lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'ranking_filter_params.freezed.dart'; | ||
part 'ranking_filter_params.g.dart'; | ||
|
||
@freezed | ||
class RankingFilterParams with _$RankingFilterParams { | ||
@JsonSerializable(includeIfNull: false) | ||
const factory RankingFilterParams({ | ||
@Default('CreateDate') String filterBy, | ||
@Default('Nothing') String vocalist, | ||
}) = _RankingFilterParams; | ||
|
||
factory RankingFilterParams.fromJson(Map<String, dynamic> json) => | ||
_$RankingFilterParamsFromJson(json); | ||
} |
175 changes: 175 additions & 0 deletions
175
lib/src/features/home/domain/ranking_filter_params.freezed.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target | ||
|
||
part of 'ranking_filter_params.dart'; | ||
|
||
// ************************************************************************** | ||
// FreezedGenerator | ||
// ************************************************************************** | ||
|
||
T _$identity<T>(T value) => value; | ||
|
||
final _privateConstructorUsedError = UnsupportedError( | ||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); | ||
|
||
RankingFilterParams _$RankingFilterParamsFromJson(Map<String, dynamic> json) { | ||
return _RankingFilterParams.fromJson(json); | ||
} | ||
|
||
/// @nodoc | ||
mixin _$RankingFilterParams { | ||
String get filterBy => throw _privateConstructorUsedError; | ||
String get vocalist => throw _privateConstructorUsedError; | ||
|
||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; | ||
@JsonKey(ignore: true) | ||
$RankingFilterParamsCopyWith<RankingFilterParams> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $RankingFilterParamsCopyWith<$Res> { | ||
factory $RankingFilterParamsCopyWith( | ||
RankingFilterParams value, $Res Function(RankingFilterParams) then) = | ||
_$RankingFilterParamsCopyWithImpl<$Res, RankingFilterParams>; | ||
@useResult | ||
$Res call({String filterBy, String vocalist}); | ||
} | ||
|
||
/// @nodoc | ||
class _$RankingFilterParamsCopyWithImpl<$Res, $Val extends RankingFilterParams> | ||
implements $RankingFilterParamsCopyWith<$Res> { | ||
_$RankingFilterParamsCopyWithImpl(this._value, this._then); | ||
|
||
// ignore: unused_field | ||
final $Val _value; | ||
// ignore: unused_field | ||
final $Res Function($Val) _then; | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? filterBy = null, | ||
Object? vocalist = null, | ||
}) { | ||
return _then(_value.copyWith( | ||
filterBy: null == filterBy | ||
? _value.filterBy | ||
: filterBy // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
vocalist: null == vocalist | ||
? _value.vocalist | ||
: vocalist // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$_RankingFilterParamsCopyWith<$Res> | ||
implements $RankingFilterParamsCopyWith<$Res> { | ||
factory _$$_RankingFilterParamsCopyWith(_$_RankingFilterParams value, | ||
$Res Function(_$_RankingFilterParams) then) = | ||
__$$_RankingFilterParamsCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call({String filterBy, String vocalist}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$_RankingFilterParamsCopyWithImpl<$Res> | ||
extends _$RankingFilterParamsCopyWithImpl<$Res, _$_RankingFilterParams> | ||
implements _$$_RankingFilterParamsCopyWith<$Res> { | ||
__$$_RankingFilterParamsCopyWithImpl(_$_RankingFilterParams _value, | ||
$Res Function(_$_RankingFilterParams) _then) | ||
: super(_value, _then); | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? filterBy = null, | ||
Object? vocalist = null, | ||
}) { | ||
return _then(_$_RankingFilterParams( | ||
filterBy: null == filterBy | ||
? _value.filterBy | ||
: filterBy // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
vocalist: null == vocalist | ||
? _value.vocalist | ||
: vocalist // ignore: cast_nullable_to_non_nullable | ||
as String, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
@JsonSerializable(includeIfNull: false) | ||
class _$_RankingFilterParams implements _RankingFilterParams { | ||
const _$_RankingFilterParams( | ||
{this.filterBy = 'CreateDate', this.vocalist = 'Nothing'}); | ||
|
||
factory _$_RankingFilterParams.fromJson(Map<String, dynamic> json) => | ||
_$$_RankingFilterParamsFromJson(json); | ||
|
||
@override | ||
@JsonKey() | ||
final String filterBy; | ||
@override | ||
@JsonKey() | ||
final String vocalist; | ||
|
||
@override | ||
String toString() { | ||
return 'RankingFilterParams(filterBy: $filterBy, vocalist: $vocalist)'; | ||
} | ||
|
||
@override | ||
bool operator ==(dynamic other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$_RankingFilterParams && | ||
(identical(other.filterBy, filterBy) || | ||
other.filterBy == filterBy) && | ||
(identical(other.vocalist, vocalist) || | ||
other.vocalist == vocalist)); | ||
} | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
int get hashCode => Object.hash(runtimeType, filterBy, vocalist); | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$_RankingFilterParamsCopyWith<_$_RankingFilterParams> get copyWith => | ||
__$$_RankingFilterParamsCopyWithImpl<_$_RankingFilterParams>( | ||
this, _$identity); | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return _$$_RankingFilterParamsToJson( | ||
this, | ||
); | ||
} | ||
} | ||
|
||
abstract class _RankingFilterParams implements RankingFilterParams { | ||
const factory _RankingFilterParams( | ||
{final String filterBy, final String vocalist}) = _$_RankingFilterParams; | ||
|
||
factory _RankingFilterParams.fromJson(Map<String, dynamic> json) = | ||
_$_RankingFilterParams.fromJson; | ||
|
||
@override | ||
String get filterBy; | ||
@override | ||
String get vocalist; | ||
@override | ||
@JsonKey(ignore: true) | ||
_$$_RankingFilterParamsCopyWith<_$_RankingFilterParams> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
lib/src/features/home/presentation/ranking_screen/ranking_filter_filter_by_radio_group.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:vocadb_app/src/common_widgets/simple_radio_group.dart'; | ||
import 'package:vocadb_app/src/features/home/presentation/ranking_screen/ranking_filter_params_state.dart'; | ||
|
||
class RankingFilterFilterByRadioGroup extends ConsumerWidget { | ||
const RankingFilterFilterByRadioGroup({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final value = ref.watch(rankingFilterParamsStateProvider); | ||
|
||
return SimpleRadioGroup( | ||
title: Text('Filter by'), | ||
groupValue: value.filterBy, | ||
onChanged: (value) { | ||
ref.read(rankingFilterParamsStateProvider.notifier).updateFilterBy(value!); | ||
}, | ||
items: [ | ||
SimpleRadioItem(name: 'Newly added', value: 'CreateDate'), | ||
SimpleRadioItem(name: 'Newly published', value: 'PublishDate'), | ||
SimpleRadioItem(name: 'Popularity', value: 'Popularity') | ||
], | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
lib/src/features/home/presentation/ranking_screen/ranking_filter_params_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:vocadb_app/src/features/home/domain/ranking_filter_params.dart'; | ||
|
||
class RankingFilterParamsState extends StateNotifier<RankingFilterParams> { | ||
RankingFilterParamsState() | ||
: super(const RankingFilterParams()); | ||
void updateFilterBy(String value) => | ||
state = state.copyWith(filterBy: value); | ||
void updateVocalist(String value) => state = state.copyWith(vocalist: value); | ||
} | ||
|
||
final rankingFilterParamsStateProvider = StateNotifierProvider.autoDispose< | ||
RankingFilterParamsState, RankingFilterParams>((ref) { | ||
return RankingFilterParamsState(); | ||
}); |
58 changes: 5 additions & 53 deletions
58
lib/src/features/home/presentation/ranking_screen/ranking_filter_screen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/src/features/home/presentation/ranking_screen/ranking_filter_vocalist_radio_group.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:vocadb_app/src/common_widgets/simple_radio_group.dart'; | ||
import 'package:vocadb_app/src/features/home/presentation/ranking_screen/ranking_filter_params_state.dart'; | ||
|
||
class RankingFilterVocalistRadioGroup extends ConsumerWidget { | ||
const RankingFilterVocalistRadioGroup({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final value = ref.watch(rankingFilterParamsStateProvider); | ||
|
||
return SimpleRadioGroup( | ||
title: Text('Vocalist'), | ||
groupValue: value.vocalist, | ||
onChanged: (value) { | ||
ref.read(rankingFilterParamsStateProvider.notifier).updateVocalist(value!); | ||
}, | ||
items: [ | ||
SimpleRadioItem(name: 'All vocalists', value: 'Nothing'), | ||
SimpleRadioItem(name: 'Only Vocaloid', value: 'Vocaloid'), | ||
SimpleRadioItem(name: 'UTAU', value: 'UTAU'), | ||
SimpleRadioItem(name: 'Other', value: 'Other') | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.