asc and desc added to studio api

This commit is contained in:
MohammadTaha Basiri 2022-03-29 12:07:56 +04:30
parent 1d401b3ba0
commit 658d74b9ed
4 changed files with 21 additions and 5 deletions

View File

@ -3,9 +3,11 @@ class StudioRequestArgs {
final String? search; final String? search;
final String? order; final String? order;
final String? type; final String? type;
final bool? asc;
const StudioRequestArgs({ const StudioRequestArgs({
required this.page, required this.page,
this.asc,
this.search, this.search,
this.order, this.order,
this.type, this.type,

View File

@ -104,6 +104,7 @@ class RequestHelper {
MapEntry('type', args.type), MapEntry('type', args.type),
MapEntry('order', args.order), MapEntry('order', args.order),
MapEntry('search', args.search), MapEntry('search', args.search),
MapEntry('asc', args.asc),
]); ]);
static String studioOverviews({required StudioRequestArgs args}) => static String studioOverviews({required StudioRequestArgs args}) =>
_baseStudioUrl + _baseStudioUrl +
@ -112,6 +113,7 @@ class RequestHelper {
MapEntry('type', args.type), MapEntry('type', args.type),
MapEntry('order', args.order), MapEntry('order', args.order),
MapEntry('search', args.search), MapEntry('search', args.search),
MapEntry('asc', args.asc),
]); ]);
static String mark(int id, String type) => baseUrl + '/$type/$id/mark'; static String mark(int id, String type) => baseUrl + '/$type/$id/mark';

View File

@ -137,6 +137,7 @@ class _StudioState extends State<Studio> {
order: state.order, order: state.order,
search: state.search, search: state.search,
type: state.type, type: state.type,
asc: state.selectedSortTypeIndex == 1,
), ),
) )
: PodcastOverview( : PodcastOverview(
@ -147,6 +148,7 @@ class _StudioState extends State<Studio> {
order: state.order, order: state.order,
search: state.search, search: state.search,
type: state.type, type: state.type,
asc: state.selectedSortTypeIndex == 1,
), ),
), ),
childCount: state.studios.length, childCount: state.studios.length,
@ -185,7 +187,7 @@ class _StudioState extends State<Studio> {
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
DidvanRadialButton( DidvanRadialButton(
title: 'پربازدیدترین‌ها', title: 'قدیمی‌ترین‌ها',
onSelected: () => setState( onSelected: () => setState(
() => state.selectedSortTypeIndex = 1, () => state.selectedSortTypeIndex = 1,
), ),
@ -193,12 +195,20 @@ class _StudioState extends State<Studio> {
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
DidvanRadialButton( DidvanRadialButton(
title: 'پربحث‌ترین‌ها', title: 'پربازدیدترین‌ها',
onSelected: () => setState( onSelected: () => setState(
() => state.selectedSortTypeIndex = 2, () => state.selectedSortTypeIndex = 2,
), ),
value: state.selectedSortTypeIndex == 2, value: state.selectedSortTypeIndex == 2,
), ),
const SizedBox(height: 24),
DidvanRadialButton(
title: 'پربحث‌ترین‌ها',
onSelected: () => setState(
() => state.selectedSortTypeIndex = 3,
),
value: state.selectedSortTypeIndex == 3,
),
], ],
), ),
), ),

View File

@ -34,14 +34,15 @@ class StudioState extends CoreProvier {
} }
String get order { String get order {
if (selectedSortTypeIndex == 0) return 'date'; if (selectedSortTypeIndex == 0 || selectedSortTypeIndex == 1) return 'date';
if (selectedSortTypeIndex == 1) return 'view'; if (selectedSortTypeIndex == 2) return 'view';
return 'comment'; return 'comment';
} }
String get orderString { String get orderString {
if (selectedSortTypeIndex == 0) return 'تازه‌ترین‌ها'; if (selectedSortTypeIndex == 0) return 'تازه‌ترین‌ها';
if (selectedSortTypeIndex == 1) return 'پربازدیدترین‌ها'; if (selectedSortTypeIndex == 1) return 'قدیمی‌ترین‌ها';
if (selectedSortTypeIndex == 2) return 'پربازدیدترین‌ها';
return 'پربحث‌نرین‌ها'; return 'پربحث‌نرین‌ها';
} }
@ -89,6 +90,7 @@ class StudioState extends CoreProvier {
type: type, type: type,
search: search, search: search,
order: order, order: order,
asc: selectedSortTypeIndex == 1,
), ),
), ),
); );