Smaller UI tweaks and update indicator
This commit is contained in:
parent
55d6743e55
commit
c316f8ebe1
4 changed files with 78 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
import '../../domain/entities/album.dart';
|
||||
import '../state/music_store.dart';
|
||||
|
||||
class SettingsPage extends StatelessWidget {
|
||||
|
@ -11,12 +14,51 @@ class SettingsPage extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 12.0,
|
||||
),
|
||||
child: Text(
|
||||
'Library',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
// const Divider(),
|
||||
ListTile(
|
||||
title: const Text('Update database'),
|
||||
title: const Text('Update library'),
|
||||
subtitle: Observer(builder: (_) {
|
||||
final ObservableFuture<List<Album>> albumsFuture =
|
||||
store.albumsFuture;
|
||||
if (albumsFuture.status == FutureStatus.fulfilled) {
|
||||
final int albumCount = (albumsFuture.result as List).length;
|
||||
return Text('XX artsts, $albumCount albums, XXXX songs');
|
||||
}
|
||||
return const Text('');
|
||||
}),
|
||||
onTap: () {
|
||||
store.updateDatabase();
|
||||
},
|
||||
)
|
||||
trailing: Observer(builder: (_) {
|
||||
if (store.isUpdatingDatabase) {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
return Container(
|
||||
height: 0,
|
||||
width: 0,
|
||||
);
|
||||
}),
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
title: Text('Select library folders'),
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
onTap: () {},
|
||||
),
|
||||
const Divider(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -26,10 +26,17 @@ abstract class _MusicStore with Store {
|
|||
@observable
|
||||
ObservableFuture<List<Album>> albumsFuture;
|
||||
|
||||
@observable
|
||||
bool isUpdatingDatabase = false;
|
||||
|
||||
@action
|
||||
Future<void> updateDatabase() async {
|
||||
await _updateDatabase();
|
||||
fetchAlbums();
|
||||
isUpdatingDatabase = true;
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
isUpdatingDatabase = false;
|
||||
|
||||
// await _updateDatabase();
|
||||
// fetchAlbums();
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
@ -26,6 +26,24 @@ mixin _$MusicStore on _MusicStore, Store {
|
|||
}, _$albumsFutureAtom, name: '${_$albumsFutureAtom.name}_set');
|
||||
}
|
||||
|
||||
final _$isUpdatingDatabaseAtom = Atom(name: '_MusicStore.isUpdatingDatabase');
|
||||
|
||||
@override
|
||||
bool get isUpdatingDatabase {
|
||||
_$isUpdatingDatabaseAtom.context
|
||||
.enforceReadPolicy(_$isUpdatingDatabaseAtom);
|
||||
_$isUpdatingDatabaseAtom.reportObserved();
|
||||
return super.isUpdatingDatabase;
|
||||
}
|
||||
|
||||
@override
|
||||
set isUpdatingDatabase(bool value) {
|
||||
_$isUpdatingDatabaseAtom.context.conditionallyRunInAction(() {
|
||||
super.isUpdatingDatabase = value;
|
||||
_$isUpdatingDatabaseAtom.reportChanged();
|
||||
}, _$isUpdatingDatabaseAtom, name: '${_$isUpdatingDatabaseAtom.name}_set');
|
||||
}
|
||||
|
||||
final _$updateDatabaseAsyncAction = AsyncAction('updateDatabase');
|
||||
|
||||
@override
|
||||
|
@ -47,7 +65,8 @@ mixin _$MusicStore on _MusicStore, Store {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
final string = 'albumsFuture: ${albumsFuture.toString()}';
|
||||
final string =
|
||||
'albumsFuture: ${albumsFuture.toString()},isUpdatingDatabase: ${isUpdatingDatabase.toString()}';
|
||||
return '{$string}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,11 @@ class AlbumArtListTile extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: Card(
|
||||
child: utils.getAlbumImage(albumArtPath),
|
||||
child: Container(
|
||||
height: 56,
|
||||
width: 56,
|
||||
child: utils.getAlbumImage(albumArtPath),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
margin: const EdgeInsets.all(0),
|
||||
shape: RoundedRectangleBorder(
|
||||
|
|
Loading…
Add table
Reference in a new issue