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(
|
return Command(
|
||||||
type: 'load',
|
type: 'load',
|
||||||
value: {
|
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(
|
return Command(
|
||||||
type: 'playlist_remove',
|
type: 'playlist_remove',
|
||||||
value: {
|
value: {
|
||||||
'position': position,
|
'positions': positions,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ class PlayerUIBody extends StatelessWidget {
|
|||||||
color: Colors.redAccent,
|
color: Colors.redAccent,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
BlocProvider.of<ConnectionStateBloc>(context)
|
BlocProvider.of<ConnectionStateBloc>(context)
|
||||||
.add(Command.playlistRemove(i));
|
.add(Command.playlistRemove([i]));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -133,7 +133,7 @@ class PlayerUIBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onSubmitted: (value) {
|
onSubmitted: (value) {
|
||||||
BlocProvider.of<ConnectionStateBloc>(context)
|
BlocProvider.of<ConnectionStateBloc>(context)
|
||||||
.add(Command.load(value));
|
.add(Command.load([value]));
|
||||||
_textController.clear();
|
_textController.clear();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -144,7 +144,7 @@ class PlayerUIBody extends StatelessWidget {
|
|||||||
tooltip: 'Add link to playlist',
|
tooltip: 'Add link to playlist',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
BlocProvider.of<ConnectionStateBloc>(context)
|
BlocProvider.of<ConnectionStateBloc>(context)
|
||||||
.add(Command.load(_textController.text));
|
.add(Command.load([_textController.text]));
|
||||||
_textController.clear();
|
_textController.clear();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -159,9 +159,7 @@ class PlayerUIBody extends StatelessWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final link in links.split('\n')) {
|
blocProvider.add(Command.load(links.split('\n')));
|
||||||
blocProvider.add(Command.load(link));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user