|
|
|
|
@ -69,15 +69,6 @@ class CommunityDecksScreenState extends State<CommunityDecksScreen> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _load() async {
|
|
|
|
|
final user = ApiAuthService.instance.currentUser.value;
|
|
|
|
|
if (user == null) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_loading = false;
|
|
|
|
|
_decks = [];
|
|
|
|
|
_error = null;
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
_loading = true;
|
|
|
|
|
_error = null;
|
|
|
|
|
@ -179,34 +170,6 @@ class CommunityDecksScreenState extends State<CommunityDecksScreen> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final user = ApiAuthService.instance.currentUser.value;
|
|
|
|
|
|
|
|
|
|
if (user == null) {
|
|
|
|
|
final body = Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'Log in to browse and add community decks.',
|
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
|
FilledButton(
|
|
|
|
|
onPressed: () => Navigator.pushNamed(context, Routes.login)
|
|
|
|
|
.then((_) => _load()),
|
|
|
|
|
child: const Text('Log in'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (widget.showAppBar) {
|
|
|
|
|
return Scaffold(appBar: AppBar(title: const Text('Community decks')), body: body);
|
|
|
|
|
}
|
|
|
|
|
return body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final body = _loading
|
|
|
|
|
? const Center(child: CircularProgressIndicator())
|
|
|
|
|
: _error != null
|
|
|
|
|
@ -270,13 +233,50 @@ class CommunityDecksScreenState extends State<CommunityDecksScreen> {
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.person_outline,
|
|
|
|
|
size: 14,
|
|
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Text(
|
|
|
|
|
'${d.questionCount} questions'
|
|
|
|
|
'${d.ownerDisplayName != null ? ' · ${d.ownerDisplayName}' : ''}',
|
|
|
|
|
d.ownerDisplayName != null && d.ownerDisplayName!.isNotEmpty
|
|
|
|
|
? d.ownerDisplayName!
|
|
|
|
|
: 'Unknown',
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'${d.questionCount} questions',
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
|
),
|
|
|
|
|
if (d.averageRating != null) ...[
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.star,
|
|
|
|
|
size: 14,
|
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 2),
|
|
|
|
|
Text(
|
|
|
|
|
d.ratingCount != null && d.ratingCount! > 0
|
|
|
|
|
? '${d.averageRating!.toStringAsFixed(1)} (${d.ratingCount})'
|
|
|
|
|
: d.averageRating!.toStringAsFixed(1),
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
isThreeLine: true,
|
|
|
|
|
trailing: d.userHasThis
|
|
|
|
|
@ -287,6 +287,14 @@ class CommunityDecksScreenState extends State<CommunityDecksScreen> {
|
|
|
|
|
vertical: 4,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: user == null
|
|
|
|
|
? FilledButton.tonal(
|
|
|
|
|
onPressed: () => Navigator.pushNamed(
|
|
|
|
|
context,
|
|
|
|
|
Routes.login,
|
|
|
|
|
).then((_) => _load()),
|
|
|
|
|
child: const Text('Log in to add'),
|
|
|
|
|
)
|
|
|
|
|
: FilledButton.tonal(
|
|
|
|
|
onPressed: () => _addToMyDecks(d),
|
|
|
|
|
child: const Text('Add'),
|
|
|
|
|
|