2020-09-05 23:55:07 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-04-05 20:14:39 +02:00
|
|
|
import 'package:lemmy_api_client/v3.dart';
|
2020-09-05 23:55:07 +02:00
|
|
|
|
2021-03-09 22:21:14 +01:00
|
|
|
import '../l10n/l10n.dart';
|
2021-02-09 15:12:13 +01:00
|
|
|
import 'radio_picker.dart';
|
2020-09-07 16:19:28 +02:00
|
|
|
|
2020-09-30 19:05:00 +02:00
|
|
|
/// Dropdown filters where you can change sorting or viewing type
|
2021-02-09 15:12:13 +01:00
|
|
|
class PostListOptions extends StatelessWidget {
|
|
|
|
final ValueChanged<SortType> onSortChanged;
|
|
|
|
final SortType sortValue;
|
2020-09-29 00:35:05 +02:00
|
|
|
final bool styleButton;
|
2020-09-05 23:55:07 +02:00
|
|
|
|
2021-01-03 18:21:56 +01:00
|
|
|
const PostListOptions({
|
2021-04-09 00:11:44 +02:00
|
|
|
required this.onSortChanged,
|
|
|
|
required this.sortValue,
|
2020-09-29 00:35:05 +02:00
|
|
|
this.styleButton = true,
|
2021-04-11 00:20:47 +02:00
|
|
|
});
|
2020-09-05 23:55:07 +02:00
|
|
|
|
|
|
|
@override
|
2021-02-09 15:12:13 +01:00
|
|
|
Widget build(BuildContext context) => Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
RadioPicker<SortType>(
|
|
|
|
title: 'sort by',
|
|
|
|
values: SortType.values,
|
|
|
|
groupValue: sortValue,
|
|
|
|
onChanged: onSortChanged,
|
2021-03-09 22:21:14 +01:00
|
|
|
mapValueToString: (value) => value.tr(context),
|
2020-09-05 23:55:07 +02:00
|
|
|
),
|
2021-02-09 15:12:13 +01:00
|
|
|
const Spacer(),
|
|
|
|
if (styleButton)
|
2021-09-23 19:25:03 +02:00
|
|
|
const IconButton(
|
|
|
|
icon: Icon(Icons.view_stream),
|
2021-02-09 15:12:13 +01:00
|
|
|
// TODO: create compact post and dropdown for selecting
|
2021-09-23 19:25:03 +02:00
|
|
|
onPressed: null,
|
2021-02-09 15:12:13 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-09-05 23:55:07 +02:00
|
|
|
}
|