layout improvements
This commit is contained in:
@@ -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,12 +233,49 @@ 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,
|
||||
@@ -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'),
|
||||
|
||||
@@ -367,12 +367,22 @@ class _DeckConfigScreenState extends State<DeckConfigScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
_applyAndPersist();
|
||||
if (mounted) Navigator.pop(context, _deck);
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Attempt Settings'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.pop(context, _deck),
|
||||
onPressed: () {
|
||||
_applyAndPersist();
|
||||
if (mounted) Navigator.pop(context, _deck);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
@@ -667,6 +677,7 @@ class _DeckConfigScreenState extends State<DeckConfigScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,9 +683,15 @@ class DeckListScreenState extends State<DeckListScreen> {
|
||||
valueListenable: ApiAuthService.instance.currentUser,
|
||||
builder: (context, user, _) {
|
||||
if (user == null) {
|
||||
return FilledButton.tonal(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: FilledButton.tonal(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pushNamed(Routes.login),
|
||||
child: const Text('Log in'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
@@ -716,10 +722,10 @@ class DeckListScreenState extends State<DeckListScreen> {
|
||||
],
|
||||
onSelected: (value) async {
|
||||
if (value != 'logout') return;
|
||||
final navigator = Navigator.of(context);
|
||||
await ApiAuthService.instance.logout();
|
||||
navigator.pushNamedAndRemoveUntil(
|
||||
Routes.login,
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
Routes.deckList,
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -61,9 +61,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
valueListenable: ApiAuthService.instance.currentUser,
|
||||
builder: (context, user, _) {
|
||||
if (user == null) {
|
||||
return FilledButton.tonal(
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: FilledButton.tonal(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pushNamed(Routes.login),
|
||||
child: const Text('Log in'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
@@ -94,10 +100,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
],
|
||||
onSelected: (value) async {
|
||||
if (value != 'logout') return;
|
||||
final navigator = Navigator.of(context);
|
||||
await ApiAuthService.instance.logout();
|
||||
navigator.pushNamedAndRemoveUntil(
|
||||
Routes.login,
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
Routes.deckList,
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
@@ -123,7 +129,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
notchMargin: 8,
|
||||
notchMargin: 2,
|
||||
padding: EdgeInsets.zero,
|
||||
height: 40,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@@ -166,16 +174,16 @@ class _NavItem extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
customBorder: const CircleBorder(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 22, color: selected ? Theme.of(context).colorScheme.primary : null),
|
||||
const SizedBox(width: 6),
|
||||
Icon(icon, size: 18, color: selected ? Theme.of(context).colorScheme.primary : null),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontSize: 10,
|
||||
color: selected ? Theme.of(context).colorScheme.primary : null,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../routes.dart';
|
||||
import '../services/api_auth_service.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
@@ -54,7 +53,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
});
|
||||
|
||||
if (err == null) {
|
||||
Navigator.pushReplacementNamed(context, Routes.deckList);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user