mucke/lib/presentation/pages/settings_page.dart

76 lines
2.1 KiB
Dart
Raw Normal View History

2020-03-28 09:39:59 +01:00
import 'package:flutter/material.dart';
2020-03-30 23:19:02 +02:00
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:provider/provider.dart';
2020-03-28 09:39:59 +01:00
2020-03-30 23:19:02 +02:00
import '../../domain/entities/album.dart';
import '../state/music_data_store.dart';
2020-03-28 09:39:59 +01:00
class SettingsPage extends StatelessWidget {
const SettingsPage({Key key}) : super(key: key);
2020-03-28 09:39:59 +01:00
@override
Widget build(BuildContext context) {
final MusicDataStore store = Provider.of<MusicDataStore>(context);
2020-03-28 09:39:59 +01:00
return ListView(
children: [
2020-04-04 21:02:42 +02:00
Container(
height: 12.0,
),
2020-03-30 23:19:02 +02:00
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
2020-04-04 21:02:42 +02:00
vertical: 4.0,
2020-03-30 23:19:02 +02:00
),
child: Text(
'Library',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
),
),
),
2020-03-28 09:39:59 +01:00
ListTile(
2020-03-30 23:19:02 +02:00
title: const Text('Update library'),
subtitle: Observer(builder: (_) {
final ObservableFuture<List<Album>> albumsFuture =
store.albumsFuture;
final bool isFetchingSongs = store.isFetchingSongs;
2020-04-04 21:02:42 +02:00
if (albumsFuture.status == FutureStatus.fulfilled &&
!isFetchingSongs) {
final int albumCount = (albumsFuture.result as List).length;
final int songCount = store.songs.length;
return Text('XX artists, $albumCount albums, $songCount songs');
2020-03-30 23:19:02 +02:00
}
return const Text('');
}),
2020-03-28 09:39:59 +01:00
onTap: () {
store.updateDatabase();
},
2020-03-30 23:19:02 +02:00
trailing: Observer(builder: (_) {
if (store.isUpdatingDatabase) {
return const CircularProgressIndicator();
}
return Container(
height: 0,
width: 0,
);
}),
),
2020-04-04 21:02:42 +02:00
const Divider(
height: 4.0,
),
2020-03-30 23:19:02 +02:00
ListTile(
title: const Text('Select library folders'),
2020-03-30 23:19:02 +02:00
trailing: Icon(Icons.chevron_right),
onTap: () {},
),
2020-04-04 21:02:42 +02:00
const Divider(
height: 4.0,
),
2020-03-28 09:39:59 +01:00
],
);
}
}