2020-09-07 22:05:50 +02:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-09-05 23:55:07 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-01-24 20:01:55 +01:00
|
|
|
import 'package:lemmy_api_client/v2.dart';
|
2020-09-05 23:55:07 +02:00
|
|
|
|
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-02-09 15:12:13 +01:00
|
|
|
@required this.onSortChanged,
|
|
|
|
@required this.sortValue,
|
2020-09-29 00:35:05 +02:00
|
|
|
this.styleButton = true,
|
2021-02-09 15:12:13 +01:00
|
|
|
}) : assert(sortValue != null);
|
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,
|
|
|
|
mapValueToString: (value) => value.value,
|
2020-09-05 23:55:07 +02:00
|
|
|
),
|
2021-02-09 15:12:13 +01:00
|
|
|
const Spacer(),
|
|
|
|
if (styleButton)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.view_stream),
|
|
|
|
// TODO: create compact post and dropdown for selecting
|
|
|
|
onPressed: () => print('TBD'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-09-05 23:55:07 +02:00
|
|
|
}
|