Allow load/remove commands to take multiple entries at once
This commit is contained in:
parent
48f03354d3
commit
8fa9c0b762
@ -52,11 +52,11 @@ class Command extends PlayerConnectionEvent {
|
||||
// );
|
||||
// }
|
||||
|
||||
factory Command.load(String url) {
|
||||
factory Command.load(List<String> urls) {
|
||||
return Command(
|
||||
type: 'load',
|
||||
value: {
|
||||
'url': url,
|
||||
'urls': urls,
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -116,11 +116,11 @@ class Command extends PlayerConnectionEvent {
|
||||
);
|
||||
}
|
||||
|
||||
factory Command.playlistRemove(int position) {
|
||||
factory Command.playlistRemove(List<int> positions) {
|
||||
return Command(
|
||||
type: 'playlist_remove',
|
||||
value: {
|
||||
'position': position,
|
||||
'positions': positions,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class PlayerUIBody extends StatelessWidget {
|
||||
color: Colors.redAccent,
|
||||
onPressed: () {
|
||||
BlocProvider.of<ConnectionStateBloc>(context)
|
||||
.add(Command.playlistRemove(i));
|
||||
.add(Command.playlistRemove([i]));
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -133,7 +133,7 @@ class PlayerUIBody extends StatelessWidget {
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
BlocProvider.of<ConnectionStateBloc>(context)
|
||||
.add(Command.load(value));
|
||||
.add(Command.load([value]));
|
||||
_textController.clear();
|
||||
},
|
||||
),
|
||||
@ -144,7 +144,7 @@ class PlayerUIBody extends StatelessWidget {
|
||||
tooltip: 'Add link to playlist',
|
||||
onPressed: () {
|
||||
BlocProvider.of<ConnectionStateBloc>(context)
|
||||
.add(Command.load(_textController.text));
|
||||
.add(Command.load([_textController.text]));
|
||||
_textController.clear();
|
||||
},
|
||||
),
|
||||
@ -159,9 +159,7 @@ class PlayerUIBody extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final link in links.split('\n')) {
|
||||
blocProvider.add(Command.load(link));
|
||||
}
|
||||
blocProvider.add(Command.load(links.split('\n')));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user