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/material.dart';
|
||||||
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
|
import '../../domain/entities/album.dart';
|
||||||
import '../state/music_store.dart';
|
import '../state/music_store.dart';
|
||||||
|
|
||||||
class SettingsPage extends StatelessWidget {
|
class SettingsPage extends StatelessWidget {
|
||||||
|
@ -11,12 +14,51 @@ class SettingsPage extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
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(
|
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: () {
|
onTap: () {
|
||||||
store.updateDatabase();
|
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
|
@observable
|
||||||
ObservableFuture<List<Album>> albumsFuture;
|
ObservableFuture<List<Album>> albumsFuture;
|
||||||
|
|
||||||
|
@observable
|
||||||
|
bool isUpdatingDatabase = false;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future<void> updateDatabase() async {
|
Future<void> updateDatabase() async {
|
||||||
await _updateDatabase();
|
isUpdatingDatabase = true;
|
||||||
fetchAlbums();
|
await Future.delayed(Duration(seconds: 5));
|
||||||
|
isUpdatingDatabase = false;
|
||||||
|
|
||||||
|
// await _updateDatabase();
|
||||||
|
// fetchAlbums();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
|
@ -26,6 +26,24 @@ mixin _$MusicStore on _MusicStore, Store {
|
||||||
}, _$albumsFutureAtom, name: '${_$albumsFutureAtom.name}_set');
|
}, _$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');
|
final _$updateDatabaseAsyncAction = AsyncAction('updateDatabase');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -47,7 +65,8 @@ mixin _$MusicStore on _MusicStore, Store {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
final string = 'albumsFuture: ${albumsFuture.toString()}';
|
final string =
|
||||||
|
'albumsFuture: ${albumsFuture.toString()},isUpdatingDatabase: ${isUpdatingDatabase.toString()}';
|
||||||
return '{$string}';
|
return '{$string}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,11 @@ class AlbumArtListTile extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Card(
|
leading: Card(
|
||||||
child: utils.getAlbumImage(albumArtPath),
|
child: Container(
|
||||||
|
height: 56,
|
||||||
|
width: 56,
|
||||||
|
child: utils.getAlbumImage(albumArtPath),
|
||||||
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
margin: const EdgeInsets.all(0),
|
margin: const EdgeInsets.all(0),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
|
|
Loading…
Add table
Reference in a new issue