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? order;
final String? type;
final bool? asc;
const StudioRequestArgs({
required this.page,
this.asc,
this.search,
this.order,
this.type,

View File

@ -104,6 +104,7 @@ class RequestHelper {
MapEntry('type', args.type),
MapEntry('order', args.order),
MapEntry('search', args.search),
MapEntry('asc', args.asc),
]);
static String studioOverviews({required StudioRequestArgs args}) =>
_baseStudioUrl +
@ -112,6 +113,7 @@ class RequestHelper {
MapEntry('type', args.type),
MapEntry('order', args.order),
MapEntry('search', args.search),
MapEntry('asc', args.asc),
]);
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,
search: state.search,
type: state.type,
asc: state.selectedSortTypeIndex == 1,
),
)
: PodcastOverview(
@ -147,6 +148,7 @@ class _StudioState extends State<Studio> {
order: state.order,
search: state.search,
type: state.type,
asc: state.selectedSortTypeIndex == 1,
),
),
childCount: state.studios.length,
@ -185,7 +187,7 @@ class _StudioState extends State<Studio> {
),
const SizedBox(height: 24),
DidvanRadialButton(
title: 'پربازدیدترین‌ها',
title: 'قدیمی‌ترین‌ها',
onSelected: () => setState(
() => state.selectedSortTypeIndex = 1,
),
@ -193,12 +195,20 @@ class _StudioState extends State<Studio> {
),
const SizedBox(height: 24),
DidvanRadialButton(
title: 'پربحث‌ترین‌ها',
title: 'پربازدیدترین‌ها',
onSelected: () => setState(
() => 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 {
if (selectedSortTypeIndex == 0) return 'date';
if (selectedSortTypeIndex == 1) return 'view';
if (selectedSortTypeIndex == 0 || selectedSortTypeIndex == 1) return 'date';
if (selectedSortTypeIndex == 2) return 'view';
return 'comment';
}
String get orderString {
if (selectedSortTypeIndex == 0) return 'تازه‌ترین‌ها';
if (selectedSortTypeIndex == 1) return 'پربازدیدترین‌ها';
if (selectedSortTypeIndex == 1) return 'قدیمی‌ترین‌ها';
if (selectedSortTypeIndex == 2) return 'پربازدیدترین‌ها';
return 'پربحث‌نرین‌ها';
}
@ -89,6 +90,7 @@ class StudioState extends CoreProvier {
type: type,
search: search,
order: order,
asc: selectedSortTypeIndex == 1,
),
),
);