-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
339 additions
and
2 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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import 'package:aoba/data/model/aliases.dart'; | ||
import 'package:isar/isar.dart'; | ||
import 'package:aoba/widgets/lists/media_list.dart'; | ||
import 'package:aoba/data/remote/gql/schema/schema.gql.dart'; | ||
|
||
part 'lists.g.dart'; | ||
|
||
@embedded | ||
class ListsPreferences { | ||
@Enumerated(EnumType.name) | ||
ListDisplayType displayType = ListDisplayType.grid; | ||
|
||
@Enumerated(EnumType.name) | ||
MediaListSort sort = MediaListSort.MEDIA_TITLE_ROMAJI; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import 'package:aoba/data/remote/gql/schema/schema.gql.dart'; | ||
|
||
typedef UserTitleLanguage = Enum$UserTitleLanguage; | ||
|
||
typedef MediaType = Enum$MediaType; | ||
typedef MediaFormat = Enum$MediaFormat; | ||
typedef MediaStatus = Enum$MediaStatus; | ||
|
||
typedef ScoreFormat = Enum$ScoreFormat; | ||
typedef MediaListStatus = Enum$MediaListStatus; | ||
typedef MediaListSort = Enum$MediaListSort; | ||
|
||
typedef FuzzyDateInput = Input$FuzzyDateInput; |
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
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
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,91 @@ | ||
import 'package:aoba/data/model/aliases.dart'; | ||
import 'package:aoba/data/model/extensions.dart'; | ||
import 'package:flextensions/extensions/build_context.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
const _kAvailableSortOptions = [ | ||
MediaListSort.SCORE, | ||
MediaListSort.PROGRESS, | ||
MediaListSort.UPDATED_TIME, | ||
MediaListSort.ADDED_TIME, | ||
MediaListSort.STARTED_ON, | ||
MediaListSort.FINISHED_ON, | ||
MediaListSort.MEDIA_POPULARITY, | ||
MediaListSort.REPEAT, | ||
]; | ||
|
||
class SortOption extends StatefulWidget { | ||
final MediaListSort titleSortOption; | ||
final MediaListSort value; | ||
final ValueChanged<MediaListSort> onChange; | ||
|
||
const SortOption({ | ||
super.key, | ||
required this.titleSortOption, | ||
required this.value, | ||
required this.onChange, | ||
}); | ||
|
||
@override | ||
State<SortOption> createState() => _SortOptionState(); | ||
} | ||
|
||
class _SortOptionState extends State<SortOption> { | ||
late bool descending = widget.value.desc; | ||
|
||
void _onSortChange(MediaListSort value) { | ||
widget.onChange(value.withOrder(descending: descending)); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = context.theme; | ||
final inputDecorationPadding = theme.inputDecorationTheme.contentPadding | ||
?.resolve(Directionality.of(context)); | ||
return Row( | ||
children: [ | ||
Expanded( | ||
child: DropdownButtonFormField<MediaListSort>( | ||
value: widget.value.withoutOrder(), | ||
elevation: 0, | ||
borderRadius: BorderRadius.circular(8), | ||
decoration: InputDecoration( | ||
contentPadding: EdgeInsets.only( | ||
left: 0, | ||
right: 8, | ||
top: inputDecorationPadding?.top ?? 16, | ||
bottom: inputDecorationPadding?.bottom ?? 16, | ||
), | ||
), | ||
items: | ||
[widget.titleSortOption, ..._kAvailableSortOptions].map((it) { | ||
return DropdownMenuItem<MediaListSort>( | ||
value: it, | ||
child: Text(it.displayName), | ||
); | ||
}).toList(), | ||
onChanged: (value) { | ||
if (value != null) { | ||
_onSortChange(value); | ||
} | ||
}, | ||
), | ||
), | ||
const SizedBox(width: 8), | ||
IconButton.outlined( | ||
onPressed: () { | ||
// No need to set state as the widget will be rebuilt due to [value] | ||
// change. | ||
descending = !descending; | ||
_onSortChange(widget.value); | ||
}, | ||
icon: Icon( | ||
descending | ||
? Icons.arrow_downward_rounded | ||
: Icons.arrow_upward_rounded, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
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
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
Oops, something went wrong.