first commit
Build / Build for Android (push) Has been cancelled
Build / Build for iOS (push) Has been cancelled

This commit is contained in:
Zakaria
2026-05-18 14:15:38 -04:00
commit 1563409cb1
382 changed files with 45347 additions and 0 deletions
@@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import '../../models/jellyfin_models.dart';
import '../../services/jellyfin_api_helper.dart';
import '../MusicScreen/album_item.dart';
import '../error_snackbar.dart';
class AddToPlaylistList extends StatefulWidget {
const AddToPlaylistList({
Key? key,
required this.itemToAddId,
}) : super(key: key);
final String itemToAddId;
@override
State<AddToPlaylistList> createState() => _AddToPlaylistListState();
}
class _AddToPlaylistListState extends State<AddToPlaylistList> {
final jellyfinApiHelper = GetIt.instance<JellyfinApiHelper>();
late Future<List<BaseItemDto>?> addToPlaylistListFuture;
@override
void initState() {
super.initState();
addToPlaylistListFuture = jellyfinApiHelper.getItems(
includeItemTypes: "Playlist",
sortBy: "SortName",
isGenres: false,
);
}
@override
Widget build(BuildContext context) {
return FutureBuilder<List<BaseItemDto>?>(
future: addToPlaylistListFuture,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Scrollbar(
child: ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return AlbumItem(
album: snapshot.data![index],
parentType: snapshot.data![index].type,
onTap: () async {
try {
await jellyfinApiHelper.addItemstoPlaylist(
playlistId: snapshot.data![index].id,
ids: [widget.itemToAddId],
);
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Added to playlist."),
// action: SnackBarAction(
// label: "OPEN",
// onPressed: () {
// Navigator.of(context).pushNamed(
// "/music/albumscreen",
// arguments: snapshot.data![index]);
// },
// ),
),
);
Navigator.pop(context);
} catch (e) {
errorSnackbar(e, context);
return;
}
},
);
},
),
);
} else if (snapshot.hasError) {
errorSnackbar(snapshot.error, context);
return const Center(
child: Icon(Icons.error, size: 64),
);
} else {
return const Center(
child: CircularProgressIndicator.adaptive(),
);
}
},
);
}
}
@@ -0,0 +1,93 @@
import 'package:finamp/models/jellyfin_models.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:get_it/get_it.dart';
import '../../services/finamp_user_helper.dart';
import '../../services/jellyfin_api_helper.dart';
import '../error_snackbar.dart';
class NewPlaylistDialog extends StatefulWidget {
const NewPlaylistDialog({
Key? key,
required this.itemToAdd,
}) : super(key: key);
final String itemToAdd;
@override
State<NewPlaylistDialog> createState() => _NewPlaylistDialogState();
}
class _NewPlaylistDialogState extends State<NewPlaylistDialog> {
final _formKey = GlobalKey<FormState>();
final _jellyfinApiHelper = GetIt.instance<JellyfinApiHelper>();
final _finampUserHelper = GetIt.instance<FinampUserHelper>();
bool _isSubmitting = false;
String? _name;
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context)!.newPlaylist),
content: Form(
key: _formKey,
child: TextFormField(
decoration:
InputDecoration(labelText: AppLocalizations.of(context)!.name),
textInputAction: TextInputAction.done,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context)!.required;
}
return null;
},
onFieldSubmitted: (_) async => await _submit(),
onSaved: (newValue) => _name = newValue,
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop<bool>(false),
child: Text(MaterialLocalizations.of(context).cancelButtonLabel),
),
TextButton(
onPressed: _isSubmitting ? null : () async => await _submit(),
child: Text(AppLocalizations.of(context)!.createButtonLabel),
),
],
);
}
Future<void> _submit() async {
if (_formKey.currentState != null && _formKey.currentState!.validate()) {
setState(() {
_isSubmitting = true;
});
_formKey.currentState!.save();
try {
await _jellyfinApiHelper.createNewPlaylist(NewPlaylist(
name: _name,
ids: [widget.itemToAdd],
userId: _finampUserHelper.currentUser!.id,
));
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(AppLocalizations.of(context)!.playlistCreated),
));
Navigator.of(context).pop<bool>(true);
} catch (e) {
errorSnackbar(e, context);
setState(() {
_isSubmitting = false;
});
return;
}
}
}
}