first commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
class DownloadLocationDeleteDialog extends StatelessWidget {
|
||||
const DownloadLocationDeleteDialog({
|
||||
Key? key,
|
||||
required this.id,
|
||||
}) : super(key: key);
|
||||
|
||||
final String id;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Are you sure?"),
|
||||
content: const Text(
|
||||
"Deleting a download location doesn't actually delete any downloads. It just removes the menu entry."),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text("CANCEL"),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text("DELETE"),
|
||||
onPressed: () {
|
||||
FinampSettingsHelper.deleteDownloadLocation(id);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
import 'download_location_list_tile.dart';
|
||||
|
||||
class DownloadLocationList extends StatefulWidget {
|
||||
const DownloadLocationList({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DownloadLocationList> createState() => _DownloadLocationListState();
|
||||
}
|
||||
|
||||
class _DownloadLocationListState extends State<DownloadLocationList> {
|
||||
late Iterable<DownloadLocation> downloadLocationsIterable;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
downloadLocationsIterable =
|
||||
FinampSettingsHelper.finampSettings.downloadLocationsMap.values;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<FinampSettings>>(
|
||||
valueListenable: FinampSettingsHelper.finampSettingsListener,
|
||||
builder: (context, box, child) {
|
||||
return ListView.builder(
|
||||
itemCount: downloadLocationsIterable.length,
|
||||
itemBuilder: (context, index) {
|
||||
return DownloadLocationListTile(
|
||||
downloadLocation: downloadLocationsIterable.elementAt(index),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import 'download_location_delete_dialog.dart';
|
||||
|
||||
class DownloadLocationListTile extends StatelessWidget {
|
||||
const DownloadLocationListTile({
|
||||
Key? key,
|
||||
required this.downloadLocation,
|
||||
}) : super(key: key);
|
||||
|
||||
final DownloadLocation downloadLocation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(downloadLocation.name),
|
||||
subtitle: Text(
|
||||
downloadLocation.path,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete),
|
||||
onPressed: downloadLocation.deletable
|
||||
? () => showDialog(
|
||||
context: context,
|
||||
builder: (context) => DownloadLocationDeleteDialog(
|
||||
id: downloadLocation.id,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user